p3lib 1.1.82__tar.gz → 1.1.84__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 (31) hide show
  1. {p3lib-1.1.82 → p3lib-1.1.84}/PKG-INFO +1 -1
  2. {p3lib-1.1.82 → p3lib-1.1.84}/setup.cfg +1 -1
  3. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib/pconfig.py +73 -3
  4. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib.egg-info/PKG-INFO +1 -1
  5. {p3lib-1.1.82 → p3lib-1.1.84}/LICENSE +0 -0
  6. {p3lib-1.1.82 → p3lib-1.1.84}/README.md +0 -0
  7. {p3lib-1.1.82 → p3lib-1.1.84}/pyproject.toml +0 -0
  8. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib/__init__.py +0 -0
  9. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib/ate.py +0 -0
  10. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib/bokeh_auth.py +0 -0
  11. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib/bokeh_gui.py +0 -0
  12. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib/boot_manager.py +0 -0
  13. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib/conduit.py +0 -0
  14. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib/database_if.py +0 -0
  15. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib/helper.py +0 -0
  16. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib/json_networking.py +0 -0
  17. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib/mqtt_rpc.py +0 -0
  18. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib/netif.py +0 -0
  19. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib/netplotly.py +0 -0
  20. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib/ngt.py +0 -0
  21. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib/ssh.py +0 -0
  22. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib/table_plot.py +0 -0
  23. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib/uio.py +0 -0
  24. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib.egg-info/SOURCES.txt +0 -0
  25. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib.egg-info/dependency_links.txt +0 -0
  26. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib.egg-info/requires.txt +0 -0
  27. {p3lib-1.1.82 → p3lib-1.1.84}/src/p3lib.egg-info/top_level.txt +0 -0
  28. {p3lib-1.1.82 → p3lib-1.1.84}/tests/test_conduit.py +0 -0
  29. {p3lib-1.1.82 → p3lib-1.1.84}/tests/test_json_networking.py +0 -0
  30. {p3lib-1.1.82 → p3lib-1.1.84}/tests/test_netif.py +0 -0
  31. {p3lib-1.1.82 → p3lib-1.1.84}/tests/test_ssh.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: p3lib
3
- Version: 1.1.82
3
+ Version: 1.1.84
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 +1,6 @@
1
1
  [metadata]
2
2
  name = p3lib
3
- version = 1.1.82
3
+ version = 1.1.84
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.
@@ -338,12 +338,12 @@ class ConfigManager(object):
338
338
  configPath = configPath.strip()
339
339
 
340
340
  return join( configPath, cfgFilename )
341
-
341
+
342
342
  def __init__(self, uio, cfgFilename, defaultConfig, addDotToFilename=True, encrypt=False, cfgPath=None):
343
343
  """@brief Constructor
344
344
  @param uio A UIO (User Input Output) instance. May be set to None if no user messages are required.
345
- @param cfgFilename The name of the config file.
346
- @param defaultConfig A default config instance containg all the default key-value pairs.
345
+ @param cfgFilename The name of the config file. If this is None then the default config filename is used.
346
+ @param defaultConfig A default config instance containing all the default key-value pairs.
347
347
  @param addDotToFilename If True (default) then a . is added to the start of the filename. This hides the file in normal cases.
348
348
  @param encrypt If True then data will be encrypted in the saved files.
349
349
  The encryption uses part of the the local SSH RSA private key.
@@ -360,6 +360,10 @@ class ConfigManager(object):
360
360
  self._cfgPath = cfgPath
361
361
  self._configDict = {}
362
362
 
363
+ # If the user passed None in as the cfg filename then generate the default config file.
364
+ if self._cfgFilename is None:
365
+ self._cfgFilename = ConfigManager.GetDefaultConfigFilename()
366
+
363
367
  self._cfgFile = self._getConfigFile()
364
368
  self._modifiedTime = self._getModifiedTime()
365
369
 
@@ -735,3 +739,69 @@ class ConfigAttrDetails(object):
735
739
  self.minValue = minValue #Only used for numbers
736
740
  self.maxValue = maxValue #Only used for numbers
737
741
  self.allowEmpty = allowEmpty #Only used for strings
742
+
743
+ class DotConfigManager(ConfigManager):
744
+ """@brief This extends the previous ConfigManager and stores config under the ~/.config folder
745
+ rather than in the home folder (~) using a filename prefixed with the . character.
746
+ The ~/.config folder holds either a single config file of the startup python filename.
747
+ The ./config folder can contain another python module folder which contains the config
748
+ file. E.G for this example app the ~/.config/examples/pconfig_example.cfg folder is used."""
749
+
750
+ @staticmethod
751
+ def GetDefaultConfigFilename():
752
+ """@brief Get the default name of the config file for this app. This will be the program name
753
+ (file that started up initially) without the .py extension. On Linux systems this
754
+ will reside in the ~/.config folder. If the ~/.config does not exist an attempt to
755
+ create it is made. If the ~/.config folder cannot be created then the config file
756
+ will be as detailed above but will be prefixed by a . character and will reside
757
+ in the users home folder."""
758
+ progName = sys.argv[0]
759
+ if progName.endswith('.py'):
760
+ progName = progName[0:-3]
761
+
762
+ folder = '.config'
763
+ homePath = os.path.expanduser("~")
764
+ configFolder = os.path.join(homePath, folder)
765
+
766
+ if not os.path.isdir(homePath):
767
+ raise Exception(f"{homePath} HOME path does not exist.")
768
+
769
+ # Create the ~/.config folder if it does not exist
770
+ if not os.path.isdir(configFolder):
771
+ # Create the ~/.config folder
772
+ os.makedir(configFolder)
773
+
774
+ # Note that we assume that addDotToFilename in the ConfigManager constructor is set True
775
+ # as this will prefix the filename with the . character.
776
+ if os.path.isdir(configFolder):
777
+ extraFolders = os.path.dirname(progName)
778
+ configFolder = os.path.join(configFolder, extraFolders)
779
+ if not os.path.isdir(configFolder):
780
+ os.makedirs(configFolder)
781
+ if not os.path.isdir(configFolder):
782
+ raise Exception(f"Failed to create the {configFolder} folder.")
783
+
784
+ configFolder = "config"
785
+ configFolder = os.path.join(configFolder, extraFolders)
786
+ configFilename = os.path.join(configFolder, os.path.basename(progName) + '.cfg')
787
+
788
+ else:
789
+ configFilename = progName
790
+
791
+ return configFilename
792
+
793
+ def __init__(self, defaultConfig, uio=None, encrypt=False):
794
+ """@brief Constructor
795
+ @param defaultConfig A default config instance containing all the default key-value pairs.
796
+ @param uio A UIO (User Input Output) instance. May be set to None if no user messages are required.
797
+ @param encrypt If True then data will be encrypted in the saved files.
798
+ The encryption uses part of the the local SSH RSA private key.
799
+ This is not secure but assuming the private key has not been compromised it's
800
+ probably the best we can do.
801
+ !!! Therefore if encrypt is set True then the an ssh key must be present !!!
802
+ ||| in the ~/.ssh folder named id_rsa. !!!"""
803
+ super().__init__(uio, DotConfigManager.GetDefaultConfigFilename(), defaultConfig, encrypt=encrypt)
804
+ # Ensure the config file is present and loaded into the internal dict.
805
+ self.load()
806
+
807
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: p3lib
3
- Version: 1.1.82
3
+ Version: 1.1.84
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
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
File without changes
File without changes