fb-tools 2.5.1__tar.gz → 2.5.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. {fb_tools-2.5.1/lib/fb_tools.egg-info → fb_tools-2.5.2}/PKG-INFO +1 -1
  2. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/__init__.py +1 -1
  3. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/handling_obj.py +23 -6
  4. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/local_version.py +1 -1
  5. {fb_tools-2.5.1 → fb_tools-2.5.2/lib/fb_tools.egg-info}/PKG-INFO +1 -1
  6. {fb_tools-2.5.1 → fb_tools-2.5.2}/locale/de/LC_MESSAGES/fb_tools.mo +0 -0
  7. {fb_tools-2.5.1 → fb_tools-2.5.2}/locale/en/LC_MESSAGES/fb_tools.mo +0 -0
  8. {fb_tools-2.5.1 → fb_tools-2.5.2}/test/test_20_handling_object.py +89 -11
  9. {fb_tools-2.5.1 → fb_tools-2.5.2}/LICENSE +0 -0
  10. {fb_tools-2.5.1 → fb_tools-2.5.2}/MANIFEST.in +0 -0
  11. {fb_tools-2.5.1 → fb_tools-2.5.2}/README.md +0 -0
  12. {fb_tools-2.5.1 → fb_tools-2.5.2}/bin/get-file-to-remove +0 -0
  13. {fb_tools-2.5.1 → fb_tools-2.5.2}/bin/myip +0 -0
  14. {fb_tools-2.5.1 → fb_tools-2.5.2}/bin/update-ddns +0 -0
  15. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/app.py +0 -0
  16. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/argparse_actions.py +0 -0
  17. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/cfg_app.py +0 -0
  18. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/collections.py +0 -0
  19. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/common.py +0 -0
  20. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/config.py +0 -0
  21. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/ddns/__init__.py +0 -0
  22. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/ddns/config.py +0 -0
  23. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/ddns/errors.py +0 -0
  24. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/ddns/myip_app.py +0 -0
  25. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/ddns/update_app.py +0 -0
  26. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/errors.py +0 -0
  27. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/get_file_rm_app.py +0 -0
  28. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/handler/__init__.py +0 -0
  29. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/handler/lock.py +0 -0
  30. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/mailaddress.py +0 -0
  31. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/merge.py +0 -0
  32. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/multi_config/__init__.py +0 -0
  33. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/multi_config/files.py +0 -0
  34. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/multi_config/inits.py +0 -0
  35. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/multi_config/read.py +0 -0
  36. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/obj.py +0 -0
  37. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/pidfile.py +0 -0
  38. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools/xlate.py +0 -0
  39. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools.egg-info/SOURCES.txt +0 -0
  40. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools.egg-info/dependency_links.txt +0 -0
  41. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools.egg-info/requires.txt +0 -0
  42. {fb_tools-2.5.1 → fb_tools-2.5.2}/lib/fb_tools.egg-info/top_level.txt +0 -0
  43. {fb_tools-2.5.1 → fb_tools-2.5.2}/locale/de/LC_MESSAGES/fb_tools.po +0 -0
  44. {fb_tools-2.5.1 → fb_tools-2.5.2}/locale/en/LC_MESSAGES/fb_tools.po +0 -0
  45. {fb_tools-2.5.1 → fb_tools-2.5.2}/locale/fb_tools.pot +0 -0
  46. {fb_tools-2.5.1 → fb_tools-2.5.2}/setup.cfg +0 -0
  47. {fb_tools-2.5.1 → fb_tools-2.5.2}/setup.py +0 -0
  48. {fb_tools-2.5.1 → fb_tools-2.5.2}/test/call_script.sh +0 -0
  49. {fb_tools-2.5.1 → fb_tools-2.5.2}/test/call_sleep.sh +0 -0
  50. {fb_tools-2.5.1 → fb_tools-2.5.2}/test/do_sleep +0 -0
  51. {fb_tools-2.5.1 → fb_tools-2.5.2}/test/general.py +0 -0
  52. {fb_tools-2.5.1 → fb_tools-2.5.2}/test/test_00_errors.py +0 -0
  53. {fb_tools-2.5.1 → fb_tools-2.5.2}/test/test_05_common.py +0 -0
  54. {fb_tools-2.5.1 → fb_tools-2.5.2}/test/test_10_base_object.py +0 -0
  55. {fb_tools-2.5.1 → fb_tools-2.5.2}/test/test_13_collections.py +0 -0
  56. {fb_tools-2.5.1 → fb_tools-2.5.2}/test/test_15_mailaddress.py +0 -0
  57. {fb_tools-2.5.1 → fb_tools-2.5.2}/test/test_17_multicfg.py +0 -0
  58. {fb_tools-2.5.1 → fb_tools-2.5.2}/test/test_18_pidfile.py +0 -0
  59. {fb_tools-2.5.1 → fb_tools-2.5.2}/test/test_25_ddns_update_status.py +0 -0
  60. {fb_tools-2.5.1 → fb_tools-2.5.2}/test/test_30_base_handler.py +0 -0
  61. {fb_tools-2.5.1 → fb_tools-2.5.2}/test/test_33_lock.py +0 -0
  62. {fb_tools-2.5.1 → fb_tools-2.5.2}/test/test_40_app_modules.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fb_tools
