ominfra 0.0.0.dev126__py3-none-any.whl → 0.0.0.dev128__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. ominfra/clouds/aws/auth.py +1 -1
  2. ominfra/deploy/_executor.py +1 -1
  3. ominfra/deploy/poly/_main.py +1 -1
  4. ominfra/pyremote/_runcommands.py +1 -1
  5. ominfra/scripts/journald2aws.py +2 -2
  6. ominfra/scripts/supervisor.py +4736 -4166
  7. ominfra/supervisor/configs.py +34 -11
  8. ominfra/supervisor/context.py +7 -345
  9. ominfra/supervisor/dispatchers.py +21 -324
  10. ominfra/supervisor/dispatchersimpl.py +343 -0
  11. ominfra/supervisor/groups.py +33 -111
  12. ominfra/supervisor/groupsimpl.py +86 -0
  13. ominfra/supervisor/inject.py +45 -20
  14. ominfra/supervisor/main.py +3 -3
  15. ominfra/supervisor/pipes.py +85 -0
  16. ominfra/supervisor/poller.py +42 -38
  17. ominfra/supervisor/privileges.py +65 -0
  18. ominfra/supervisor/process.py +6 -742
  19. ominfra/supervisor/processimpl.py +516 -0
  20. ominfra/supervisor/setup.py +38 -0
  21. ominfra/supervisor/setupimpl.py +262 -0
  22. ominfra/supervisor/spawning.py +32 -0
  23. ominfra/supervisor/spawningimpl.py +350 -0
  24. ominfra/supervisor/supervisor.py +67 -84
  25. ominfra/supervisor/types.py +101 -47
  26. ominfra/supervisor/utils/__init__.py +0 -0
  27. ominfra/supervisor/utils/collections.py +52 -0
  28. ominfra/supervisor/utils/diag.py +31 -0
  29. ominfra/supervisor/utils/fds.py +46 -0
  30. ominfra/supervisor/utils/fs.py +47 -0
  31. ominfra/supervisor/utils/os.py +45 -0
  32. ominfra/supervisor/utils/ostypes.py +9 -0
  33. ominfra/supervisor/utils/signals.py +60 -0
  34. ominfra/supervisor/utils/strings.py +105 -0
  35. ominfra/supervisor/utils/users.py +67 -0
  36. {ominfra-0.0.0.dev126.dist-info → ominfra-0.0.0.dev128.dist-info}/METADATA +3 -3
  37. {ominfra-0.0.0.dev126.dist-info → ominfra-0.0.0.dev128.dist-info}/RECORD +41 -25
  38. ominfra/supervisor/datatypes.py +0 -175
  39. ominfra/supervisor/signals.py +0 -52
  40. ominfra/supervisor/utils.py +0 -206
  41. {ominfra-0.0.0.dev126.dist-info → ominfra-0.0.0.dev128.dist-info}/LICENSE +0 -0
  42. {ominfra-0.0.0.dev126.dist-info → ominfra-0.0.0.dev128.dist-info}/WHEEL +0 -0
  43. {ominfra-0.0.0.dev126.dist-info → ominfra-0.0.0.dev128.dist-info}/entry_points.txt +0 -0
  44. {ominfra-0.0.0.dev126.dist-info → ominfra-0.0.0.dev128.dist-info}/top_level.txt +0 -0
@@ -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))