p3lib 1.1.82__tar.gz → 1.1.83__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.83}/PKG-INFO +1 -1
  2. {p3lib-1.1.82 → p3lib-1.1.83}/setup.cfg +1 -1
  3. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib/pconfig.py +49 -2
  4. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib.egg-info/PKG-INFO +1 -1
  5. {p3lib-1.1.82 → p3lib-1.1.83}/LICENSE +0 -0
  6. {p3lib-1.1.82 → p3lib-1.1.83}/README.md +0 -0
  7. {p3lib-1.1.82 → p3lib-1.1.83}/pyproject.toml +0 -0
  8. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib/__init__.py +0 -0
  9. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib/ate.py +0 -0
  10. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib/bokeh_auth.py +0 -0
  11. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib/bokeh_gui.py +0 -0
  12. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib/boot_manager.py +0 -0
  13. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib/conduit.py +0 -0
  14. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib/database_if.py +0 -0
  15. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib/helper.py +0 -0
  16. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib/json_networking.py +0 -0
  17. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib/mqtt_rpc.py +0 -0
  18. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib/netif.py +0 -0
  19. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib/netplotly.py +0 -0
  20. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib/ngt.py +0 -0
  21. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib/ssh.py +0 -0
  22. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib/table_plot.py +0 -0
  23. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib/uio.py +0 -0
  24. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib.egg-info/SOURCES.txt +0 -0
  25. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib.egg-info/dependency_links.txt +0 -0
  26. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib.egg-info/requires.txt +0 -0
  27. {p3lib-1.1.82 → p3lib-1.1.83}/src/p3lib.egg-info/top_level.txt +0 -0
  28. {p3lib-1.1.82 → p3lib-1.1.83}/tests/test_conduit.py +0 -0
  29. {p3lib-1.1.82 → p3lib-1.1.83}/tests/test_json_networking.py +0 -0
  30. {p3lib-1.1.82 → p3lib-1.1.83}/tests/test_netif.py +0 -0
  31. {p3lib-1.1.82 → p3lib-1.1.83}/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.83
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.83
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,11 +339,54 @@ class ConfigManager(object):
339
339
 
340
340
  return join( configPath, cfgFilename )
341
341
 
342
+ @staticmethod
343
+ def GetDefaultConfigFilename():
344
+ """@brief Get the default name of the config file for this app. This will be the program name
345
+ (file that started up initially) without the .py extension. On Linux systems this
346
+ will reside in the ~/.config folder. If the ~/.config does not exist an attempt to
347
+ create it is made. If the ~/.config folder cannot be created then the config file
348
+ will be as detailed above but will be prefixed by a . character and will reside
349
+ in the users home folder."""
350
+ progName = sys.argv[0]
351
+ if progName.endswith('.py'):
352
+ progName = progName[0:-3]
353
+
354
+ folder = '.config'
355
+ homePath = os.path.expanduser("~")
356
+ configFolder = os.path.join(homePath, folder)
357
+
358
+ if not os.path.isdir(homePath):
359
+ raise Exception(f"{homePath} HOME path does not exist.")
360
+
361
+ # Create the ~/.config folder if it does not exist
362
+ if not os.path.isdir(configFolder):
363
+ # Create the ~/.config folder
364
+ os.makedir(configFolder)
365
+
366
+ # Note that we assume that addDotToFilename in the ConfigManager constructor is set True
367
+ # as this will prefix the filename with the . character.
368
+ if os.path.isdir(configFolder):
369
+ extraFolders = os.path.dirname(progName)
370
+ configFolder = os.path.join(configFolder, extraFolders)
371
+ if not os.path.isdir(configFolder):
372
+ os.makedirs(configFolder)
373
+ if not os.path.isdir(configFolder):
374
+ raise Exception(f"Failed to create the {configFolder} folder.")
375
+
376
+ configFolder = "config"
377
+ configFolder = os.path.join(configFolder, extraFolders)
378
+ configFilename = os.path.join(configFolder, os.path.basename(progName) + '.cfg')
379
+
380
+ else:
381
+ configFilename = progName
382
+
383
+ return configFilename
384
+
342
385
  def __init__(self, uio, cfgFilename, defaultConfig, addDotToFilename=True, encrypt=False, cfgPath=None):
343
386
  """@brief Constructor
344
387
  @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.
388
+ @param cfgFilename The name of the config file. If this is None then the default config filename is used.
389
+ @param defaultConfig A default config instance containing all the default key-value pairs.
347
390
  @param addDotToFilename If True (default) then a . is added to the start of the filename. This hides the file in normal cases.
348
391
  @param encrypt If True then data will be encrypted in the saved files.
349
392
  The encryption uses part of the the local SSH RSA private key.
@@ -360,6 +403,10 @@ class ConfigManager(object):
360
403
  self._cfgPath = cfgPath
361
404
  self._configDict = {}
362
405
 
406
+ # If the user passed None in as the cfg filename then generate the default config file.
407
+ if self._cfgFilename is None:
408
+ self._cfgFilename = ConfigManager.GetDefaultConfigFilename()
409
+
363
410
  self._cfgFile = self._getConfigFile()
364
411
  self._modifiedTime = self._getModifiedTime()
365
412
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: p3lib
3
- Version: 1.1.82
3
+ Version: 1.1.83
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