ebs-linuxnode-core 3.1.2__tar.gz → 3.1.4__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.
- {ebs-linuxnode-core-3.1.2/ebs_linuxnode_core.egg-info → ebs-linuxnode-core-3.1.4}/PKG-INFO +1 -1
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs/linuxnode/core/config.py +1 -1
- ebs-linuxnode-core-3.1.4/ebs/linuxnode/core/shell.py +96 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4/ebs_linuxnode_core.egg-info}/PKG-INFO +1 -1
- ebs-linuxnode-core-3.1.2/ebs/linuxnode/core/shell.py +0 -21
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/.gitignore +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs/__init__.py +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs/linuxnode/__init__.py +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs/linuxnode/core/__init__.py +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs/linuxnode/core/background.py +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs/linuxnode/core/basemixin.py +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs/linuxnode/core/basenode.py +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs/linuxnode/core/busy.py +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs/linuxnode/core/constants.py +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs/linuxnode/core/http.py +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs/linuxnode/core/log.py +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs/linuxnode/core/nodeid.py +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs/linuxnode/core/resources.py +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs/linuxnode/db/__init__.py +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs/linuxnode/db/sequence.py +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs_linuxnode_core.egg-info/SOURCES.txt +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs_linuxnode_core.egg-info/dependency_links.txt +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs_linuxnode_core.egg-info/requires.txt +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs_linuxnode_core.egg-info/top_level.txt +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/example.py +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/setup.cfg +0 -0
- {ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/setup.py +0 -0
|
@@ -119,7 +119,7 @@ class IoTNodeConfig(object):
|
|
|
119
119
|
if element == '_elements' or element not in self._elements.keys():
|
|
120
120
|
return super(IoTNodeConfig, self).__setattr__(element, value)
|
|
121
121
|
section, item, item_spec = self._elements[element]
|
|
122
|
-
item_type, fallback, read_only = item_spec
|
|
122
|
+
item_type, fallback, read_only, masked = item_spec
|
|
123
123
|
|
|
124
124
|
if read_only:
|
|
125
125
|
raise AttributeError("{} element '{}' is read_only. Cannot write."
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
from os import environ
|
|
4
|
+
from twisted.internet.utils import getProcessOutput
|
|
5
|
+
from twisted.internet.error import ProcessExitedAlready
|
|
6
|
+
from twisted.internet.protocol import ProcessProtocol
|
|
7
|
+
from .basemixin import BaseMixin
|
|
8
|
+
from .config import ConfigMixin
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ProcessClient(ProcessProtocol):
|
|
12
|
+
def __init__(self, line_handler=None, exit_handler=None,
|
|
13
|
+
name=None, *args, **kwargs):
|
|
14
|
+
super(ProcessClient, self).__init__(*args, **kwargs)
|
|
15
|
+
self._line_handler = line_handler
|
|
16
|
+
self._exit_handler = exit_handler
|
|
17
|
+
self._name = name
|
|
18
|
+
|
|
19
|
+
def connectionMade(self):
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
def outReceived(self, data: bytes):
|
|
23
|
+
if self._line_handler:
|
|
24
|
+
self._line_handler(data.strip().decode())
|
|
25
|
+
|
|
26
|
+
def errReceived(self, data):
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
def inConnectionLost(self):
|
|
30
|
+
# stdin is closed. (we probably did it)"
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
def outConnectionLost(self):
|
|
34
|
+
# The child closed their stdout.
|
|
35
|
+
pass
|
|
36
|
+
|
|
37
|
+
def errConnectionLost(self):
|
|
38
|
+
# The child closed their stderr.
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
def processExited(self, reason):
|
|
42
|
+
pass
|
|
43
|
+
|
|
44
|
+
def processEnded(self, reason):
|
|
45
|
+
if self._exit_handler:
|
|
46
|
+
self._exit_handler(reason.value.exitCode)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class BaseShellMixin(ConfigMixin, BaseMixin):
|
|
50
|
+
def __init__(self, *args, **kwargs):
|
|
51
|
+
self._shell_processes = {}
|
|
52
|
+
super(BaseShellMixin, self).__init__(*args, **kwargs)
|
|
53
|
+
|
|
54
|
+
def _shell_execute(self, command, response_handler):
|
|
55
|
+
if len(command) > 1:
|
|
56
|
+
args = command[1:]
|
|
57
|
+
else:
|
|
58
|
+
args = []
|
|
59
|
+
d = getProcessOutput(command[0], args, env=environ)
|
|
60
|
+
d.addCallback(response_handler)
|
|
61
|
+
return d
|
|
62
|
+
|
|
63
|
+
def shell_process(self, executable, args=None, env=None,
|
|
64
|
+
protocol=None, usePTY=True,
|
|
65
|
+
line_handler=None, exit_handler=None, name=None):
|
|
66
|
+
if not name:
|
|
67
|
+
name = executable
|
|
68
|
+
|
|
69
|
+
if protocol:
|
|
70
|
+
client = protocol()
|
|
71
|
+
elif line_handler:
|
|
72
|
+
usePTY = True
|
|
73
|
+
client = ProcessClient(
|
|
74
|
+
exit_handler=exit_handler,
|
|
75
|
+
line_handler=line_handler,
|
|
76
|
+
name=name
|
|
77
|
+
)
|
|
78
|
+
else:
|
|
79
|
+
raise AttributeError("Either protocol or line_handler must be provided")
|
|
80
|
+
|
|
81
|
+
self._shell_processes[name] = client
|
|
82
|
+
if not args:
|
|
83
|
+
args = []
|
|
84
|
+
if not len(args) or args[0] != executable:
|
|
85
|
+
args.insert(0, executable)
|
|
86
|
+
self.reactor.spawnProcess(client, executable, args=args, env=env, usePTY=usePTY)
|
|
87
|
+
|
|
88
|
+
def stop(self):
|
|
89
|
+
super(BaseShellMixin, self).stop()
|
|
90
|
+
for name, process in self._shell_processes.items():
|
|
91
|
+
try:
|
|
92
|
+
process.transport.signalProcess('TERM')
|
|
93
|
+
process.transport.loseConnection()
|
|
94
|
+
self.log.info(f"Terminated child process {name}")
|
|
95
|
+
except ProcessExitedAlready:
|
|
96
|
+
self.log.info(f"Child process {name} not running")
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
from os import environ
|
|
4
|
-
from twisted.internet.utils import getProcessOutput
|
|
5
|
-
from .basemixin import BaseMixin
|
|
6
|
-
from .config import ConfigMixin
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class BaseShellMixin(ConfigMixin, BaseMixin):
|
|
10
|
-
# def __init__(self, *args, **kwargs):
|
|
11
|
-
# self._shell_processes = {}
|
|
12
|
-
# super(BaseShellMixin, self).__init__(self, *args, **kwargs)
|
|
13
|
-
|
|
14
|
-
def _shell_execute(self, command, response_handler):
|
|
15
|
-
if len(command) > 1:
|
|
16
|
-
args = command[1:]
|
|
17
|
-
else:
|
|
18
|
-
args = []
|
|
19
|
-
d = getProcessOutput(command[0], args, env=environ)
|
|
20
|
-
d.addCallback(response_handler)
|
|
21
|
-
return d
|
|
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
|
{ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs_linuxnode_core.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs_linuxnode_core.egg-info/requires.txt
RENAMED
|
File without changes
|
{ebs-linuxnode-core-3.1.2 → ebs-linuxnode-core-3.1.4}/ebs_linuxnode_core.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|