ominfra 0.0.0.dev151__py3-none-any.whl → 0.0.0.dev153__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- ominfra/clouds/aws/journald2aws/driver.py +1 -1
- ominfra/manage/bootstrap.py +3 -0
- ominfra/manage/bootstrap_.py +1 -0
- ominfra/manage/commands/interp.py +0 -3
- ominfra/manage/commands/subprocess.py +0 -3
- ominfra/manage/deploy/{command.py → commands.py} +0 -3
- ominfra/manage/deploy/inject.py +2 -2
- ominfra/manage/inject.py +8 -1
- ominfra/manage/main.py +7 -7
- ominfra/manage/remote/_main.py +3 -3
- ominfra/manage/remote/config.py +2 -0
- ominfra/manage/remote/connection.py +48 -0
- ominfra/manage/remote/execution.py +90 -12
- ominfra/manage/remote/inject.py +19 -4
- ominfra/manage/system/__init__.py +0 -0
- ominfra/manage/system/commands.py +24 -0
- ominfra/manage/system/config.py +8 -0
- ominfra/manage/system/inject.py +54 -0
- ominfra/manage/system/packages.py +106 -0
- ominfra/manage/system/types.py +5 -0
- ominfra/scripts/journald2aws.py +68 -68
- ominfra/scripts/manage.py +483 -83
- ominfra/scripts/supervisor.py +157 -157
- ominfra/supervisor/main.py +1 -1
- {ominfra-0.0.0.dev151.dist-info → ominfra-0.0.0.dev153.dist-info}/METADATA +3 -3
- {ominfra-0.0.0.dev151.dist-info → ominfra-0.0.0.dev153.dist-info}/RECORD +30 -24
- {ominfra-0.0.0.dev151.dist-info → ominfra-0.0.0.dev153.dist-info}/LICENSE +0 -0
- {ominfra-0.0.0.dev151.dist-info → ominfra-0.0.0.dev153.dist-info}/WHEEL +0 -0
- {ominfra-0.0.0.dev151.dist-info → ominfra-0.0.0.dev153.dist-info}/entry_points.txt +0 -0
- {ominfra-0.0.0.dev151.dist-info → ominfra-0.0.0.dev153.dist-info}/top_level.txt +0 -0
ominfra/scripts/journald2aws.py
CHANGED
@@ -79,7 +79,7 @@ ConfigMapping = ta.Mapping[str, ta.Any]
|
|
79
79
|
ThreadWorkerT = ta.TypeVar('ThreadWorkerT', bound='ThreadWorker')
|
80
80
|
|
81
81
|
# ../../../../omlish/lite/subprocesses.py
|
82
|
-
SubprocessChannelOption = ta.Literal['pipe', 'stdout', 'devnull']
|
82
|
+
SubprocessChannelOption = ta.Literal['pipe', 'stdout', 'devnull'] # ta.TypeAlias
|
83
83
|
|
84
84
|
|
85
85
|
########################################
|
@@ -1439,73 +1439,6 @@ json_dump_compact: ta.Callable[..., bytes] = functools.partial(json.dump, **JSON
|
|
1439
1439
|
json_dumps_compact: ta.Callable[..., str] = functools.partial(json.dumps, **JSON_COMPACT_KWARGS)
|
1440
1440
|
|
1441
1441
|
|
1442
|
-
########################################
|
1443
|
-
# ../../../../../omlish/lite/pidfile.py
|
1444
|
-
|
1445
|
-
|
1446
|
-
class Pidfile:
|
1447
|
-
def __init__(self, path: str) -> None:
|
1448
|
-
super().__init__()
|
1449
|
-
self._path = path
|
1450
|
-
|
1451
|
-
_f: ta.TextIO
|
1452
|
-
|
1453
|
-
def __repr__(self) -> str:
|
1454
|
-
return f'{self.__class__.__name__}({self._path!r})'
|
1455
|
-
|
1456
|
-
def __enter__(self) -> 'Pidfile':
|
1457
|
-
fd = os.open(self._path, os.O_RDWR | os.O_CREAT, 0o600)
|
1458
|
-
try:
|
1459
|
-
os.set_inheritable(fd, True)
|
1460
|
-
f = os.fdopen(fd, 'r+')
|
1461
|
-
except Exception:
|
1462
|
-
try:
|
1463
|
-
os.close(fd)
|
1464
|
-
except Exception: # noqa
|
1465
|
-
pass
|
1466
|
-
raise
|
1467
|
-
self._f = f
|
1468
|
-
return self
|
1469
|
-
|
1470
|
-
def __exit__(self, exc_type, exc_val, exc_tb):
|
1471
|
-
if hasattr(self, '_f'):
|
1472
|
-
self._f.close()
|
1473
|
-
del self._f
|
1474
|
-
|
1475
|
-
def try_lock(self) -> bool:
|
1476
|
-
try:
|
1477
|
-
fcntl.flock(self._f, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
1478
|
-
return True
|
1479
|
-
except OSError:
|
1480
|
-
return False
|
1481
|
-
|
1482
|
-
def ensure_locked(self) -> None:
|
1483
|
-
if not self.try_lock():
|
1484
|
-
raise RuntimeError('Could not get lock')
|
1485
|
-
|
1486
|
-
def write(self, pid: ta.Optional[int] = None) -> None:
|
1487
|
-
self.ensure_locked()
|
1488
|
-
if pid is None:
|
1489
|
-
pid = os.getpid()
|
1490
|
-
self._f.write(f'{pid}\n')
|
1491
|
-
self._f.flush()
|
1492
|
-
|
1493
|
-
def clear(self) -> None:
|
1494
|
-
self.ensure_locked()
|
1495
|
-
self._f.seek(0)
|
1496
|
-
self._f.truncate()
|
1497
|
-
|
1498
|
-
def read(self) -> int:
|
1499
|
-
if self.try_lock():
|
1500
|
-
raise RuntimeError('Got lock')
|
1501
|
-
self._f.seek(0)
|
1502
|
-
return int(self._f.read())
|
1503
|
-
|
1504
|
-
def kill(self, sig: int = signal.SIGTERM) -> None:
|
1505
|
-
pid = self.read()
|
1506
|
-
os.kill(pid, sig) # FIXME: Still racy
|
1507
|
-
|
1508
|
-
|
1509
1442
|
########################################
|
1510
1443
|
# ../../../../../omlish/lite/reflect.py
|
1511
1444
|
|
@@ -1628,6 +1561,73 @@ def format_num_bytes(num_bytes: int) -> str:
|
|
1628
1561
|
return f'{num_bytes / 1024 ** (len(FORMAT_NUM_BYTES_SUFFIXES) - 1):.2f}{FORMAT_NUM_BYTES_SUFFIXES[-1]}'
|
1629
1562
|
|
1630
1563
|
|
1564
|
+
########################################
|
1565
|
+
# ../../../../../omlish/os/pidfile.py
|
1566
|
+
|
1567
|
+
|
1568
|
+
class Pidfile:
|
1569
|
+
def __init__(self, path: str) -> None:
|
1570
|
+
super().__init__()
|
1571
|
+
self._path = path
|
1572
|
+
|
1573
|
+
_f: ta.TextIO
|
1574
|
+
|
1575
|
+
def __repr__(self) -> str:
|
1576
|
+
return f'{self.__class__.__name__}({self._path!r})'
|
1577
|
+
|
1578
|
+
def __enter__(self) -> 'Pidfile':
|
1579
|
+
fd = os.open(self._path, os.O_RDWR | os.O_CREAT, 0o600)
|
1580
|
+
try:
|
1581
|
+
os.set_inheritable(fd, True)
|
1582
|
+
f = os.fdopen(fd, 'r+')
|
1583
|
+
except Exception:
|
1584
|
+
try:
|
1585
|
+
os.close(fd)
|
1586
|
+
except Exception: # noqa
|
1587
|
+
pass
|
1588
|
+
raise
|
1589
|
+
self._f = f
|
1590
|
+
return self
|
1591
|
+
|
1592
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
1593
|
+
if hasattr(self, '_f'):
|
1594
|
+
self._f.close()
|
1595
|
+
del self._f
|
1596
|
+
|
1597
|
+
def try_lock(self) -> bool:
|
1598
|
+
try:
|
1599
|
+
fcntl.flock(self._f, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
1600
|
+
return True
|
1601
|
+
except OSError:
|
1602
|
+
return False
|
1603
|
+
|
1604
|
+
def ensure_locked(self) -> None:
|
1605
|
+
if not self.try_lock():
|
1606
|
+
raise RuntimeError('Could not get lock')
|
1607
|
+
|
1608
|
+
def write(self, pid: ta.Optional[int] = None) -> None:
|
1609
|
+
self.ensure_locked()
|
1610
|
+
if pid is None:
|
1611
|
+
pid = os.getpid()
|
1612
|
+
self._f.write(f'{pid}\n')
|
1613
|
+
self._f.flush()
|
1614
|
+
|
1615
|
+
def clear(self) -> None:
|
1616
|
+
self.ensure_locked()
|
1617
|
+
self._f.seek(0)
|
1618
|
+
self._f.truncate()
|
1619
|
+
|
1620
|
+
def read(self) -> int:
|
1621
|
+
if self.try_lock():
|
1622
|
+
raise RuntimeError('Got lock')
|
1623
|
+
self._f.seek(0)
|
1624
|
+
return int(self._f.read())
|
1625
|
+
|
1626
|
+
def kill(self, sig: int = signal.SIGTERM) -> None:
|
1627
|
+
pid = self.read()
|
1628
|
+
os.kill(pid, sig) # FIXME: Still racy
|
1629
|
+
|
1630
|
+
|
1631
1631
|
########################################
|
1632
1632
|
# ../../auth.py
|
1633
1633
|
"""
|