ominfra 0.0.0.dev127__py3-none-any.whl → 0.0.0.dev129__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.
- ominfra/deploy/_executor.py +24 -0
- ominfra/pyremote/_runcommands.py +24 -0
- ominfra/scripts/journald2aws.py +24 -0
- ominfra/scripts/supervisor.py +1320 -1225
- ominfra/supervisor/configs.py +34 -11
- ominfra/supervisor/dispatchers.py +7 -6
- ominfra/supervisor/dispatchersimpl.py +29 -22
- ominfra/supervisor/groups.py +1 -1
- ominfra/supervisor/groupsimpl.py +2 -2
- ominfra/supervisor/inject.py +22 -17
- ominfra/supervisor/io.py +82 -0
- ominfra/supervisor/main.py +6 -7
- ominfra/supervisor/pipes.py +15 -13
- ominfra/supervisor/poller.py +36 -35
- ominfra/supervisor/{processes.py → process.py} +2 -1
- ominfra/supervisor/{processesimpl.py → processimpl.py} +42 -54
- ominfra/supervisor/setup.py +1 -1
- ominfra/supervisor/setupimpl.py +4 -3
- ominfra/supervisor/signals.py +56 -50
- ominfra/supervisor/spawning.py +2 -1
- ominfra/supervisor/spawningimpl.py +24 -21
- ominfra/supervisor/supervisor.py +72 -134
- ominfra/supervisor/types.py +45 -34
- ominfra/supervisor/utils/__init__.py +0 -0
- ominfra/supervisor/utils/diag.py +31 -0
- ominfra/supervisor/utils/fds.py +46 -0
- ominfra/supervisor/utils/fs.py +47 -0
- ominfra/supervisor/utils/os.py +45 -0
- ominfra/supervisor/utils/ostypes.py +9 -0
- ominfra/supervisor/utils/signals.py +60 -0
- ominfra/supervisor/utils/strings.py +105 -0
- ominfra/supervisor/{users.py → utils/users.py} +11 -8
- {ominfra-0.0.0.dev127.dist-info → ominfra-0.0.0.dev129.dist-info}/METADATA +3 -3
- {ominfra-0.0.0.dev127.dist-info → ominfra-0.0.0.dev129.dist-info}/RECORD +39 -33
- ominfra/supervisor/context.py +0 -84
- ominfra/supervisor/datatypes.py +0 -113
- ominfra/supervisor/utils.py +0 -206
- /ominfra/supervisor/{collections.py → utils/collections.py} +0 -0
- {ominfra-0.0.0.dev127.dist-info → ominfra-0.0.0.dev129.dist-info}/LICENSE +0 -0
- {ominfra-0.0.0.dev127.dist-info → ominfra-0.0.0.dev129.dist-info}/WHEEL +0 -0
- {ominfra-0.0.0.dev127.dist-info → ominfra-0.0.0.dev129.dist-info}/entry_points.txt +0 -0
- {ominfra-0.0.0.dev127.dist-info → ominfra-0.0.0.dev129.dist-info}/top_level.txt +0 -0
ominfra/supervisor/utils.py
DELETED
@@ -1,206 +0,0 @@
|
|
1
|
-
# ruff: noqa: UP006 UP007
|
2
|
-
import errno
|
3
|
-
import os
|
4
|
-
import sys
|
5
|
-
import tempfile
|
6
|
-
import types
|
7
|
-
import typing as ta
|
8
|
-
|
9
|
-
from .signals import sig_name
|
10
|
-
|
11
|
-
|
12
|
-
T = ta.TypeVar('T')
|
13
|
-
|
14
|
-
|
15
|
-
##
|
16
|
-
|
17
|
-
|
18
|
-
def as_bytes(s: ta.Union[str, bytes], encoding: str = 'utf8') -> bytes:
|
19
|
-
if isinstance(s, bytes):
|
20
|
-
return s
|
21
|
-
else:
|
22
|
-
return s.encode(encoding)
|
23
|
-
|
24
|
-
|
25
|
-
def as_string(s: ta.Union[str, bytes], encoding: str = 'utf8') -> str:
|
26
|
-
if isinstance(s, str):
|
27
|
-
return s
|
28
|
-
else:
|
29
|
-
return s.decode(encoding)
|
30
|
-
|
31
|
-
|
32
|
-
def find_prefix_at_end(haystack: bytes, needle: bytes) -> int:
|
33
|
-
l = len(needle) - 1
|
34
|
-
while l and not haystack.endswith(needle[:l]):
|
35
|
-
l -= 1
|
36
|
-
return l
|
37
|
-
|
38
|
-
|
39
|
-
##
|
40
|
-
|
41
|
-
|
42
|
-
def compact_traceback() -> ta.Tuple[
|
43
|
-
ta.Tuple[str, str, int],
|
44
|
-
ta.Type[BaseException],
|
45
|
-
BaseException,
|
46
|
-
types.TracebackType,
|
47
|
-
]:
|
48
|
-
t, v, tb = sys.exc_info()
|
49
|
-
if not tb:
|
50
|
-
raise RuntimeError('No traceback')
|
51
|
-
|
52
|
-
tbinfo = []
|
53
|
-
while tb:
|
54
|
-
tbinfo.append((
|
55
|
-
tb.tb_frame.f_code.co_filename,
|
56
|
-
tb.tb_frame.f_code.co_name,
|
57
|
-
str(tb.tb_lineno),
|
58
|
-
))
|
59
|
-
tb = tb.tb_next
|
60
|
-
|
61
|
-
# just to be safe
|
62
|
-
del tb
|
63
|
-
|
64
|
-
file, function, line = tbinfo[-1]
|
65
|
-
info = ' '.join(['[%s|%s|%s]' % x for x in tbinfo]) # noqa
|
66
|
-
return (file, function, line), t, v, info # type: ignore
|
67
|
-
|
68
|
-
|
69
|
-
class ExitNow(Exception): # noqa
|
70
|
-
pass
|
71
|
-
|
72
|
-
|
73
|
-
def real_exit(code: int) -> None:
|
74
|
-
os._exit(code) # noqa
|
75
|
-
|
76
|
-
|
77
|
-
##
|
78
|
-
|
79
|
-
|
80
|
-
def decode_wait_status(sts: int) -> ta.Tuple[int, str]:
|
81
|
-
"""
|
82
|
-
Decode the status returned by wait() or waitpid().
|
83
|
-
|
84
|
-
Return a tuple (exitstatus, message) where exitstatus is the exit status, or -1 if the process was killed by a
|
85
|
-
signal; and message is a message telling what happened. It is the caller's responsibility to display the message.
|
86
|
-
"""
|
87
|
-
|
88
|
-
if os.WIFEXITED(sts):
|
89
|
-
es = os.WEXITSTATUS(sts) & 0xffff
|
90
|
-
msg = f'exit status {es}'
|
91
|
-
return es, msg
|
92
|
-
elif os.WIFSIGNALED(sts):
|
93
|
-
sig = os.WTERMSIG(sts)
|
94
|
-
msg = f'terminated by {sig_name(sig)}'
|
95
|
-
if hasattr(os, 'WCOREDUMP'):
|
96
|
-
iscore = os.WCOREDUMP(sts)
|
97
|
-
else:
|
98
|
-
iscore = bool(sts & 0x80)
|
99
|
-
if iscore:
|
100
|
-
msg += ' (core dumped)'
|
101
|
-
return -1, msg
|
102
|
-
else:
|
103
|
-
msg = 'unknown termination cause 0x%04x' % sts # noqa
|
104
|
-
return -1, msg
|
105
|
-
|
106
|
-
|
107
|
-
##
|
108
|
-
|
109
|
-
|
110
|
-
def read_fd(fd: int) -> bytes:
|
111
|
-
try:
|
112
|
-
data = os.read(fd, 2 << 16) # 128K
|
113
|
-
except OSError as why:
|
114
|
-
if why.args[0] not in (errno.EWOULDBLOCK, errno.EBADF, errno.EINTR):
|
115
|
-
raise
|
116
|
-
data = b''
|
117
|
-
return data
|
118
|
-
|
119
|
-
|
120
|
-
def try_unlink(path: str) -> bool:
|
121
|
-
try:
|
122
|
-
os.unlink(path)
|
123
|
-
except OSError:
|
124
|
-
return False
|
125
|
-
return True
|
126
|
-
|
127
|
-
|
128
|
-
def close_fd(fd: int) -> bool:
|
129
|
-
try:
|
130
|
-
os.close(fd)
|
131
|
-
except OSError:
|
132
|
-
return False
|
133
|
-
return True
|
134
|
-
|
135
|
-
|
136
|
-
def is_fd_open(fd: int) -> bool:
|
137
|
-
try:
|
138
|
-
n = os.dup(fd)
|
139
|
-
except OSError:
|
140
|
-
return False
|
141
|
-
os.close(n)
|
142
|
-
return True
|
143
|
-
|
144
|
-
|
145
|
-
def get_open_fds(limit: int) -> ta.FrozenSet[int]:
|
146
|
-
return frozenset(filter(is_fd_open, range(limit)))
|
147
|
-
|
148
|
-
|
149
|
-
def mktempfile(suffix: str, prefix: str, dir: str) -> str: # noqa
|
150
|
-
fd, filename = tempfile.mkstemp(suffix, prefix, dir)
|
151
|
-
os.close(fd)
|
152
|
-
return filename
|
153
|
-
|
154
|
-
|
155
|
-
##
|
156
|
-
|
157
|
-
|
158
|
-
def get_path() -> ta.Sequence[str]:
|
159
|
-
"""Return a list corresponding to $PATH, or a default."""
|
160
|
-
|
161
|
-
path = ['/bin', '/usr/bin', '/usr/local/bin']
|
162
|
-
if 'PATH' in os.environ:
|
163
|
-
p = os.environ['PATH']
|
164
|
-
if p:
|
165
|
-
path = p.split(os.pathsep)
|
166
|
-
return path
|
167
|
-
|
168
|
-
|
169
|
-
def normalize_path(v: str) -> str:
|
170
|
-
return os.path.normpath(os.path.abspath(os.path.expanduser(v)))
|
171
|
-
|
172
|
-
|
173
|
-
##
|
174
|
-
|
175
|
-
|
176
|
-
ANSI_ESCAPE_BEGIN = b'\x1b['
|
177
|
-
ANSI_TERMINATORS = (b'H', b'f', b'A', b'B', b'C', b'D', b'R', b's', b'u', b'J', b'K', b'h', b'l', b'p', b'm')
|
178
|
-
|
179
|
-
|
180
|
-
def strip_escapes(s: bytes) -> bytes:
|
181
|
-
"""Remove all ANSI color escapes from the given string."""
|
182
|
-
|
183
|
-
result = b''
|
184
|
-
show = 1
|
185
|
-
i = 0
|
186
|
-
l = len(s)
|
187
|
-
while i < l:
|
188
|
-
if show == 0 and s[i:i + 1] in ANSI_TERMINATORS:
|
189
|
-
show = 1
|
190
|
-
elif show:
|
191
|
-
n = s.find(ANSI_ESCAPE_BEGIN, i)
|
192
|
-
if n == -1:
|
193
|
-
return result + s[i:]
|
194
|
-
else:
|
195
|
-
result = result + s[i:n]
|
196
|
-
i = n
|
197
|
-
show = 0
|
198
|
-
i += 1
|
199
|
-
return result
|
200
|
-
|
201
|
-
|
202
|
-
##
|
203
|
-
|
204
|
-
|
205
|
-
def timeslice(period: int, when: float) -> int:
|
206
|
-
return int(when - (when % period))
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|