3
- Version: 2.5.1
3
+ Version: 2.5.2
4
4
  Summary: Modules for common used objects, error classes and methods.
5
5
  Home-page: https://github.com/fbrehm/python_fb_tools
6
6
  Author: Frank Brehm
@@ -15,7 +15,7 @@ DEFAULT_ENCODING = UTF8_ENCODING
15
15
  DEFAULT_TERMINAL_WIDTH = 99
16
16
  DEFAULT_TERMINAL_HEIGHT = 40
17
17
 
18
- __version__ = '2.5.1'
18
+ __version__ = '2.5.2'
19
19
 
20
20
  from .mailaddress import MailAddress, QualifiedMailAddress, MailAddressList # noqa
21
21
  from .multi_config import BaseMultiConfig # noqa
@@ -56,7 +56,7 @@ from .errors import InterruptError, IoTimeoutError, ReadTimeoutError, WriteTimeo
56
56
  from .obj import FbBaseObject
57
57
  from .xlate import XLATOR, format_list
58
58
 
59
- __version__ = '2.2.3'
59
+ __version__ = '2.2.4'
60
60
  LOG = logging.getLogger(__name__)
61
61
 
62
62
  _ = XLATOR.gettext
@@ -171,8 +171,9 @@ class HandlingObject(FbBaseObject):
171
171
  pattern_yes_no = r'^\s*(' + '|'.join(yes_list) + '|' + '|'.join(no_list) + r')?\s*$'
172
172
  re_yes_no = re.compile(pattern_yes_no, re.IGNORECASE)
173
173
 
174
- valid_address_families = ('any', socket.AF_INET, 'ipv4', socket.AF_INET6, 'ipv6')
175
- valid_address_families_out = ("'any'", 'socket.AF_INET', "'IPv4'", 'socket.AF_INET6', "'IPv6'")
174
+ valid_address_families = ('any', 0, socket.AF_INET, 'ipv4', 4, socket.AF_INET6, 'ipv6', 6)
175
+ valid_address_families_out = (
176
+ "'any'", '0', 'socket.AF_INET', "'IPv4'", '4', 'socket.AF_INET6', "'IPv6'", '6')
176
177
 
177
178
  # -------------------------------------------------------------------------
