p3lib 1.1.106__tar.gz → 1.1.107__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 (34) hide show
  1. {p3lib-1.1.106 → p3lib-1.1.107}/PKG-INFO +1 -1
  2. p3lib-1.1.107/pyproject.toml +10 -0
  3. {p3lib-1.1.106 → p3lib-1.1.107}/setup.cfg +1 -1
  4. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/pconfig.py +58 -22
  5. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib.egg-info/PKG-INFO +1 -1
  6. p3lib-1.1.106/pyproject.toml +0 -6
  7. {p3lib-1.1.106 → p3lib-1.1.107}/LICENSE +0 -0
  8. {p3lib-1.1.106 → p3lib-1.1.107}/README.md +0 -0
  9. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/__init__.py +0 -0
  10. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/ate.py +0 -0
  11. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/bokeh_auth.py +0 -0
  12. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/bokeh_gui.py +0 -0
  13. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/boot_manager.py +0 -0
  14. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/conduit.py +0 -0
  15. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/database_if.py +0 -0
  16. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/file_io.py +0 -0
  17. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/gnome_desktop_app.py +0 -0
  18. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/helper.py +0 -0
  19. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/json_networking.py +0 -0
  20. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/mqtt_rpc.py +0 -0
  21. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/netif.py +0 -0
  22. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/netplotly.py +0 -0
  23. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/ngt.py +0 -0
  24. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/ssh.py +0 -0
  25. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/table_plot.py +0 -0
  26. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib/uio.py +0 -0
  27. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib.egg-info/SOURCES.txt +0 -0
  28. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib.egg-info/dependency_links.txt +0 -0
  29. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib.egg-info/requires.txt +0 -0
  30. {p3lib-1.1.106 → p3lib-1.1.107}/src/p3lib.egg-info/top_level.txt +0 -0
  31. {p3lib-1.1.106 → p3lib-1.1.107}/tests/test_conduit.py +0 -0
  32. {p3lib-1.1.106 → p3lib-1.1.107}/tests/test_json_networking.py +0 -0
  33. {p3lib-1.1.106 → p3lib-1.1.107}/tests/test_netif.py +0 -0
  34. {p3lib-1.1.106 → p3lib-1.1.107}/tests/test_ssh.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: p3lib
3
- Version: 1.1.106
3
+ Version: 1.1.107
4
4
  Summary: A group of python modules for networking, plotting data, config storage, automating boot scripts, ssh access and user input output.
5
5
  Home-page: https://github.com/pjaos/p3lib
6
6
  Author: Paul Austen
@@ -0,0 +1,10 @@
1
+ [tool.poetry]
2
+ name = "p3lib"
3
+ version = "1.1.107"
4
+
5
+ [build-system]
6
+ requires = [
7
+ "setuptools>=42",
8
+ "wheel"
9
+ ]
10
+ build-backend = "setuptools.build_meta"
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = p3lib
3
- version = 1.1.106
3
+ version = 1.1.107
4
4
  author = Paul Austen
5
5
  author_email = pausten.os@gmail.com
6
6
  description = A group of python modules for networking, plotting data, config storage, automating boot scripts, ssh access and user input output.
@@ -339,7 +339,15 @@ class ConfigManager(object):
339
339
 
340
340
  return join( configPath, cfgFilename )
341
341
 
