p3lib 1.1.79__py3-none-any.whl → 1.1.81__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 +2 -2
- p3lib/boot_manager.py +10 -5
- p3lib/pconfig.py +14 -16
- p3lib/table_plot.py +0 -1
- p3lib/uio.py +9 -6
- {p3lib-1.1.79.dist-info → p3lib-1.1.81.dist-info}/METADATA +1 -1
- {p3lib-1.1.79.dist-info → p3lib-1.1.81.dist-info}/RECORD +10 -10
- {p3lib-1.1.79.dist-info → p3lib-1.1.81.dist-info}/LICENSE +0 -0
- {p3lib-1.1.79.dist-info → p3lib-1.1.81.dist-info}/WHEEL +0 -0
- {p3lib-1.1.79.dist-info → p3lib-1.1.81.dist-info}/top_level.txt +0 -0
p3lib/bokeh_auth.py
CHANGED
@@ -321,9 +321,9 @@ class CredentialsManager(object):
|
|
321
321
|
username = self._uio.getInput('Enter the username: ')
|
322
322
|
password = self._uio.getInput('Enter the password: ')
|
323
323
|
if self.credentialsHasher.verify(username, password):
|
324
|
-
self._uio.info(
|
324
|
+
self._uio.info("The username and password match.")
|
325
325
|
else:
|
326
|
-
self._uio.error(
|
326
|
+
self._uio.error("The username and password do not match.")
|
327
327
|
|
328
328
|
def _showUsernames(self):
|
329
329
|
"""@brief Show the user a list of the usernames stored."""
|
p3lib/boot_manager.py
CHANGED
@@ -15,7 +15,7 @@ class BootManager(object):
|
|
15
15
|
|
16
16
|
LINUX_OS_NAME = "Linux"
|
17
17
|
|
18
|
-
def __init__(self, uio=None, allowRootUser=True):
|
18
|
+
def __init__(self, uio=None, allowRootUser=True, ensureRootUser=False):
|
19
19
|
"""@brief Constructor
|
20
20
|
@param uio A UIO instance to display user output. If unset then no output
|
21
21
|
is displayed to user.
|
@@ -23,13 +23,14 @@ class BootManager(object):
|
|
23
23
|
programs. Note that as the BootManager is responsible for
|
24
24
|
ensuring programs are started up when a machine boots up
|
25
25
|
the installed program should be installed for the root
|
26
|
-
user on Linux systems.
|
26
|
+
user on Linux systems.
|
27
|
+
@param ensureRootUser If True the current user must be root user (Linux systems)."""
|
27
28
|
self._uio = uio
|
28
29
|
self._allowRootUser=allowRootUser
|
29
30
|
self._osName = platform.system()
|
30
31
|
self._platformBootManager = None
|
31
32
|
if self._osName == BootManager.LINUX_OS_NAME:
|
32
|
-
self._platformBootManager = LinuxBootManager(uio, self._allowRootUser)
|
33
|
+
self._platformBootManager = LinuxBootManager(uio, self._allowRootUser, ensureRootUser)
|
33
34
|
else:
|
34
35
|
raise Exception("{} is an unsupported OS.".format(self._osName) )
|
35
36
|
|
@@ -97,16 +98,20 @@ class LinuxBootManager(object):
|
|
97
98
|
raise Exception(f"{serviceFolder} folder not found.")
|
98
99
|
return serviceFolder
|
99
100
|
|
100
|
-
def __init__(self, uio, allowRootUser):
|
101
|
+
def __init__(self, uio, allowRootUser, ensureRootUser):
|
101
102
|
"""@brief Constructor
|
102
103
|
@param uio A UIO instance to display user output. If unset then no output is displayed to user.
|
103
|
-
@param allowRootUser If True then allow root user to to auto start programs.
|
104
|
+
@param allowRootUser If True then allow root user to to auto start programs.
|
105
|
+
@param ensureRootUser If True the current user must be root user."""
|
104
106
|
self._uio = uio
|
105
107
|
self._logFile = None
|
106
108
|
self._allowRootUser=allowRootUser
|
107
109
|
self._info("OS: {}".format(platform.system()) )
|
108
110
|
self._rootMode = False # If True run as root, else False.
|
109
111
|
self._systemCtlBin = LinuxBootManager.GetSystemCTLBin()
|
112
|
+
if ensureRootUser and os.geteuid() != 0:
|
113
|
+
self._fatalError(self.__class__.__name__ + ": Not root user. Ensure that you are root user and try again.")
|
114
|
+
|
110
115
|
if os.geteuid() == 0:
|
111
116
|
if not allowRootUser:
|
112
117
|
self._fatalError(self.__class__.__name__ + f": You are running as root user but allowRootUser={allowRootUser}.")
|
p3lib/pconfig.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/bin/sh/env
|
1
|
+
#!/bin/sh/env python3
|
2
2
|
|
3
3
|
import os
|
4
4
|
import base64
|
@@ -6,6 +6,7 @@ import datetime
|
|
6
6
|
import sys
|
7
7
|
import json
|
8
8
|
import copy
|
9
|
+
import platform
|
9
10
|
|
10
11
|
from shutil import copyfile
|
11
12
|
|
@@ -313,31 +314,28 @@ class ConfigManager(object):
|
|
313
314
|
if not cfgFilename:
|
314
315
|
raise Exception("No config filename defined.")
|
315
316
|
|
316
|
-
cfgFilename = cfgFilename
|
317
317
|
if addDotToFilename:
|
318
318
|
if not cfgFilename.startswith("."):
|
319
319
|
|
320
320
|
cfgFilename=".%s" % (cfgFilename)
|
321
321
|
|
322
|
-
else:
|
323
|
-
|
324
|
-
cfgFilename=cfgFilename
|
325
|
-
|
326
322
|
#The the config path has been set then use it
|
327
323
|
if cfgPath:
|
328
324
|
configPath = cfgPath
|
329
325
|
|
330
326
|
else:
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
#
|
339
|
-
|
340
|
-
|
327
|
+
# If the root user on a Linux system
|
328
|
+
if platform.system() == 'Linux' and os.geteuid() == 0:
|
329
|
+
# This should be the root users config folder.
|
330
|
+
configPath="/root"
|
331
|
+
|
332
|
+
else:
|
333
|
+
configPath=""
|
334
|
+
#If an absolute path is set for the config file then don't try to
|
335
|
+
#put the file in the users home dir
|
336
|
+
if not cfgFilename.startswith("/"):
|
337
|
+
configPath = expanduser("~")
|
338
|
+
configPath = configPath.strip()
|
341
339
|
|
342
340
|
return join( configPath, cfgFilename )
|
343
341
|
|
p3lib/table_plot.py
CHANGED
@@ -18,7 +18,6 @@ from bokeh.layouts import gridplot, row, column
|
|
18
18
|
from bokeh.plotting import figure, ColumnDataSource
|
19
19
|
from bokeh.palettes import Category20
|
20
20
|
from bokeh.models import HoverTool, Div
|
21
|
-
from bokeh.models import DatetimeTickFormatter
|
22
21
|
from bokeh.models.widgets.buttons import Button
|
23
22
|
from bokeh.models.widgets import TextInput
|
24
23
|
from bokeh.plotting import output_file, save
|
p3lib/uio.py
CHANGED
@@ -113,7 +113,7 @@ class UIO(object):
|
|
113
113
|
self._print('{}INFO{}: {}'.format(UIO.GetInfoEscapeSeq(), UIO.DISPLAY_RESET_ESCAPE_SEQ, text))
|
114
114
|
else:
|
115
115
|
self._print('INFO: {}'.format(text))
|
116
|
-
self._update_syslog(PRIORITY.INFO, text)
|
116
|
+
self._update_syslog(PRIORITY.INFO, "INFO: "+text)
|
117
117
|
|
118
118
|
def debug(self, text):
|
119
119
|
"""@brief Present a debug level message to the user if debuging is enabled.
|
@@ -128,7 +128,7 @@ class UIO(object):
|
|
128
128
|
self.storeToDebugLog('{}DEBUG{}: {}'.format(UIO.GetDebugEscapeSeq(), UIO.DISPLAY_RESET_ESCAPE_SEQ, text))
|
129
129
|
else:
|
130
130
|
self.storeToDebugLog('DEBUG: {}'.format(text))
|
131
|
-
self._update_syslog(PRIORITY.DEBUG, text)
|
131
|
+
self._update_syslog(PRIORITY.DEBUG, "DEBUG: "+text)
|
132
132
|
|
133
133
|
def warn(self, text):
|
134
134
|
"""@brief Present a warning level message to the user.
|
@@ -137,7 +137,7 @@ class UIO(object):
|
|
137
137
|
self._print('{}WARN{}: {}'.format(UIO.GetWarnEscapeSeq(), UIO.DISPLAY_RESET_ESCAPE_SEQ, text))
|
138
138
|
else:
|
139
139
|
self._print('WARN: {}'.format(text))
|
140
|
-
self._update_syslog(PRIORITY.WARNING, text)
|
140
|
+
self._update_syslog(PRIORITY.WARNING, "WARN: "+text)
|
141
141
|
|
142
142
|
def error(self, text):
|
143
143
|
"""@brief Present an error level message to the user.
|
@@ -146,7 +146,7 @@ class UIO(object):
|
|
146
146
|
self._print('{}ERROR{}: {}'.format(UIO.GetErrorEscapeSeq(), UIO.DISPLAY_RESET_ESCAPE_SEQ, text))
|
147
147
|
else:
|
148
148
|
self._print('ERROR: {}'.format(text))
|
149
|
-
self._update_syslog(PRIORITY.ERROR, text)
|
149
|
+
self._update_syslog(PRIORITY.ERROR, "ERROR: "+text)
|
150
150
|
|
151
151
|
def _print(self, text):
|
152
152
|
"""@brief Print text to stdout"""
|
@@ -382,7 +382,10 @@ class UIO(object):
|
|
382
382
|
@param syslogProgramName The name of the program that is being logged. If defined this appears after the username in the syslog output."""
|
383
383
|
self._sysLogEnabled = enabled
|
384
384
|
self._sysLogHost = host
|
385
|
-
|
385
|
+
if programName:
|
386
|
+
self._syslogProgramName = programName
|
387
|
+
else:
|
388
|
+
self._syslogProgramName = sys.argv[0]
|
386
389
|
|
387
390
|
def _update_syslog(self, pri, msg):
|
388
391
|
"""Send a message to syslog is syslog is enabled
|
@@ -398,7 +401,7 @@ class UIO(object):
|
|
398
401
|
"""
|
399
402
|
if self._sysLogEnabled:
|
400
403
|
aMsg=msg
|
401
|
-
#Ensure we have no
|
404
|
+
#Ensure we have no 0x00 characters in the message.
|
402
405
|
# syslog will throw an error if it finds any
|
403
406
|
if "\x00" in aMsg:
|
404
407
|
aMsg=aMsg.replace("\x00", "")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: p3lib
|
3
|
-
Version: 1.1.
|
3
|
+
Version: 1.1.81
|
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=wQKSiF_gYvCs5aWUptiDkloC2tmEO-5XiAQ0mO8KFYk,14767
|
4
4
|
p3lib/bokeh_gui.py,sha256=55sajP_x9O1lE0uP3w3-T5f2oMzk7jSolLqxlEdLeLg,40245
|
5
|
-
p3lib/boot_manager.py,sha256=
|
5
|
+
p3lib/boot_manager.py,sha256=IrIJg9LOsxWBP1-1wNR_mO_jzR1FAWVOBVtw7mHHLgw,14968
|
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
|
@@ -11,12 +11,12 @@ p3lib/mqtt_rpc.py,sha256=6LmFA1kR4HSJs9eWbOJORRHNY01L_lHWjvtE2fmY8P8,10511
|
|
11
11
|
p3lib/netif.py,sha256=3QV5OGdHhELIf4MBj6mx5MNCtVeZ7JXoNEkeu4KzCaE,9796
|
12
12
|
p3lib/netplotly.py,sha256=PMDx-w1jtRVW6Od5u_kuKbBxNpTS_Y88mMF60puMxLM,9363
|
13
13
|
p3lib/ngt.py,sha256=rXA-6zQkfeOupZ-3Q-k3-1DvbKYIi2TCtLKgUb0waWY,37726
|
14
|
-
p3lib/pconfig.py,sha256=
|
14
|
+
p3lib/pconfig.py,sha256=IWNEE1DKGwLo78CsUoJLtwGNEMuVLfL4zTKPy_SxygY,30089
|
15
15
|
p3lib/ssh.py,sha256=klqQ9YuqU8GwPVPHrAJeEs5PI5hgoYiXflq2kIGG3as,39509
|
16
|
-
p3lib/table_plot.py,sha256=
|
17
|
-
p3lib/uio.py,sha256=
|
18
|
-
p3lib-1.1.
|
19
|
-
p3lib-1.1.
|
20
|
-
p3lib-1.1.
|
21
|
-
p3lib-1.1.
|
22
|
-
p3lib-1.1.
|
16
|
+
p3lib/table_plot.py,sha256=RPncwVlGUkkx5Fw0dHQedXo0TSPlTi__VrJBDzaMsuI,32116
|
17
|
+
p3lib/uio.py,sha256=Aaxc99XiE3d2f9vLjaN-bZsckoNxay5t0ujdK6PXGrw,23265
|
18
|
+
p3lib-1.1.81.dist-info/LICENSE,sha256=igqTy5u0kVWM1n-NUZMvAlinY6lVjAXKoag0okkS8V8,1067
|
19
|
+
p3lib-1.1.81.dist-info/METADATA,sha256=h2NYdtBmdpPqnnmEbgvQyqhwQUVxyINEGm6avNu8_j4,918
|
20
|
+
p3lib-1.1.81.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
21
|
+
p3lib-1.1.81.dist-info/top_level.txt,sha256=SDCpXYh-19yCFp4Z8ZK4B-3J4NvTCJElZ42NPgcR6-U,6
|
22
|
+
p3lib-1.1.81.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|