p3lib 1.1.93__py3-none-any.whl → 1.1.95__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/boot_manager.py +46 -22
- p3lib/helper.py +0 -1
- {p3lib-1.1.93.dist-info → p3lib-1.1.95.dist-info}/METADATA +1 -1
- {p3lib-1.1.93.dist-info → p3lib-1.1.95.dist-info}/RECORD +7 -7
- {p3lib-1.1.93.dist-info → p3lib-1.1.95.dist-info}/LICENSE +0 -0
- {p3lib-1.1.93.dist-info → p3lib-1.1.95.dist-info}/WHEEL +0 -0
- {p3lib-1.1.93.dist-info → p3lib-1.1.95.dist-info}/top_level.txt +0 -0
p3lib/boot_manager.py
CHANGED
@@ -27,13 +27,16 @@ class BootManager(object):
|
|
27
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
28
|
|
29
29
|
@staticmethod
|
30
|
-
def HandleOptions(uio, options, enable_syslog):
|
30
|
+
def HandleOptions(uio, options, enable_syslog, appName=None, restartSeconds=1):
|
31
31
|
"""@brief Handle one of the bot manager command line options if the
|
32
32
|
user passed it on the cmd line.
|
33
33
|
@param uio A UIO instance.
|
34
34
|
@param options As returned from parser.parse_args() where parser
|
35
35
|
is an instance of argparse.ArgumentParser.
|
36
36
|
@param enable_syslog True to enable systemd syslog output.
|
37
|
+
@param appName The name of the app. This is used as the service name. If not set then
|
38
|
+
the name of the initially executed python file is used.
|
39
|
+
@param restartSeconds The number of seconds to sleep before restarting a service that has stopped (default=1).
|
37
40
|
@return True if handled , False if not."""
|
38
41
|
handled = False
|
39
42
|
if options.check_auto_start:
|
@@ -41,7 +44,7 @@ class BootManager(object):
|
|
41
44
|
handled = True
|
42
45
|
|
43
46
|
elif options.enable_auto_start:
|
44
|
-
BootManager.EnableAutoStart(uio, enable_syslog)
|
47
|
+
BootManager.EnableAutoStart(uio, enable_syslog, appName, restartSeconds)
|
45
48
|
handled = True
|
46
49
|
|
47
50
|
elif options.disable_auto_start:
|
@@ -51,9 +54,16 @@ class BootManager(object):
|
|
51
54
|
return handled
|
52
55
|
|
53
56
|
@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
|
-
|
57
|
+
def EnableAutoStart(uio, enable_syslog, appName, restartSeconds):
|
58
|
+
"""@brief Enable this program to auto start when the computer on which it is installed starts.
|
59
|
+
@param uio A UIO instance.
|
60
|
+
@param options As returned from parser.parse_args() where parser
|
61
|
+
is an instance of argparse.ArgumentParser.
|
62
|
+
@param enable_syslog True to enable systemd syslog output.
|
63
|
+
@param appName The name of the app. This is used as the service name. If not set then
|
64
|
+
the name of the initially executed python file is used.
|
65
|
+
@param restartSeconds The number of seconds to sleep before restarting a service that has stopped (default=1)."""
|
66
|
+
bootManager = BootManager(uio=uio, ensureRootUser=True, appName=appName, restartSeconds=restartSeconds)
|
57
67
|
arsString = " ".join(sys.argv)
|
58
68
|
bootManager.add(argString=arsString, enableSyslog=enable_syslog)
|
59
69
|
|
@@ -72,7 +82,7 @@ class BootManager(object):
|
|
72
82
|
for line in lines:
|
73
83
|
uio.info(line)
|
74
84
|
|
75
|
-
def __init__(self, uio=None, allowRootUser=True, ensureRootUser=False):
|
85
|
+
def __init__(self, uio=None, allowRootUser=True, ensureRootUser=False, appName=None, restartSeconds=1):
|
76
86
|
"""@brief Constructor
|
77
87
|
@param uio A UIO instance to display user output. If unset then no output
|
78
88
|
is displayed to user.
|
@@ -81,13 +91,16 @@ class BootManager(object):
|
|
81
91
|
ensuring programs are started up when a machine boots up
|
82
92
|
the installed program should be installed for the root
|
83
93
|
user on Linux systems.
|
84
|
-
@param ensureRootUser If True the current user must be root user (Linux systems).
|
94
|
+
@param ensureRootUser If True the current user must be root user (Linux systems).
|
95
|
+
@param appName The name of the app. This is used as the service name. If not set then
|
96
|
+
the name of the initially executed python file is used.
|
97
|
+
@param restartSeconds The number of seconds to sleep before restarting a service that has stopped (default=1)."""
|
85
98
|
self._uio = uio
|
86
99
|
self._allowRootUser=allowRootUser
|
87
100
|
self._osName = platform.system()
|
88
101
|
self._platformBootManager = None
|
89
102
|
if self._osName == BootManager.LINUX_OS_NAME:
|
90
|
-
self._platformBootManager = LinuxBootManager(uio, self._allowRootUser, ensureRootUser)
|
103
|
+
self._platformBootManager = LinuxBootManager(uio, self._allowRootUser, ensureRootUser, appName, restartSeconds)
|
91
104
|
else:
|
92
105
|
raise Exception("{} is an unsupported OS.".format(self._osName) )
|
93
106
|
|
@@ -155,11 +168,14 @@ class LinuxBootManager(object):
|
|
155
168
|
raise Exception(f"{serviceFolder} folder not found.")
|
156
169
|
return serviceFolder
|
157
170
|
|
158
|
-
def __init__(self, uio, allowRootUser, ensureRootUser):
|
171
|
+
def __init__(self, uio, allowRootUser, ensureRootUser, appName, restartSeconds):
|
159
172
|
"""@brief Constructor
|
160
173
|
@param uio A UIO instance to display user output. If unset then no output is displayed to user.
|
161
174
|
@param allowRootUser If True then allow root user to to auto start programs.
|
162
|
-
@param ensureRootUser If True the current user must be root user.
|
175
|
+
@param ensureRootUser If True the current user must be root user.
|
176
|
+
@param appName The name of the app. This is used as the systemd service name. If not set then
|
177
|
+
the name of the initially executed python file is used.
|
178
|
+
@param restartSeconds The number of seconds to sleep before restarting a service that has stopped."""
|
163
179
|
self._uio = uio
|
164
180
|
self._logFile = None
|
165
181
|
self._allowRootUser=allowRootUser
|
@@ -180,7 +196,8 @@ class LinuxBootManager(object):
|
|
180
196
|
self._cmdLinePrefix = self._systemCtlBin
|
181
197
|
self._username = getpass.getuser()
|
182
198
|
self._serviceFolder = LinuxBootManager.GetServiceFolder(self._rootMode)
|
183
|
-
self._appName =
|
199
|
+
self._appName = appName
|
200
|
+
self._restartSeconds = restartSeconds
|
184
201
|
|
185
202
|
def _getInstallledStartupScript(self):
|
186
203
|
"""@brief Get the startup script full path. The startup script must be
|
@@ -252,18 +269,25 @@ class LinuxBootManager(object):
|
|
252
269
|
if not os.path.isdir(exePath):
|
253
270
|
self._fatalError("{} path not found".format(exePath))
|
254
271
|
|
255
|
-
appName
|
256
|
-
if
|
257
|
-
|
272
|
+
# If the appName was set in the constructor then use this.
|
273
|
+
if self._appName:
|
274
|
+
appName = self._appName
|
258
275
|
|
259
|
-
|
260
|
-
|
261
|
-
self._fatalError("{} file not found.".format(absApp) )
|
276
|
+
# Else we use the initially executed python file.
|
277
|
+
else:
|
262
278
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
279
|
+
appName = os.path.basename(exeFile)
|
280
|
+
if len(appName) == 0:
|
281
|
+
self._fatalError("No app found to execute.")
|
282
|
+
|
283
|
+
absApp = os.path.join(exePath, appName)
|
284
|
+
if not os.path.isfile( absApp ):
|
285
|
+
self._fatalError("{} file not found.".format(absApp) )
|
286
|
+
|
287
|
+
appName = appName.replace(".py", "")
|
288
|
+
if self._rootMode:
|
289
|
+
# We can only save to /var/log/ is we are root user.
|
290
|
+
self._logFile = os.path.join(LinuxBootManager.LOG_PATH, appName)
|
267
291
|
|
268
292
|
return (appName, absApp)
|
269
293
|
|
@@ -302,7 +326,7 @@ class LinuxBootManager(object):
|
|
302
326
|
lines.append("[Service]")
|
303
327
|
lines.append("Type=simple")
|
304
328
|
lines.append("Restart=always")
|
305
|
-
lines.append("RestartSec=
|
329
|
+
lines.append(f"RestartSec={self._restartSeconds}")
|
306
330
|
if enableSyslog:
|
307
331
|
lines.append("StandardOutput=syslog")
|
308
332
|
lines.append("StandardError=syslog")
|
p3lib/helper.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: p3lib
|
3
|
-
Version: 1.1.
|
3
|
+
Version: 1.1.95
|
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
|
@@ -2,10 +2,10 @@ p3lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
p3lib/ate.py,sha256=_BiqMUYNAlp4O8MkP_PAUe62Bzd8dzV4Ipv62OFS6Ok,4759
|
3
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=h8IOvhQA8z-4S3smNHGYII55m5bzmQjcmzfPEJedxb8,18921
|
6
6
|
p3lib/conduit.py,sha256=jPkjdtyCx2I6SFqcEo8y2g7rgnZ-jNY7oCuYIETzT5Q,6046
|
7
7
|
p3lib/database_if.py,sha256=XKu1w3zftGbj4Rh54wrWJnoCtqHkhCzJUPN2S70XIKg,11915
|
8
|
-
p3lib/helper.py,sha256=
|
8
|
+
p3lib/helper.py,sha256=xTKPgpziwr4zyaoc0sjZRFr0M91fo7Tok_nSAvtiTZE,12020
|
9
9
|
p3lib/json_networking.py,sha256=6u4s1SmypjTYPnSxHP712OgQ3ZJaxOqIkgHQ1J7Qews,9738
|
10
10
|
p3lib/mqtt_rpc.py,sha256=6LmFA1kR4HSJs9eWbOJORRHNY01L_lHWjvtE2fmY8P8,10511
|
11
11
|
p3lib/netif.py,sha256=3QV5OGdHhELIf4MBj6mx5MNCtVeZ7JXoNEkeu4KzCaE,9796
|
@@ -15,8 +15,8 @@ p3lib/pconfig.py,sha256=82rX7zvJVbSFtYYHvhj9I6GTdpjf9v73fNs9WQE-5ik,35388
|
|
15
15
|
p3lib/ssh.py,sha256=OyoAQ_h1L2RfkjTAChDrvLFfl4Fe_gBNdX5rvK-wKiw,42125
|
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.95.dist-info/LICENSE,sha256=igqTy5u0kVWM1n-NUZMvAlinY6lVjAXKoag0okkS8V8,1067
|
19
|
+
p3lib-1.1.95.dist-info/METADATA,sha256=jbNsDi4Z4iilqPmYlfxw82s4Xz2gKTytMiCobh7m6Pw,918
|
20
|
+
p3lib-1.1.95.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
21
|
+
p3lib-1.1.95.dist-info/top_level.txt,sha256=SDCpXYh-19yCFp4Z8ZK4B-3J4NvTCJElZ42NPgcR6-U,6
|
22
|
+
p3lib-1.1.95.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|