342
- def __init__(self, uio, cfgFilename, defaultConfig, addDotToFilename=True, encrypt=False, cfgPath=None):
342
+ def __init__(self,
343
+ uio,
344
+ cfgFilename,
345
+ defaultConfig,
346
+ addDotToFilename=True,
347
+ encrypt=False,
348
+ cfgPath=None,
349
+ stripUnknownKeys=True,
350
+ addNewKeys=True):
343
351
  """@brief Constructor
344
352
  @param uio A UIO (User Input Output) instance. May be set to None if no user messages are required.
345
353
  @param cfgFilename The name of the config file. If this is None then the default config filename is used.
@@ -351,13 +359,17 @@ class ConfigManager(object):
351
359
  probably the best we can do. Therefore if encrypt is set True then the
352
360
  an ssh key must be present in the ~/.ssh folder named id_rsa.
353
361
  @param cfgPath The config path when the config file will be stored. By default this is unset and the
354
- current users home folder is the location of the config file."""
362
+ current users home folder is the location of the config file.
363
+ @param stripUnknownKeys If True then keys in the dict but not in the default config dict are stripped from the config.
364
+ @param addNewKeys If keys are found in the default config that are not in the config dict, add them."""
355
365
  self._uio = uio
356
366
  self._cfgFilename = cfgFilename
357
367
  self._defaultConfig = defaultConfig
358
368
  self._addDotToFilename = addDotToFilename
359
369
  self._encrypt = encrypt
360
370
  self._cfgPath = cfgPath
371
+ self._stripUnknownKeys = stripUnknownKeys
372
+ self._addNewKeys = addNewKeys
361
373
  self._configDict = {}
362
374
 
363
375
  # If the user passed None in as the cfg filename then generate the default config file.
@@ -463,7 +475,8 @@ class ConfigManager(object):
463
475
  return dictLoaded
464
476
 
465
477
  def load(self, showLoadedMsg=True):
466
- """@brief Load the config."""
478
+ """@brief Load the config.
479
+ @param showLoadedMsg If True load messages are displayed."""
467
480
 
468
481
  if not isfile(self._cfgFile):
469
482
 
@@ -483,17 +496,19 @@ class ConfigManager(object):
483
496
  # Config parameters may be added or dropped over time. We use the default config to
484
497
  # check for parameters that should be added/removed.
485
498
 
486
- # Add any missing keys to the loaded config from the default config.
487
- for defaultKey in defaultConfigKeys:
488
- if defaultKey not in loadedConfigKeys:
489
- loadedConfig[defaultKey] = self._defaultConfig[defaultKey]
490
- self._debug("----------> DEFAULT VALUE ADDED: {} = {}".format(defaultKey, loadedConfig[defaultKey]))
499
+ if self._addNewKeys:
500
+ # Add any missing keys to the loaded config from the default config.
501
+ for defaultKey in defaultConfigKeys:
502
+ if defaultKey not in loadedConfigKeys:
503
+ loadedConfig[defaultKey] = self._defaultConfig[defaultKey]
504
+ self._debug("----------> DEFAULT VALUE ADDED: {} = {}".format(defaultKey, loadedConfig[defaultKey]))
491
505
 
492
- # If some keys have been dropped from the config, remove them.
493
- for loadedConfigKey in loadedConfigKeys:
494
- if loadedConfigKey not in defaultConfigKeys:
495
- self._debug("----------> DROPPED FROM CONFIG: {} = {}".format(loadedConfigKey, loadedConfig[loadedConfigKey]))
496
- loadedConfig.pop(loadedConfigKey, None)
506
+ if self._stripUnknownKeys:
507
+ # If some keys have been dropped from the config, remove them.
508
+ for loadedConfigKey in loadedConfigKeys:
509
+ if loadedConfigKey not in defaultConfigKeys:
510
+ self._debug("----------> DROPPED FROM CONFIG: {} = {}".format(loadedConfigKey, loadedConfig[loadedConfigKey]))
511
+ loadedConfig.pop(loadedConfigKey, None)
497
512
 
498
513
  self._configDict = loadedConfig
499
514
  self._info("Loaded config from %s" % (self._cfgFile) )
@@ -760,10 +775,12 @@ class DotConfigManager(ConfigManager):
760
775
  KEY_EDIT_ORDER_LIST = None
761
776
 
762
777
  @staticmethod
763
- def GetDefaultConfigFilename():
778
+ def GetDefaultConfigFilename(filenameOverride=None):
764
779
  """@brief Get the default name of the config file for this app. This will be the program name
