p3lib 1.1.106__tar.gz → 1.1.108__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.108/PKG-INFO +34 -0
- p3lib-1.1.108/pyproject.toml +16 -0
- p3lib-1.1.108/src/p3lib/login.html +98 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/pconfig.py +62 -26
- p3lib-1.1.106/PKG-INFO +0 -26
- p3lib-1.1.106/pyproject.toml +0 -6
- p3lib-1.1.106/setup.cfg +0 -32
- p3lib-1.1.106/src/p3lib.egg-info/PKG-INFO +0 -26
- p3lib-1.1.106/src/p3lib.egg-info/SOURCES.txt +0 -32
- p3lib-1.1.106/src/p3lib.egg-info/dependency_links.txt +0 -1
- p3lib-1.1.106/src/p3lib.egg-info/requires.txt +0 -2
- p3lib-1.1.106/src/p3lib.egg-info/top_level.txt +0 -1
- p3lib-1.1.106/tests/test_conduit.py +0 -41
- p3lib-1.1.106/tests/test_json_networking.py +0 -100
- p3lib-1.1.106/tests/test_netif.py +0 -79
- p3lib-1.1.106/tests/test_ssh.py +0 -73
- {p3lib-1.1.106 → p3lib-1.1.108}/LICENSE +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/README.md +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/__init__.py +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/ate.py +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/bokeh_auth.py +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/bokeh_gui.py +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/boot_manager.py +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/conduit.py +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/database_if.py +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/file_io.py +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/gnome_desktop_app.py +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/helper.py +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/json_networking.py +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/mqtt_rpc.py +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/netif.py +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/netplotly.py +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/ngt.py +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/ssh.py +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/table_plot.py +0 -0
- {p3lib-1.1.106 → p3lib-1.1.108}/src/p3lib/uio.py +0 -0
p3lib-1.1.108/PKG-INFO
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: p3lib
|
3
|
+
Version: 1.1.108
|
4
|
+
Summary: A group of python modules for networking, plotting data, config storage, automating boot scripts, ssh access and user input output.
|
5
|
+
Home-page: https://github.com/pjaos/test_equipment
|
6
|
+
License: MIT
|
7
|
+
Author: Paul Austen
|
8
|
+
Author-email: pjaos@gmail.com
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
10
|
+
Classifier: Programming Language :: Python :: 2
|
11
|
+
Classifier: Programming Language :: Python :: 2.7
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
13
|
+
Classifier: Programming Language :: Python :: 3.4
|
14
|
+
Classifier: Programming Language :: Python :: 3.5
|
15
|
+
Classifier: Programming Language :: Python :: 3.6
|
16
|
+
Classifier: Programming Language :: Python :: 3.7
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
22
|
+
Project-URL: Repository, https://github.com/pjaos/test_equipment
|
23
|
+
Description-Content-Type: text/markdown
|
24
|
+
|
25
|
+
# A Python3 library
|
26
|
+
A group of python modules for networking, plotting data, config storage, automating boot scripts, ssh access and user input output.
|
27
|
+
|
28
|
+
## Installation
|
29
|
+
p3lib is available on pypi and can be installed using the following command.
|
30
|
+
|
31
|
+
```
|
32
|
+
pip3 install p3lib
|
33
|
+
```
|
34
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
[tool.poetry]
|
2
|
+
name = "p3lib"
|
3
|
+
version = "1.1.108"
|
4
|
+
description = "A group of python modules for networking, plotting data, config storage, automating boot scripts, ssh access and user input output."
|
5
|
+
authors = ["Paul Austen <pjaos@gmail.com>"]
|
6
|
+
license = "MIT License"
|
7
|
+
readme = "README.md"
|
8
|
+
homepage = "https://github.com/pjaos/test_equipment"
|
9
|
+
repository = "https://github.com/pjaos/test_equipment"
|
10
|
+
|
11
|
+
[build-system]
|
12
|
+
requires = [
|
13
|
+
"setuptools>=42",
|
14
|
+
"wheel"
|
15
|
+
]
|
16
|
+
build-backend = "setuptools.build_meta"
|
@@ -0,0 +1,98 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Bokeh App with Login</title>
|
5
|
+
<style>
|
6
|
+
*{
|
7
|
+
margin:0;
|
8
|
+
padding: 0;
|
9
|
+
box-sizing: border-box;
|
10
|
+
}
|
11
|
+
html{
|
12
|
+
height: 100%;
|
13
|
+
}
|
14
|
+
body{
|
15
|
+
font-family: 'Segoe UI', sans-serif;;
|
16
|
+
font-size: 1rem;
|
17
|
+
line-height: 1.6;
|
18
|
+
height: 100%;
|
19
|
+
}
|
20
|
+
p{
|
21
|
+
padding-bottom: 5px;
|
22
|
+
}
|
23
|
+
.wrap {
|
24
|
+
width: 100%;
|
25
|
+
height: 100%;
|
26
|
+
display: flex;
|
27
|
+
justify-content: center;
|
28
|
+
align-items: center;
|
29
|
+
background: #fafafa;
|
30
|
+
}
|
31
|
+
.login-form{
|
32
|
+
width: 350px;
|
33
|
+
margin: 0 auto;
|
34
|
+
border: 1px solid #ddd;
|
35
|
+
padding: 2rem;
|
36
|
+
background: #ffffff;
|
37
|
+
}
|
38
|
+
.form-input{
|
39
|
+
background: #fafafa;
|
40
|
+
border: 1px solid #eeeeee;
|
41
|
+
padding: 12px;
|
42
|
+
width: 100%;
|
43
|
+
}
|
44
|
+
.form-group{
|
45
|
+
margin-bottom: 1rem;
|
46
|
+
}
|
47
|
+
.form-button{
|
48
|
+
background: #69d2e7;
|
49
|
+
border: 1px solid #ddd;
|
50
|
+
color: #ffffff;
|
51
|
+
padding: 10px;
|
52
|
+
width: 100%;
|
53
|
+
text-transform: uppercase;
|
54
|
+
}
|
55
|
+
.form-button:hover{
|
56
|
+
background: #69c8e7;
|
57
|
+
}
|
58
|
+
.form-header{
|
59
|
+
text-align: center;
|
60
|
+
margin-bottom : 2rem;
|
61
|
+
}
|
62
|
+
.form-footer{
|
63
|
+
text-align: center;
|
64
|
+
}
|
65
|
+
</style>
|
66
|
+
</head>
|
67
|
+
<body>
|
68
|
+
<div class="wrap">
|
69
|
+
<form class="login-form" action="/login" method="post">
|
70
|
+
{% module xsrf_form_html() %}
|
71
|
+
<div class="form-header">
|
72
|
+
<h3><img src="https://static.bokeh.org/logos/logotype.svg"></h3>
|
73
|
+
<p> Login to access your application</p>
|
74
|
+
</div>
|
75
|
+
<!--Email Input-->
|
76
|
+
<div class="form-group">
|
77
|
+
<input name="username" type="text" class="form-input" autocapitalize="off" autocorrect="off" placeholder="username">
|
78
|
+
</div>
|
79
|
+
<!--Password Input-->
|
80
|
+
<div class="form-group">
|
81
|
+
<input name="password" type="password" class="form-input" placeholder="password">
|
82
|
+
</div>
|
83
|
+
<!--Login Button-->
|
84
|
+
<div class="form-group">
|
85
|
+
<button class="form-button" type="submit">Login</button>
|
86
|
+
</div>
|
87
|
+
<span class="errormessage">{{errormessage}}</span>
|
88
|
+
<div><small>
|
89
|
+
<p>This is a <b>toy example</b> that demonstrates the authentication building blocks that are available with a Bokeh server.</p>
|
90
|
+
|
91
|
+
<p>You can log in with user: <b><i>bokeh</i></b> / pass: <b><i>bokeh</i></b></p>
|
92
|
+
|
93
|
+
<p><a href="https://docs.bokeh.org/en/latest/docs/user_guide/server/deploy.html#authentication">See the documentation</a> for a full discussion.</p>
|
94
|
+
</small></div>
|
95
|
+
</form>
|
96
|
+
</div>
|
97
|
+
</body>
|
98
|
+
</html>
|
@@ -339,7 +339,15 @@ class ConfigManager(object):
|
|
339
339
|
|
340
340
|
return join( configPath, cfgFilename )
|
341
341
|
|
342
|
-
def __init__(self,
|
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
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
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
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
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) )
|
@@ -704,16 +719,16 @@ class ConfigManager(object):
|
|
704
719
|
self._info("{} has been removed.".format(configFile))
|
705
720
|
self._info("The default configuration will be loaded next time..")
|
706
721
|
|
707
|
-
def configure(self, editConfigMethod):
|
722
|
+
def configure(self, editConfigMethod, prompt="Enter 'E' to edit a parameter, or 'Q' to quit", editCharacters = 'E', quitCharacters= 'Q'):
|
708
723
|
"""@brief A helper method to edit the dictionary config.
|
709
724
|
@param editConfigMethod The method to call to edit configuration.
|
710
725
|
@return None"""
|
711
726
|
running=True
|
712
727
|
while running:
|
713
728
|
idKeyDict=self.show()
|
714
|
-
response = self._uio.getInput(
|
729
|
+
response = self._uio.getInput(prompt)
|
715
730
|
response=response.upper()
|
716
|
-
if response
|
731
|
+
if response in editCharacters:
|
717
732
|
id = self._uio.getIntInput("Enter the ID of the parameter to change")
|
718
733
|
if id not in idKeyDict:
|
719
734
|
self._uio.error("Configuration ID {} is invalid.".format(id))
|
@@ -722,7 +737,7 @@ class ConfigManager(object):
|
|
722
737
|
editConfigMethod(key)
|
723
738
|
self.store()
|
724
739
|
|
725
|
-
elif response
|
740
|
+
elif response in quitCharacters:
|
726
741
|
running = False
|
727
742
|
|
728
743
|
def show(self):
|
@@ -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
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
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,
|
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
|
-
|
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()
|
p3lib-1.1.106/PKG-INFO
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.2
|
2
|
-
Name: p3lib
|
3
|
-
Version: 1.1.106
|
4
|
-
Summary: A group of python modules for networking, plotting data, config storage, automating boot scripts, ssh access and user input output.
|
5
|
-
Home-page: https://github.com/pjaos/p3lib
|
6
|
-
Author: Paul Austen
|
7
|
-
Author-email: pausten.os@gmail.com
|
8
|
-
Project-URL: Bug Tracker, https://github.com/pjaos/p3lib/issues
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
11
|
-
Classifier: Operating System :: OS Independent
|
12
|
-
Requires-Python: >=3.8
|
13
|
-
Description-Content-Type: text/markdown
|
14
|
-
License-File: LICENSE
|
15
|
-
Requires-Dist: paramiko>=2.9.3
|
16
|
-
Requires-Dist: pillow>=9.2.0
|
17
|
-
|
18
|
-
# A Python3 library
|
19
|
-
A group of python modules for networking, plotting data, config storage, automating boot scripts, ssh access and user input output.
|
20
|
-
|
21
|
-
## Installation
|
22
|
-
p3lib is available on pypi and can be installed using the following command.
|
23
|
-
|
24
|
-
```
|
25
|
-
pip3 install p3lib
|
26
|
-
```
|
p3lib-1.1.106/pyproject.toml
DELETED
p3lib-1.1.106/setup.cfg
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
[metadata]
|
2
|
-
name = p3lib
|
3
|
-
version = 1.1.106
|
4
|
-
author = Paul Austen
|
5
|
-
author_email = pausten.os@gmail.com
|
6
|
-
description = A group of python modules for networking, plotting data, config storage, automating boot scripts, ssh access and user input output.
|
7
|
-
long_description = file: README.md
|
8
|
-
long_description_content_type = text/markdown
|
9
|
-
url = https://github.com/pjaos/p3lib
|
10
|
-
project_urls =
|
11
|
-
Bug Tracker = https://github.com/pjaos/p3lib/issues
|
12
|
-
classifiers =
|
13
|
-
Programming Language :: Python :: 3
|
14
|
-
License :: OSI Approved :: MIT License
|
15
|
-
Operating System :: OS Independent
|
16
|
-
|
17
|
-
[options]
|
18
|
-
package_dir =
|
19
|
-
= src
|
20
|
-
packages = find:
|
21
|
-
python_requires = >=3.8
|
22
|
-
install_requires =
|
23
|
-
paramiko>=2.9.3
|
24
|
-
pillow>=9.2.0
|
25
|
-
|
26
|
-
[options.packages.find]
|
27
|
-
where = src
|
28
|
-
|
29
|
-
[egg_info]
|
30
|
-
tag_build =
|
31
|
-
tag_date = 0
|
32
|
-
|
@@ -1,26 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.2
|
2
|
-
Name: p3lib
|
3
|
-
Version: 1.1.106
|
4
|
-
Summary: A group of python modules for networking, plotting data, config storage, automating boot scripts, ssh access and user input output.
|
5
|
-
Home-page: https://github.com/pjaos/p3lib
|
6
|
-
Author: Paul Austen
|
7
|
-
Author-email: pausten.os@gmail.com
|
8
|
-
Project-URL: Bug Tracker, https://github.com/pjaos/p3lib/issues
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
11
|
-
Classifier: Operating System :: OS Independent
|
12
|
-
Requires-Python: >=3.8
|
13
|
-
Description-Content-Type: text/markdown
|
14
|
-
License-File: LICENSE
|
15
|
-
Requires-Dist: paramiko>=2.9.3
|
16
|
-
Requires-Dist: pillow>=9.2.0
|
17
|
-
|
18
|
-
# A Python3 library
|
19
|
-
A group of python modules for networking, plotting data, config storage, automating boot scripts, ssh access and user input output.
|
20
|
-
|
21
|
-
## Installation
|
22
|
-
p3lib is available on pypi and can be installed using the following command.
|
23
|
-
|
24
|
-
```
|
25
|
-
pip3 install p3lib
|
26
|
-
```
|
@@ -1,32 +0,0 @@
|
|
1
|
-
LICENSE
|
2
|
-
README.md
|
3
|
-
pyproject.toml
|
4
|
-
setup.cfg
|
5
|
-
src/p3lib/__init__.py
|
6
|
-
src/p3lib/ate.py
|
7
|
-
src/p3lib/bokeh_auth.py
|
8
|
-
src/p3lib/bokeh_gui.py
|
9
|
-
src/p3lib/boot_manager.py
|
10
|
-
src/p3lib/conduit.py
|
11
|
-
src/p3lib/database_if.py
|
12
|
-
src/p3lib/file_io.py
|
13
|
-
src/p3lib/gnome_desktop_app.py
|
14
|
-
src/p3lib/helper.py
|
15
|
-
src/p3lib/json_networking.py
|
16
|
-
src/p3lib/mqtt_rpc.py
|
17
|
-
src/p3lib/netif.py
|
18
|
-
src/p3lib/netplotly.py
|
19
|
-
src/p3lib/ngt.py
|
20
|
-
src/p3lib/pconfig.py
|
21
|
-
src/p3lib/ssh.py
|
22
|
-
src/p3lib/table_plot.py
|
23
|
-
src/p3lib/uio.py
|
24
|
-
src/p3lib.egg-info/PKG-INFO
|
25
|
-
src/p3lib.egg-info/SOURCES.txt
|
26
|
-
src/p3lib.egg-info/dependency_links.txt
|
27
|
-
src/p3lib.egg-info/requires.txt
|
28
|
-
src/p3lib.egg-info/top_level.txt
|
29
|
-
tests/test_conduit.py
|
30
|
-
tests/test_json_networking.py
|
31
|
-
tests/test_netif.py
|
32
|
-
tests/test_ssh.py
|
@@ -1 +0,0 @@
|
|
1
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
p3lib
|
@@ -1,41 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python3
|
2
|
-
|
3
|
-
import unittest
|
4
|
-
|
5
|
-
import sys
|
6
|
-
from p3lib.conduit import Conduit
|
7
|
-
|
8
|
-
class ConduitTester(unittest.TestCase):
|
9
|
-
"""@brief Test cases for the Conduit class"""
|
10
|
-
|
11
|
-
def setUp(self):
|
12
|
-
self.conduit = Conduit()
|
13
|
-
|
14
|
-
def tearDown(self):
|
15
|
-
pass
|
16
|
-
|
17
|
-
def test1_AToB(self):
|
18
|
-
msg = "test1_AToB_Message"
|
19
|
-
self.conduit.putA(msg)
|
20
|
-
|
21
|
-
self.assertTrue( self.conduit.bReadAvailable() )
|
22
|
-
|
23
|
-
rxMsg = self.conduit.getB()
|
24
|
-
self.assertTrue( msg == rxMsg)
|
25
|
-
|
26
|
-
def test1_BToA(self):
|
27
|
-
msg = "test1_BToA_Message"
|
28
|
-
self.conduit.putB(msg)
|
29
|
-
|
30
|
-
self.assertTrue( self.conduit.aReadAvailable() )
|
31
|
-
|
32
|
-
rxMsg = self.conduit.getA()
|
33
|
-
self.assertTrue( msg == rxMsg)
|
34
|
-
|
35
|
-
def main():
|
36
|
-
"""@brief Unit tests for the UIO class"""
|
37
|
-
suite = unittest.TestLoader().loadTestsFromTestCase(ConduitTester)
|
38
|
-
unittest.TextTestRunner(verbosity=2).run(suite)
|
39
|
-
|
40
|
-
if __name__ == '__main__':
|
41
|
-
main()
|
@@ -1,100 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python3
|
2
|
-
|
3
|
-
from time import sleep
|
4
|
-
from p3lib.json_networking import JSONServer, JsonServerHandler, JSONClient
|
5
|
-
import threading
|
6
|
-
|
7
|
-
class ServerSessionHandler(JsonServerHandler):
|
8
|
-
#handler that sends data back to src
|
9
|
-
def handle(self):
|
10
|
-
try:
|
11
|
-
while True:
|
12
|
-
rxDict = self.rx()
|
13
|
-
self.tx(self.request, rxDict)
|
14
|
-
|
15
|
-
except:
|
16
|
-
pass
|
17
|
-
|
18
|
-
class TestClass:
|
19
|
-
"""@brief Test the json_networking class byt setting up a server sending data to is and checking the data we get back
|
20
|
-
what we sent."""
|
21
|
-
HOST = "localhost"
|
22
|
-
PORT = 9999
|
23
|
-
APASSWORD = "300fkslaa"
|
24
|
-
MIN_ID = 0
|
25
|
-
MAX_ID = 100
|
26
|
-
ID_STR = "ID"
|
27
|
-
|
28
|
-
@classmethod
|
29
|
-
def setup_class(cls):
|
30
|
-
server = JSONServer((TestClass.HOST, TestClass.PORT), ServerSessionHandler)
|
31
|
-
serverThread = threading.Thread(target=server.serve_forever)
|
32
|
-
serverThread.daemon = True
|
33
|
-
serverThread.start()
|
34
|
-
|
35
|
-
def test_connect(self):
|
36
|
-
client = JSONClient(TestClass.HOST, TestClass.PORT)
|
37
|
-
|
38
|
-
def test_tx(self):
|
39
|
-
client = JSONClient(TestClass.HOST, TestClass.PORT)
|
40
|
-
txDict = {"password": "apassword"}
|
41
|
-
client.tx(txDict)
|
42
|
-
|
43
|
-
def test_rx(self):
|
44
|
-
client = JSONClient(TestClass.HOST, TestClass.PORT)
|
45
|
-
|
46
|
-
txDict = {"password": TestClass.APASSWORD}
|
47
|
-
client.tx(txDict)
|
48
|
-
|
49
|
-
rxDict = client.rx()
|
50
|
-
assert( "password" in rxDict)
|
51
|
-
value = rxDict["password"]
|
52
|
-
assert( value == TestClass.APASSWORD )
|
53
|
-
|
54
|
-
def txThread(self, client):
|
55
|
-
for id in range(TestClass.MIN_ID, TestClass.MAX_ID):
|
56
|
-
txDict = {TestClass.ID_STR: id}
|
57
|
-
client.tx(txDict)
|
58
|
-
|
59
|
-
def test_tx_multiple(self):
|
60
|
-
client = JSONClient(TestClass.HOST, TestClass.PORT)
|
61
|
-
txThread = threading.Thread(target=self.txThread, args=(client,) )
|
62
|
-
txThread.start()
|
63
|
-
for id in range(TestClass.MIN_ID, TestClass.MAX_ID):
|
64
|
-
txDict = {TestClass.ID_STR: id}
|
65
|
-
client.tx(txDict)
|
66
|
-
|
67
|
-
def test_rx_multiple(self):
|
68
|
-
client = JSONClient(TestClass.HOST, TestClass.PORT)
|
69
|
-
txThread = threading.Thread(target=self.txThread, args=(client,) )
|
70
|
-
txThread.start()
|
71
|
-
|
72
|
-
expectedID=TestClass.MIN_ID
|
73
|
-
while True:
|
74
|
-
rxDict = client.rx()
|
75
|
-
assert(TestClass.ID_STR in rxDict)
|
76
|
-
id = rxDict[TestClass.ID_STR]
|
77
|
-
assert( id == expectedID )
|
78
|
-
expectedID=expectedID+1
|
79
|
-
if expectedID == TestClass.MAX_ID:
|
80
|
-
break
|
81
|
-
|
82
|
-
client.close()
|
83
|
-
|
84
|
-
def test_rx_multiple_non_blocking(self):
|
85
|
-
client = JSONClient(TestClass.HOST, TestClass.PORT)
|
86
|
-
txThread = threading.Thread(target=self.txThread, args=(client,))
|
87
|
-
txThread.start()
|
88
|
-
|
89
|
-
expectedID = TestClass.MIN_ID
|
90
|
-
while True:
|
91
|
-
rxDict = client.rx(blocking=False)
|
92
|
-
if rxDict:
|
93
|
-
assert (TestClass.ID_STR in rxDict)
|
94
|
-
id = rxDict[TestClass.ID_STR]
|
95
|
-
assert (id == expectedID)
|
96
|
-
expectedID = expectedID + 1
|
97
|
-
if expectedID == TestClass.MAX_ID:
|
98
|
-
break
|
99
|
-
|
100
|
-
client.close()
|
@@ -1,79 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python3
|
2
|
-
|
3
|
-
from time import sleep
|
4
|
-
from p3lib.netif import NetIF
|
5
|
-
|
6
|
-
#These must be changed to use an interface on the local machine.
|
7
|
-
NET_IF = "enx0c37960803fc"
|
8
|
-
IP_ADDRESS = "192.168.0.10"
|
9
|
-
NETMASK = "255.255.255.0"
|
10
|
-
|
11
|
-
class TestClass:
|
12
|
-
"""@brief Test the NEtIF class."""
|
13
|
-
|
14
|
-
def test_ip_in_network(self):
|
15
|
-
assert( NetIF.IsAddressInNetwork("192.168.1.123", "192.168.1.0/24") )
|
16
|
-
|
17
|
-
def test_ip_not_in_network(self):
|
18
|
-
assert( not NetIF.IsAddressInNetwork("192.168.1.123", "192.168.2.0/24") )
|
19
|
-
|
20
|
-
def test_IPStr2int_0(self):
|
21
|
-
intValue = NetIF.IPStr2int("0.0.0.0")
|
22
|
-
assert( intValue == 0 )
|
23
|
-
|
24
|
-
def test_IPStr2int_f(self):
|
25
|
-
intValue = NetIF.IPStr2int("255.255.255.255")
|
26
|
-
assert( intValue == 0xffffffff )
|
27
|
-
|
28
|
-
def test_IPStr2int_v(self):
|
29
|
-
intValue = NetIF.IPStr2int("192.168.1.1")
|
30
|
-
assert( intValue == 0xc0a80101 )
|
31
|
-
|
32
|
-
def test_Int2IPStr_0(self):
|
33
|
-
strValue = NetIF.Int2IPStr(0)
|
34
|
-
assert( strValue == "0.0.0.0" )
|
35
|
-
|
36
|
-
def test_Int2IPStr_f(self):
|
37
|
-
strValue = NetIF.Int2IPStr(0xffffffff)
|
38
|
-
assert( strValue == "255.255.255.255" )
|
39
|
-
|
40
|
-
def test_Int2IPStr_v(self):
|
41
|
-
strValue = NetIF.Int2IPStr(0xc0a80101)
|
42
|
-
assert( strValue == "192.168.1.1" )
|
43
|
-
|
44
|
-
def test_NetmaskToBitCount(self):
|
45
|
-
assert( NetIF.NetmaskToBitCount("255.255.255.0") == 24 )
|
46
|
-
|
47
|
-
def test_getIFDict(self):
|
48
|
-
netif = NetIF()
|
49
|
-
ifDict = netif.getIFDict()
|
50
|
-
|
51
|
-
def test_checkSupportedOS(self):
|
52
|
-
netif = NetIF()
|
53
|
-
netif._checkSupportedOS()
|
54
|
-
|
55
|
-
def test_getIFName(self):
|
56
|
-
netif = NetIF()
|
57
|
-
#This requires the machine has an interface on the IP_ADDRESS/24 network
|
58
|
-
ifName = netif.getIFName(IP_ADDRESS)
|
59
|
-
assert( ifName == NET_IF)
|
60
|
-
|
61
|
-
ifName = netif.getIFName("1.1.1.1")
|
62
|
-
assert( ifName == None )
|
63
|
-
|
64
|
-
def test_getIFNetmask(self):
|
65
|
-
netif = NetIF()
|
66
|
-
#This requires the machine has an interface named MACHINE_NET_IF
|
67
|
-
nm = netif.getIFNetmask(NET_IF)
|
68
|
-
assert( nm == NETMASK )
|
69
|
-
|
70
|
-
def test_getIFIPAddress(self):
|
71
|
-
netif = NetIF()
|
72
|
-
ipAddr = netif.getIFIPAddress(NET_IF)
|
73
|
-
assert( ipAddr == IP_ADDRESS )
|
74
|
-
|
75
|
-
def test_getLocalNetworkAddress(self):
|
76
|
-
netif = NetIF()
|
77
|
-
ipAddr = netif.getLocalNetworkAddress()
|
78
|
-
assert( ipAddr == IP_ADDRESS )
|
79
|
-
|
p3lib-1.1.106/tests/test_ssh.py
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python3
|
2
|
-
|
3
|
-
import unittest
|
4
|
-
from time import sleep
|
5
|
-
|
6
|
-
# Supress the following warning
|
7
|
-
# CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0.
|
8
|
-
import warnings
|
9
|
-
from cryptography.utils import CryptographyDeprecationWarning
|
10
|
-
with warnings.catch_warnings(action="ignore", category=CryptographyDeprecationWarning):
|
11
|
-
import paramiko
|
12
|
-
|
13
|
-
from p3lib.uio import UIO
|
14
|
-
from p3lib.ssh import SSH, SSHTunnelManager
|
15
|
-
|
16
|
-
#An ssh login on an ssh server must be available for these test to run.
|
17
|
-
USERNAME="pja"
|
18
|
-
SERVER="localhost"
|
19
|
-
|
20
|
-
class SSHTester(unittest.TestCase):
|
21
|
-
"""@brief Unit tests for the UIO class"""
|
22
|
-
|
23
|
-
def setUp(self):
|
24
|
-
"""@brief To test correctly the ssh key should be removed from the server
|
25
|
-
The user will be asked to enter a password and the connect will succeed.
|
26
|
-
The next time the user should be able to login without a password."""
|
27
|
-
self._uio = UIO()
|
28
|
-
uio = UIO()
|
29
|
-
self.ssh = SSH(SERVER, USERNAME, uio=uio)
|
30
|
-
|
31
|
-
def tearDown(self):
|
32
|
-
self.ssh.close()
|
33
|
-
|
34
|
-
def test1_connect(self):
|
35
|
-
self.ssh.connect()
|
36
|
-
|
37
|
-
def test2_put(self):
|
38
|
-
localFile = "/tmp/pushFile.txt"
|
39
|
-
remoteFile = "/tmp/pushedFile.txt"
|
40
|
-
fd = open(localFile, 'w')
|
41
|
-
fd.write("1234\n")
|
42
|
-
fd.close()
|
43
|
-
|
44
|
-
self.ssh.connect(connectSFTPSession=True)
|
45
|
-
self.ssh.putFile(localFile, remoteFile)
|
46
|
-
|
47
|
-
def test3_get(self):
|
48
|
-
localFile = "/tmp/pulledFile.txt"
|
49
|
-
remoteFile = "/tmp/pushedFile.txt"
|
50
|
-
fd = open(localFile, 'w')
|
51
|
-
fd.write("1234\n")
|
52
|
-
fd.close()
|
53
|
-
|
54
|
-
self.ssh.connect(connectSFTPSession=True)
|
55
|
-
self.ssh.getFile(remoteFile, localFile)
|
56
|
-
|
57
|
-
def test4_fwdTunnel(self):
|
58
|
-
self.ssh.connect()
|
59
|
-
sshTunnelManager = SSHTunnelManager(self._uio, self.ssh, True)
|
60
|
-
sshTunnelManager.startFwdSSHTunnel(30000, SERVER, 22)
|
61
|
-
|
62
|
-
def test5_revTunnel(self):
|
63
|
-
self.ssh.connect()
|
64
|
-
sshTunnelManager = SSHTunnelManager(self._uio, self.ssh, True)
|
65
|
-
sshTunnelManager.startRevSSHTunnel(30000, SERVER, 22)
|
66
|
-
|
67
|
-
def main():
|
68
|
-
"""@brief Unit tests for the UIO class"""
|
69
|
-
suite = unittest.TestLoader().loadTestsFromTestCase(SSHTester)
|
70
|
-
unittest.TextTestRunner(verbosity=2).run(suite)
|
71
|
-
|
72
|
-
if __name__ == '__main__':
|
73
|
-
main()
|
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
|