p3lib 1.1.83__tar.gz → 1.1.85__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.
- {p3lib-1.1.83 → p3lib-1.1.85}/PKG-INFO +1 -1
- {p3lib-1.1.83 → p3lib-1.1.85}/setup.cfg +1 -1
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib/pconfig.py +83 -51
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib.egg-info/PKG-INFO +1 -1
- {p3lib-1.1.83 → p3lib-1.1.85}/LICENSE +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/README.md +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/pyproject.toml +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib/__init__.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib/ate.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib/bokeh_auth.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib/bokeh_gui.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib/boot_manager.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib/conduit.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib/database_if.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib/helper.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib/json_networking.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib/mqtt_rpc.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib/netif.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib/netplotly.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib/ngt.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib/ssh.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib/table_plot.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib/uio.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib.egg-info/SOURCES.txt +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib.egg-info/dependency_links.txt +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib.egg-info/requires.txt +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/src/p3lib.egg-info/top_level.txt +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/tests/test_conduit.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/tests/test_json_networking.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/tests/test_netif.py +0 -0
- {p3lib-1.1.83 → p3lib-1.1.85}/tests/test_ssh.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: p3lib
|
3
|
-
Version: 1.1.
|
3
|
+
Version: 1.1.85
|
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.
|
3
|
+
version = 1.1.85
|
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,49 +338,6 @@ class ConfigManager(object):
|
|
338
338
|
configPath = configPath.strip()
|
339
339
|
|
340
340
|
return join( configPath, cfgFilename )
|
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
341
|
|
385
342
|
def __init__(self, uio, cfgFilename, defaultConfig, addDotToFilename=True, encrypt=False, cfgPath=None):
|
386
343
|
"""@brief Constructor
|
@@ -518,16 +475,25 @@ class ConfigManager(object):
|
|
518
475
|
loadedConfig = self._getDict()
|
519
476
|
#Get list of all the keys from the config file loaded.
|
520
477
|
loadedConfigKeys = loadedConfig.keys()
|
478
|
+
|
521
479
|
#Get the default config
|
522
480
|
self._configDict = copy.deepcopy( self._defaultConfig )
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
481
|
+
defaultConfigKeys = self._configDict.keys()
|
482
|
+
|
483
|
+
# Config parameters may be added or dropped over time. We use the default config to
|
484
|
+
# check for parameters that should be added/removed.
|
485
|
+
|
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
|
+
self._configDict[defaultKey] = self._defaultConfig[defaultKey]
|
490
|
+
self._debug("----------> DEFAULT VALUE ADDED: {} = {}".format(defaultKey, self._configDict[defaultKey]))
|
491
|
+
|
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, self._configDict[loadedConfigKey]))
|
496
|
+
self._configDict.pop(loadedConfigKey, None)
|
531
497
|
|
532
498
|
self._info("Loaded config from %s" % (self._cfgFile) )
|
533
499
|
|
@@ -782,3 +748,69 @@ class ConfigAttrDetails(object):
|
|
782
748
|
self.minValue = minValue #Only used for numbers
|
783
749
|
self.maxValue = maxValue #Only used for numbers
|
784
750
|
self.allowEmpty = allowEmpty #Only used for strings
|
751
|
+
|
752
|
+
class DotConfigManager(ConfigManager):
|
753
|
+
"""@brief This extends the previous ConfigManager and stores config under the ~/.config folder
|
754
|
+
rather than in the home folder (~) using a filename prefixed with the . character.
|
755
|
+
The ~/.config folder holds either a single config file of the startup python filename.
|
756
|
+
The ./config folder can contain another python module folder which contains the config
|
757
|
+
file. E.G for this example app the ~/.config/examples/pconfig_example.cfg folder is used."""
|
758
|
+
|
759
|
+
@staticmethod
|
760
|
+
def GetDefaultConfigFilename():
|
761
|
+
"""@brief Get the default name of the config file for this app. This will be the program name
|
762
|
+
(file that started up initially) without the .py extension. On Linux systems this
|
763
|
+
will reside in the ~/.config folder. If the ~/.config does not exist an attempt to
|
764
|
+
create it is made. If the ~/.config folder cannot be created then the config file
|
765
|
+
will be as detailed above but will be prefixed by a . character and will reside
|
766
|
+
in the users home folder."""
|
767
|
+
progName = sys.argv[0]
|
768
|
+
if progName.endswith('.py'):
|
769
|
+
progName = progName[0:-3]
|
770
|
+
|
771
|
+
folder = '.config'
|
772
|
+
homePath = os.path.expanduser("~")
|
773
|
+
configFolder = os.path.join(homePath, folder)
|
774
|
+
|
775
|
+
if not os.path.isdir(homePath):
|
776
|
+
raise Exception(f"{homePath} HOME path does not exist.")
|
777
|
+
|
778
|
+
# Create the ~/.config folder if it does not exist
|
779
|
+
if not os.path.isdir(configFolder):
|
780
|
+
# Create the ~/.config folder
|
781
|
+
os.makedir(configFolder)
|
782
|
+
|
783
|
+
# Note that we assume that addDotToFilename in the ConfigManager constructor is set True
|
784
|
+
# as this will prefix the filename with the . character.
|
785
|
+
if os.path.isdir(configFolder):
|
786
|
+
extraFolders = os.path.dirname(progName)
|
787
|
+
configFolder = os.path.join(configFolder, extraFolders)
|
788
|
+
if not os.path.isdir(configFolder):
|
789
|
+
os.makedirs(configFolder)
|
790
|
+
if not os.path.isdir(configFolder):
|
791
|
+
raise Exception(f"Failed to create the {configFolder} folder.")
|
792
|
+
|
793
|
+
configFolder = "config"
|
794
|
+
configFolder = os.path.join(configFolder, extraFolders)
|
795
|
+
configFilename = os.path.join(configFolder, os.path.basename(progName) + '.cfg')
|
796
|
+
|
797
|
+
else:
|
798
|
+
configFilename = progName
|
799
|
+
|
800
|
+
return configFilename
|
801
|
+
|
802
|
+
def __init__(self, defaultConfig, uio=None, encrypt=False):
|
803
|
+
"""@brief Constructor
|
804
|
+
@param defaultConfig A default config instance containing all the default key-value pairs.
|
805
|
+
@param uio A UIO (User Input Output) instance. May be set to None if no user messages are required.
|
806
|
+
@param encrypt If True then data will be encrypted in the saved files.
|
807
|
+
The encryption uses part of the the local SSH RSA private key.
|
808
|
+
This is not secure but assuming the private key has not been compromised it's
|
809
|
+
probably the best we can do.
|
810
|
+
!!! Therefore if encrypt is set True then the an ssh key must be present !!!
|
811
|
+
||| in the ~/.ssh folder named id_rsa. !!!"""
|
812
|
+
super().__init__(uio, DotConfigManager.GetDefaultConfigFilename(), defaultConfig, encrypt=encrypt)
|
813
|
+
# Ensure the config file is present and loaded into the internal dict.
|
814
|
+
self.load()
|
815
|
+
|
816
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: p3lib
|
3
|
-
Version: 1.1.
|
3
|
+
Version: 1.1.85
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|