765
780
  (file that started up initially) without the .py extension. A .cfg extension is added
766
- and it will be found in the ~/.config folder."""
781
+ and it will be found in the ~/.config folder.
782
+ @param filenameOverride The name for the config file in the .config folder. If left as None then the program name ise used
783
+ as the config filename."""
767
784
  dotConfigFolder = '.config'
768
785
  if platform.system() == 'Linux' and os.geteuid() == 0:
769
786
  homePath = "/root"
@@ -779,10 +796,13 @@ class DotConfigManager(ConfigManager):
779
796
  # Create the ~/.config folder
780
797
  os.makedirs(configFolder)
781
798
 
782
- progName = sys.argv[0]
783
- if progName.endswith('.py'):
784
- progName = progName[0:-3]
785
- progName = os.path.basename(progName).strip()
799
+ if filenameOverride:
800
+ progName = filenameOverride
801
+ else:
802
+ progName = sys.argv[0]
803
+ if progName.endswith('.py'):
804
+ progName = progName[0:-3]
805
+ progName = os.path.basename(progName).strip()
786
806
 
787
807
  # Note that we assume that addDotToFilename in the ConfigManager constructor is set True
788
808
  # as this will prefix the filename with the . character.
@@ -794,7 +814,14 @@ class DotConfigManager(ConfigManager):
794
814
 
795
815
  return configFilename
796
816
 
797
- def __init__(self, defaultConfig, keyEditOrderList=None, uio=None, encrypt=False):
817
+ def __init__(self,
818
+ defaultConfig,
819
+ keyEditOrderList=None,
820
+ uio=None,
821
+ encrypt=False,
822
+ stripUnknownKeys=True,
823
+ addNewKeys=True,
824
+ filenameOverride=None):
798
825
  """@brief Constructor
799
826
  @param defaultConfig A default config instance containing all the default key-value pairs.
800
827
  @param keyEditOrderList A list of all the dict keys in the order that the caller wishes them to be displayed top the user.
@@ -804,8 +831,17 @@ class DotConfigManager(ConfigManager):
804
831
  This is not secure but assuming the private key has not been compromised it's
805
832
  probably the best we can do.
806
833
  !!! Therefore if encrypt is set True then the an ssh key must be present !!!
807
- ||| in the ~/.ssh folder named id_rsa. !!!"""
808
- super().__init__(uio, DotConfigManager.GetDefaultConfigFilename(), defaultConfig, encrypt=encrypt)
834
+ ||| in the ~/.ssh folder named id_rsa. !!!
835
+ @param stripUnknownKeys If True then keys in the dict but not in the default config dict are stripped from the config.
836
+ @param addNewKeys If keys are found in the default config that are not in the config dict, add them.
837
+ @param filenameOverride The name for the config file in the .config folder. If left as None then the program name ise used
838
+ as the config filename."""
839
+ super().__init__(uio,
840
+ DotConfigManager.GetDefaultConfigFilename(filenameOverride),
841
+ defaultConfig,
842
+ encrypt=encrypt,
843
+ stripUnknownKeys=stripUnknownKeys,
844
+ addNewKeys=addNewKeys)
809
845
  self._keyEditOrderList = keyEditOrderList
810
846
  # Ensure the config file is present and loaded into the internal dict.
811
847
  self.load()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: p3lib
3
- Version: 1.1.106
3
+ Version: 1.1.107
4
4
  Summary: A group of python modules for networking, plotting data, config storage, automating boot scripts, ssh access and user input output.
5
5
  Home-page: https://github.com/pjaos/p3lib
6
6
  Author: Paul Austen
@@ -1,6 +0,0 @@
1
- [build-system]
2
- requires = [
3
- "setuptools>=42",
4
- "wheel"
5
- ]
6
- build-backend = "setuptools.build_meta"
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
File without changes
File without changes