p3lib 1.1.81__py3-none-any.whl → 1.1.82__py3-none-any.whl
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/bokeh_auth.py +7 -1
- p3lib/boot_manager.py +74 -36
- {p3lib-1.1.81.dist-info → p3lib-1.1.82.dist-info}/METADATA +1 -1
- {p3lib-1.1.81.dist-info → p3lib-1.1.82.dist-info}/RECORD +7 -7
- {p3lib-1.1.81.dist-info → p3lib-1.1.82.dist-info}/LICENSE +0 -0
- {p3lib-1.1.81.dist-info → p3lib-1.1.82.dist-info}/WHEEL +0 -0
- {p3lib-1.1.81.dist-info → p3lib-1.1.82.dist-info}/top_level.txt +0 -0
p3lib/bokeh_auth.py
CHANGED
@@ -149,10 +149,16 @@ class LoginHandler(RequestHandler):
|
|
149
149
|
self._recordLoginAttempt(username, password)
|
150
150
|
valid = False
|
151
151
|
credentialsJsonFile = GetCredentialsFile()
|
152
|
+
LoginHandler.SaveInfoAccessLogMessage(f"credentialsJsonFile = {credentialsJsonFile}")
|
153
|
+
fileExists = os.path.isfile(credentialsJsonFile)
|
154
|
+
LoginHandler.SaveInfoAccessLogMessage(f"fileExists = {fileExists}")
|
152
155
|
ch = CredentialsHasher(credentialsJsonFile)
|
153
|
-
|
156
|
+
verified = ch.verify(username, password)
|
157
|
+
LoginHandler.SaveInfoAccessLogMessage(f"verified = {verified}")
|
158
|
+
if verified:
|
154
159
|
valid = True
|
155
160
|
self._recordLoginSuccess(username, password)
|
161
|
+
LoginHandler.SaveInfoAccessLogMessage(f"check_permission(): valid = {valid}")
|
156
162
|
return valid
|
157
163
|
|
158
164
|
def post(self):
|
p3lib/boot_manager.py
CHANGED
@@ -13,8 +13,65 @@ class BootManager(object):
|
|
13
13
|
Currently supports the following platforms
|
14
14
|
Linux"""
|
15
15
|
|
16
|
-
LINUX_OS_NAME
|
16
|
+
LINUX_OS_NAME = "Linux"
|
17
|
+
ENABLE_CMD_OPT = "--enable_auto_start"
|
18
|
+
DISABLE_CMD_OPT = "--disable_auto_start"
|
19
|
+
CHECK_CMD_OPT = "--check_auto_start"
|
17
20
|
|
21
|
+
@staticmethod
|
22
|
+
def AddCmdArgs(parser):
|
23
|
+
"""@brief Add cmd line arguments to enable, disable and show the systemd boot state.
|
24
|
+
@param parser An instance of argparse.ArgumentParser."""
|
25
|
+
parser.add_argument(BootManager.ENABLE_CMD_OPT, help="Auto start when this computer starts.", action="store_true", default=False)
|
26
|
+
parser.add_argument(BootManager.DISABLE_CMD_OPT, help="Disable auto starting when this computer starts.", action="store_true", default=False)
|
27
|
+
parser.add_argument(BootManager.CHECK_CMD_OPT, help="Check the status of an auto started icons_gw instance.", action="store_true", default=False)
|
28
|
+
|
29
|
+
@staticmethod
|
30
|
+
def HandleOptions(uio, options, enable_syslog):
|
31
|
+
"""@brief Handle one of the bot manager command line options if the
|
32
|
+
user passed it on the cmd line.
|
33
|
+
@param uio A UIO instance.
|
34
|
+
@param options As returned from parser.parse_args() where parser
|
35
|
+
is an instance of argparse.ArgumentParser.
|
36
|
+
@param enable_syslog True to enable systemd syslog output.
|
37
|
+
@return True if handled , False if not."""
|
38
|
+
handled = False
|
39
|
+
if options.check_auto_start:
|
40
|
+
BootManager.CheckAutoStartStatus(uio)
|
41
|
+
handled = True
|
42
|
+
|
43
|
+
elif options.enable_auto_start:
|
44
|
+
BootManager.EnableAutoStart(uio, enable_syslog)
|
45
|
+
handled = True
|
46
|
+
|
47
|
+
elif options.disable_auto_start:
|
48
|
+
BootManager.DisableAutoStart(uio)
|
49
|
+
handled = True
|
50
|
+
|
51
|
+
return handled
|
52
|
+
|
53
|
+
@staticmethod
|
54
|
+
def EnableAutoStart(uio, enable_syslog):
|
55
|
+
"""@brief Enable this program to auto start when the computer on which it is installed starts."""
|
56
|
+
bootManager = BootManager(uio=uio, ensureRootUser=True)
|
57
|
+
arsString = " ".join(sys.argv)
|
58
|
+
bootManager.add(argString=arsString, enableSyslog=enable_syslog)
|
59
|
+
|
60
|
+
@staticmethod
|
61
|
+
def DisableAutoStart(uio):
|
62
|
+
"""@brief Enable this program to auto start when the computer on which it is installed starts."""
|
63
|
+
bootManager = BootManager(uio=uio, ensureRootUser=True)
|
64
|
+
bootManager.remove()
|
65
|
+
|
66
|
+
@staticmethod
|
67
|
+
def CheckAutoStartStatus(uio):
|
68
|
+
"""@brief Check the status of a process previously set to auto start."""
|
69
|
+
bootManager = BootManager(uio=uio)
|
70
|
+
lines = bootManager.getStatus()
|
71
|
+
if lines and len(lines) > 0:
|
72
|
+
for line in lines:
|
73
|
+
uio.info(line)
|
74
|
+
|
18
75
|
def __init__(self, uio=None, allowRootUser=True, ensureRootUser=False):
|
19
76
|
"""@brief Constructor
|
20
77
|
@param uio A UIO instance to display user output. If unset then no output
|
@@ -130,41 +187,14 @@ class LinuxBootManager(object):
|
|
130
187
|
named the same as the python file executed without the .py suffix.
|
131
188
|
@return The startup script file (absolute path)."""""
|
132
189
|
startupScript=None
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
exeFile=os.path.basename( pythonFile.replace(".py", "") )
|
142
|
-
if envPaths and len(envPaths) > 0:
|
143
|
-
for envPath in envPaths:
|
144
|
-
_exeStartupScript = os.path.join(envPath, exeFile)
|
145
|
-
if os.path.isfile(_exeStartupScript):
|
146
|
-
startupScript=_exeStartupScript
|
147
|
-
break
|
148
|
-
|
149
|
-
# If the script file has not been found then search for a file with
|
150
|
-
# the .py suffix.
|
151
|
-
if not startupScript:
|
152
|
-
if envPaths and len(envPaths) > 0:
|
153
|
-
for envPath in envPaths:
|
154
|
-
_startupScript = os.path.join(envPath, pythonFile)
|
155
|
-
if os.path.isfile(_startupScript):
|
156
|
-
startupScript=_startupScript
|
157
|
-
break
|
158
|
-
|
159
|
-
if not startupScript:
|
160
|
-
paths = self._getPaths()
|
161
|
-
if len(paths):
|
162
|
-
for _path in paths:
|
163
|
-
self._info(_path)
|
164
|
-
self._fatalError("{} startup script not found using the PATH env var".format(pythonFile) )
|
165
|
-
else:
|
166
|
-
self._fatalError("No PATH env var found.")
|
167
|
-
|
190
|
+
argList = sys.argv
|
191
|
+
# If the first argument in the arg is a file.
|
192
|
+
if len(argList) > 0:
|
193
|
+
firstArg = argList[0]
|
194
|
+
if os.path.isfile(firstArg) or os.path.islink(firstArg):
|
195
|
+
startupScript = firstArg
|
196
|
+
if startupScript is None:
|
197
|
+
raise Exception("Failed to find the startup script.")
|
168
198
|
return startupScript
|
169
199
|
|
170
200
|
def _getPaths(self):
|
@@ -287,6 +317,13 @@ class LinuxBootManager(object):
|
|
287
317
|
if user and len(user) > 0:
|
288
318
|
lines.append('Environment="HOME=/home/{}"'.format(user))
|
289
319
|
if argString:
|
320
|
+
argString = argString.strip()
|
321
|
+
if argString.startswith(absApp):
|
322
|
+
argString=argString.replace(absApp, "")
|
323
|
+
# We don't want the enable cmd opt in the cmd we add to the systemd file.
|
324
|
+
if argString.find(BootManager.ENABLE_CMD_OPT):
|
325
|
+
argString = argString.replace(BootManager.ENABLE_CMD_OPT, "")
|
326
|
+
argString = argString.strip()
|
290
327
|
lines.append("ExecStart={} {}".format(absApp, argString))
|
291
328
|
else:
|
292
329
|
lines.append("ExecStart={}".format(absApp))
|
@@ -299,6 +336,7 @@ class LinuxBootManager(object):
|
|
299
336
|
fd = open(serviceFile, 'w')
|
300
337
|
fd.write( "\n".join(lines) )
|
301
338
|
fd.close()
|
339
|
+
self._info(f"Created {serviceFile}")
|
302
340
|
except IOError:
|
303
341
|
self._fatalError("Failed to create {}".format(serviceFile) )
|
304
342
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: p3lib
|
3
|
-
Version: 1.1.
|
3
|
+
Version: 1.1.82
|
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,8 +1,8 @@
|
|
1
1
|
p3lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
p3lib/ate.py,sha256=_BiqMUYNAlp4O8MkP_PAUe62Bzd8dzV4Ipv62OFS6Ok,4759
|
3
|
-
p3lib/bokeh_auth.py,sha256=
|
3
|
+
p3lib/bokeh_auth.py,sha256=zi_Hty2WkCJVNQ4sINNRo5FBXujuJky9phyoF6M55ms,15180
|
4
4
|
p3lib/bokeh_gui.py,sha256=55sajP_x9O1lE0uP3w3-T5f2oMzk7jSolLqxlEdLeLg,40245
|
5
|
-
p3lib/boot_manager.py,sha256=
|
5
|
+
p3lib/boot_manager.py,sha256=h5In_QoRDH8oHivcu4gyTzGXWg3joKBiVCz2B8Ttn8E,16941
|
6
6
|
p3lib/conduit.py,sha256=jPkjdtyCx2I6SFqcEo8y2g7rgnZ-jNY7oCuYIETzT5Q,6046
|
7
7
|
p3lib/database_if.py,sha256=XKu1w3zftGbj4Rh54wrWJnoCtqHkhCzJUPN2S70XIKg,11915
|
8
8
|
p3lib/helper.py,sha256=-B63_ncfchMwXrvyVcnj9sxwGnMJ3ASmLmpoYa4tBmM,11862
|
@@ -15,8 +15,8 @@ p3lib/pconfig.py,sha256=IWNEE1DKGwLo78CsUoJLtwGNEMuVLfL4zTKPy_SxygY,30089
|
|
15
15
|
p3lib/ssh.py,sha256=klqQ9YuqU8GwPVPHrAJeEs5PI5hgoYiXflq2kIGG3as,39509
|
16
16
|
p3lib/table_plot.py,sha256=RPncwVlGUkkx5Fw0dHQedXo0TSPlTi__VrJBDzaMsuI,32116
|
17
17
|
p3lib/uio.py,sha256=Aaxc99XiE3d2f9vLjaN-bZsckoNxay5t0ujdK6PXGrw,23265
|
18
|
-
p3lib-1.1.
|
19
|
-
p3lib-1.1.
|
20
|
-
p3lib-1.1.
|
21
|
-
p3lib-1.1.
|
22
|
-
p3lib-1.1.
|
18
|
+
p3lib-1.1.82.dist-info/LICENSE,sha256=igqTy5u0kVWM1n-NUZMvAlinY6lVjAXKoag0okkS8V8,1067
|
19
|
+
p3lib-1.1.82.dist-info/METADATA,sha256=Ug7Hh8J-1kXHvVGX5zCVGQItaWSbRDz6LsgsJ5XmXtI,918
|
20
|
+
p3lib-1.1.82.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
21
|
+
p3lib-1.1.82.dist-info/top_level.txt,sha256=SDCpXYh-19yCFp4Z8ZK4B-3J4NvTCJElZ42NPgcR6-U,6
|
22
|
+
p3lib-1.1.82.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|