178
179
  def __init__(
@@ -330,6 +331,12 @@ class HandlingObject(FbBaseObject):
330
331
  family = socket.AF_INET
331
332
  elif family == 'ipv6':
332
333
  family = socket.AF_INET6
334
+ elif family == 0:
335
+ family = 'any'
336
+ elif family == 4:
337
+ family = socket.AF_INET
338
+ elif family == 6:
339
+ family = socket.AF_INET6
333
340
  self._address_family = family
334
341
 
335
342
  # -------------------------------------------------------------------------
@@ -366,7 +373,7 @@ class HandlingObject(FbBaseObject):
366
373
  @rtype: dict
367
374
  """
368
375
  res = super(HandlingObject, self).as_dict(short=short)
369
- res['address_family'] = self.assumed_answer
376
+ res['address_family'] = self.address_family
370
377
  res['assumed_answer'] = self.assumed_answer
371
378
  res['fileio_timeout'] = self.fileio_timeout
372
379
  res['force'] = self.force
@@ -414,7 +421,9 @@ class HandlingObject(FbBaseObject):
414
421
  if isinstance(address_family, str):
415
422
  family = address_family.lower()
416
423
 
417
- if family is not None and family not in self.valid_address_families:
424
+ if family is None:
425
+ family = self.address_family
426
+ elif family not in self.valid_address_families:
418
427
  msg = _('Wrong address family {!r} given. Valid values are:').format(address_family)
419
428
  msg += ' ' + format_list(['None'] + list(self.valid_address_families_out))
420
429
  raise ValueError(msg)
@@ -424,12 +433,18 @@ class HandlingObject(FbBaseObject):
424
433
 
425
434
  if family == 'any':
426
435
  return 0
436
+ elif family == 0:
437
+ return 0
427
438
  elif family == 'ipv4':
428
439
  return socket.AF_INET
440
+ elif family == 4:
441
+ return socket.AF_INET
429
442
  elif family == 'ipv6':
430
443
  return socket.AF_INET6
444
+ elif family == 6:
445
+ return socket.AF_INET6
431
446
 
432
- return address_family
447
+ return family
433
448
 
434
449
  # -------------------------------------------------------------------------
435
450
  def get_address(self, host, address_family=None):
@@ -440,6 +455,8 @@ class HandlingObject(FbBaseObject):
440
455
  @param address_family: Limit the result to the addresses of the given address family.
441
456
  """
442
457
  af = self.get_address_famlily_int(address_family)
458
+ if self.verbose > 3:
459
+ LOG.debug(f'Got the integer address family {af!r} for {address_family!r}.')
443
460
 
444
461
  try:
445
462
  address = ipaddress.ip_address(host)
@@ -11,7 +11,7 @@
11
11
  __author__ = 'Frank Brehm <frank@brehm-online.com>'
12
12
  __copyright__ = '(C) 2024 by Frank Brehm, Berlin'
13
13
  __contact__ = 'frank@brehm-online.com'
14
- __version__ = '2.5.1'
14
+ __version__ = '2.5.2'
15
15
  __license__ = 'LGPL3+'
16
16
 
17
17
  # vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fb_tools
3
- Version: 2.5.1
3
+ Version: 2.5.2
4
4
  Summary: Modules for common used objects, error classes and methods.
5
5
  Home-page: https://github.com/fbrehm/python_fb_tools
6
6
  Author: Frank Brehm
@@ -84,7 +84,7 @@ class TestFbHandlingObject(FbToolsTestcase):
84
84
  # -------------------------------------------------------------------------
85
85
  def test_import(self):
86
86
  """Test instantiating fb_tools.handling_obj."""
87
- LOG.info('Testing import of fb_tools.handling_obj ...')
87
+ LOG.info(self.get_method_doc())
88
88
  import fb_tools.handling_obj
89
89
  LOG.debug('Version of fb_tools.handling_obj: {!r}.'.format(
90
90
  fb_tools.handling_obj.__version__))
@@ -112,7 +112,7 @@ class TestFbHandlingObject(FbToolsTestcase):
112
112
  # -------------------------------------------------------------------------
113
113
  def test_called_process_error(self):
114
114
  """Test raising a CalledProcessError exception."""
115
- LOG.info('Testing raising a CalledProcessError exception ...')
115
+ LOG.info(self.get_method_doc())
116
116
 
117
117
  from fb_tools.handling_obj import CalledProcessError
118
118
 
@@ -150,7 +150,7 @@ class TestFbHandlingObject(FbToolsTestcase):
150
150
  # -------------------------------------------------------------------------
151
151
  def test_timeout_expired_error(self):
152
152
  """Test raising a TimeoutExpiredError exception."""
153
- LOG.info('Testing raising a TimeoutExpiredError exception ...')
153
+ LOG.info(self.get_method_doc())
154
154
 
155
155
  from fb_tools.handling_obj import TimeoutExpiredError
156
156
 
@@ -189,7 +189,7 @@ class TestFbHandlingObject(FbToolsTestcase):
189
189
  # -------------------------------------------------------------------------
190
190
  def test_generic_handling_object(self):
191
191
  """Test init of a generic handling object."""
192
- LOG.info('Testing init of a generic handling object.')
192
+ LOG.info(self.get_method_doc())
193
193
 
194
194
  import fb_tools.handling_obj
195
195
  from fb_tools.handling_obj import HandlingObject
@@ -223,7 +223,7 @@ class TestFbHandlingObject(FbToolsTestcase):
223
223
  # -------------------------------------------------------------------------
224
224
  def test_completed_process(self):
225
225
  """Test class CompletedProcess."""
226
- LOG.info('Testing class CompletedProcess.')
226
+ LOG.info(self.get_method_doc())
227
227
 
228
228
  from fb_tools.handling_obj import CompletedProcess
229
229
  from fb_tools.handling_obj import CalledProcessError
@@ -258,7 +258,7 @@ class TestFbHandlingObject(FbToolsTestcase):
258
258
  @unittest.skipUnless(EXEC_LONG_TESTS, 'Long terming tests are not executed.')
259
259
  def test_run_simple(self):
260
260
  """Test execution of a shell script."""
261
- LOG.info('Testing execution of a shell script.')
261
+ LOG.info(self.get_method_doc())
262
262
 
263
263
  from fb_tools.common import pp
264
264
  from fb_tools.handling_obj import HandlingObject, CompletedProcess
@@ -293,7 +293,7 @@ class TestFbHandlingObject(FbToolsTestcase):
293
293
  @unittest.skipUnless(EXEC_LONG_TESTS, 'Long terming tests are not executed.')
294
294
  def test_run_timeout(self):
295
295
  """Test timing out the run() method."""
296
- LOG.info('Testing timing out the run() method.')
296
+ LOG.info(self.get_method_doc())
297
297
 
298
298
  from fb_tools.handling_obj import HandlingObject
299
299
  from fb_tools.handling_obj import TimeoutExpiredError
@@ -325,7 +325,7 @@ class TestFbHandlingObject(FbToolsTestcase):
325
325
  # -------------------------------------------------------------------------
326
326
  def test_read_file(self):
327
327
  """Test method read_file() of class HandlingObject."""
328
- LOG.info('Testing method read_file() of class HandlingObject.')
328
+ LOG.info(self.get_method_doc())
329
329
 
330
330
  from fb_tools.common import to_unicode, to_str, encode_or_bust
331
331
 
@@ -394,7 +394,7 @@ class TestFbHandlingObject(FbToolsTestcase):
394
394
  # -------------------------------------------------------------------------
395
395
  def test_write_file(self):
396
396
  """Test method write_file() of class HandlingObject."""
397
- LOG.info('Testing method write_file() of class HandlingObject.')
397
+ LOG.info(self.get_method_doc())
398
398
 
399
399
  from fb_tools.common import to_unicode, encode_or_bust
400
400
 
@@ -429,7 +429,7 @@ class TestFbHandlingObject(FbToolsTestcase):
429
429
  # -------------------------------------------------------------------------
430
430
  def test_get_command(self):
431
431
  """Test method get_command() of class HandlingObject."""
432
- LOG.info('Testing method get_command() of class HandlingObject.')
432
+ LOG.info(self.get_method_doc())
433
433
 
434
434
  from fb_tools.handling_obj import HandlingObject
435
435
 
@@ -504,12 +504,89 @@ class TestFbHandlingObject(FbToolsTestcase):
504
504
  self.assertIsInstance(p, Path)
505
505
  self.assertEqual(p.name, cmd)
506
506
 
507
+ # -------------------------------------------------------------------------
508
+ def test_get_int_addressfamily(self):
509
+ """Test property address_famlily and method get_address_famlily_int()."""
510
+ LOG.info(self.get_method_doc())
511
+
512
+ import socket
513
+
514
+ from fb_tools.handling_obj import HandlingObject
515
+
516
+ hdlr = HandlingObject(
517
+ appname=self.appname,
518
+ verbose=self.verbose,
519
+ )
520
+
521
+ af = hdlr.address_family
522
+ LOG.debug(f'Default value of property address_famlily is {af!r}.')
523
+ self.assertEqual(hdlr.address_family, 'any')
524
+
525
+ test_data = (
526
+ (socket.AF_INET, socket.AF_INET),
527
+ ('ipv4', socket.AF_INET),
528
+ (4, socket.AF_INET),
529
+ (socket.AF_INET6, socket.AF_INET6),
530
+ ('ipv6', socket.AF_INET6),
531
+ (6, socket.AF_INET6),
532
+ ('any', 'any'),
533
+ (0, 'any'),
534
+ )
535
+
536
+ for pair in test_data:
537
+ test_val = pair[0]
538
+ exp_val = pair[1]
539
+ LOG.debug(f'Testing {test_val!r} for property address_family, expecting {exp_val!r}.')
540
+ hdlr.address_family = test_val
541
+ af = hdlr.address_family
542
+ LOG.debug(f'Value of property address_famlily is {af!r}.')
543
+ self.assertEqual(af, exp_val)
544
+
545
+ test_data = (None, '0', 3, '4', 'bla')
546
+ for test_val in test_data:
547
+ LOG.debug(f'Testing {test_val!r} for property address_family.')
548
+ with self.assertRaises(ValueError) as cm:
549
+ hdlr.address_family = test_val
550
+ e = cm.exception
551
+ LOG.debug('{} raised: {}'.format(e.__class__.__name__, e))
552
+
553
+ hdlr.address_family = 0
554
+
555
+ test_data = (
556
+ (None, 0),
557
+ (0, 0),
558
+ ('any', 0),
559
+ (socket.AF_INET, socket.AF_INET),
560
+ ('ipv4', socket.AF_INET),
561
+ (4, socket.AF_INET),
562
+ (socket.AF_INET6, socket.AF_INET6),
563
+ ('ipv6', socket.AF_INET6),
564
+ (6, socket.AF_INET6),
565
+ )
566
+
567
+ for pair in test_data:
568
+ test_val = pair[0]
569
+ exp_val = pair[1]
570
+ LOG.debug(
571
+ f'Testing {test_val!r} for get_address_famlily_int(), expecting {exp_val!r}.')
572
+ af = hdlr.get_address_famlily_int(test_val)
573
+ LOG.debug(f'Return value of get_address_famlily_int() is {af!r}.')
574
+ self.assertEqual(af, exp_val)
575
+
576
+ test_data = ('0', 3, '4', 'bla', object())
577
+ for test_val in test_data:
578
+ LOG.debug(f'Testing get_address_famlily_int({test_val!r}) ...')
579
+ with self.assertRaises(ValueError) as cm:
580
+ af = hdlr.get_address_famlily_int(test_val)
581
+ e = cm.exception
582
+ LOG.debug('{} raised: {}'.format(e.__class__.__name__, e))
583
+
507
584
  # -------------------------------------------------------------------------
508
585
  @unittest.skipUnless(
509
586
  EXEC_DNS_DEPENDING_TESTS, 'Tests depending on external DNS are not executed.')
510
587
  def test_get_address(self):
511
588
  """Test method get_address() of class HandlingObject."""
512
- LOG.info('Testing method get_address() of class HandlingObject.')
589
+ LOG.info(self.get_method_doc())
513
590
 
514
591
  import ipaddress
515
592
  import socket
@@ -574,6 +651,7 @@ if __name__ == '__main__':
574
651
  suite.addTest(TestFbHandlingObject('test_read_file', verbose))
575
652
  suite.addTest(TestFbHandlingObject('test_write_file', verbose))
576
653
  suite.addTest(TestFbHandlingObject('test_get_command', verbose))
654
+ suite.addTest(TestFbHandlingObject('test_get_int_addressfamily', verbose))
577
655
  suite.addTest(TestFbHandlingObject('test_get_address', verbose))
578
656
 
579
657
  runner = unittest.TextTestRunner(verbosity=verbose)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes