ominfra 0.0.0.dev7__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.
Files changed (50) hide show
  1. ominfra-0.0.0.dev7/LICENSE +21 -0
  2. ominfra-0.0.0.dev7/MANIFEST.in +1 -0
  3. ominfra-0.0.0.dev7/PKG-INFO +18 -0
  4. ominfra-0.0.0.dev7/README.rst +1 -0
  5. ominfra-0.0.0.dev7/ominfra/__about__.py +27 -0
  6. ominfra-0.0.0.dev7/ominfra/__init__.py +0 -0
  7. ominfra-0.0.0.dev7/ominfra/bootstrap/__init__.py +0 -0
  8. ominfra-0.0.0.dev7/ominfra/bootstrap/bootstrap.py +8 -0
  9. ominfra-0.0.0.dev7/ominfra/cmds.py +83 -0
  10. ominfra-0.0.0.dev7/ominfra/deploy/__init__.py +0 -0
  11. ominfra-0.0.0.dev7/ominfra/deploy/_executor.py +1036 -0
  12. ominfra-0.0.0.dev7/ominfra/deploy/configs.py +19 -0
  13. ominfra-0.0.0.dev7/ominfra/deploy/executor/__init__.py +1 -0
  14. ominfra-0.0.0.dev7/ominfra/deploy/executor/base.py +115 -0
  15. ominfra-0.0.0.dev7/ominfra/deploy/executor/concerns/__init__.py +0 -0
  16. ominfra-0.0.0.dev7/ominfra/deploy/executor/concerns/dirs.py +28 -0
  17. ominfra-0.0.0.dev7/ominfra/deploy/executor/concerns/nginx.py +47 -0
  18. ominfra-0.0.0.dev7/ominfra/deploy/executor/concerns/repo.py +17 -0
  19. ominfra-0.0.0.dev7/ominfra/deploy/executor/concerns/supervisor.py +46 -0
  20. ominfra-0.0.0.dev7/ominfra/deploy/executor/concerns/systemd.py +88 -0
  21. ominfra-0.0.0.dev7/ominfra/deploy/executor/concerns/user.py +25 -0
  22. ominfra-0.0.0.dev7/ominfra/deploy/executor/concerns/venv.py +22 -0
  23. ominfra-0.0.0.dev7/ominfra/deploy/executor/main.py +119 -0
  24. ominfra-0.0.0.dev7/ominfra/deploy/poly/__init__.py +1 -0
  25. ominfra-0.0.0.dev7/ominfra/deploy/poly/_main.py +725 -0
  26. ominfra-0.0.0.dev7/ominfra/deploy/poly/base.py +179 -0
  27. ominfra-0.0.0.dev7/ominfra/deploy/poly/configs.py +38 -0
  28. ominfra-0.0.0.dev7/ominfra/deploy/poly/deploy.py +25 -0
  29. ominfra-0.0.0.dev7/ominfra/deploy/poly/main.py +18 -0
  30. ominfra-0.0.0.dev7/ominfra/deploy/poly/nginx.py +60 -0
  31. ominfra-0.0.0.dev7/ominfra/deploy/poly/repo.py +41 -0
  32. ominfra-0.0.0.dev7/ominfra/deploy/poly/runtime.py +39 -0
  33. ominfra-0.0.0.dev7/ominfra/deploy/poly/site.py +11 -0
  34. ominfra-0.0.0.dev7/ominfra/deploy/poly/supervisor.py +64 -0
  35. ominfra-0.0.0.dev7/ominfra/deploy/poly/venv.py +52 -0
  36. ominfra-0.0.0.dev7/ominfra/deploy/remote.py +91 -0
  37. ominfra-0.0.0.dev7/ominfra/pyremote/__init__.py +0 -0
  38. ominfra-0.0.0.dev7/ominfra/pyremote/_runcommands.py +824 -0
  39. ominfra-0.0.0.dev7/ominfra/pyremote/bootstrap.py +149 -0
  40. ominfra-0.0.0.dev7/ominfra/pyremote/runcommands.py +56 -0
  41. ominfra-0.0.0.dev7/ominfra/ssh.py +191 -0
  42. ominfra-0.0.0.dev7/ominfra/tools/__init__.py +0 -0
  43. ominfra-0.0.0.dev7/ominfra/tools/listresources.py +256 -0
  44. ominfra-0.0.0.dev7/ominfra.egg-info/PKG-INFO +18 -0
  45. ominfra-0.0.0.dev7/ominfra.egg-info/SOURCES.txt +48 -0
  46. ominfra-0.0.0.dev7/ominfra.egg-info/dependency_links.txt +1 -0
  47. ominfra-0.0.0.dev7/ominfra.egg-info/requires.txt +7 -0
  48. ominfra-0.0.0.dev7/ominfra.egg-info/top_level.txt +1 -0
  49. ominfra-0.0.0.dev7/pyproject.toml +45 -0
  50. ominfra-0.0.0.dev7/setup.cfg +4 -0
@@ -0,0 +1,21 @@
1
+ Copyright 2023- wrmsr
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
4
+ following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
7
+ disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
10
+ disclaimer in the documentation and/or other materials provided with the distribution.
11
+
12
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
13
+ derived from this software without specific prior written permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
16
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
20
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1 @@
1
+ global-exclude **/conftest.py
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.1
2
+ Name: ominfra
3
+ Version: 0.0.0.dev7
4
+ Summary: ominfra
5
+ Author: wrmsr
6
+ License: BSD-3-Clause
7
+ Project-URL: source, https://github.com/wrmsr/omlish
8
+ Classifier: License :: OSI Approved :: BSD License
9
+ Classifier: Development Status :: 2 - Pre-Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Operating System :: POSIX
13
+ Requires-Python: >=3.12
14
+ License-File: LICENSE
15
+ Requires-Dist: omlish==0.0.0.dev7
16
+ Provides-Extra: ssh
17
+ Requires-Dist: paramiko>=3.4; extra == "ssh"
18
+ Requires-Dist: asyncssh>=2.16; python_version < "3.13" and extra == "ssh"
@@ -0,0 +1 @@
1
+ *omlish*
@@ -0,0 +1,27 @@
1
+ from omlish.__about__ import ProjectBase
2
+ from omlish.__about__ import SetuptoolsBase
3
+ from omlish.__about__ import __version__
4
+
5
+
6
+ class Project(ProjectBase):
7
+ name = 'ominfra'
8
+ description = 'ominfra'
9
+
10
+ dependencies = [
11
+ f'omlish == {__version__}',
12
+ ]
13
+
14
+ optional_dependencies = {
15
+ 'ssh': [
16
+ 'paramiko >= 3.4', # !! LGPL
17
+
18
+ "asyncssh >= 2.16; python_version < '3.13'", # cffi
19
+ ],
20
+ }
21
+
22
+
23
+ class Setuptools(SetuptoolsBase):
24
+ find_packages = {
25
+ 'include': ['ominfra', 'ominfra.*'],
26
+ 'exclude': [*SetuptoolsBase.find_packages['exclude']],
27
+ }
File without changes
File without changes
@@ -0,0 +1,8 @@
1
+ """
2
+ Jobs:
3
+ - globals
4
+ - pkgs
5
+ - pyenv
6
+ - tailscale
7
+ - docker
8
+ """
@@ -0,0 +1,83 @@
1
+ """
2
+ TODO:
3
+ - timeout
4
+ - stream in/out/err
5
+ - *sessions*
6
+ - anyio
7
+ """
8
+ import abc
9
+ import asyncio
10
+ import io
11
+ import typing as ta
12
+
13
+ from omlish import check
14
+ from omlish import dataclasses as dc
15
+ from omlish import lang
16
+
17
+
18
+ class CommandRunner(lang.Abstract):
19
+ @dc.dataclass(frozen=True)
20
+ class Command:
21
+ args: ta.Sequence[str]
22
+ in_: bytes | None = None
23
+
24
+ @dc.dataclass(frozen=True)
25
+ class Result:
26
+ rc: int
27
+ out: bytes
28
+ err: bytes
29
+
30
+ def check(self) -> ta.Self:
31
+ if self.rc != 0:
32
+ raise CommandRunner.ReturnCodeError(self)
33
+ return self
34
+
35
+ class ReturnCodeError(Exception):
36
+ def __init__(self, result: 'CommandRunner.Result') -> None:
37
+ super().__init__(f'Bad return code: {result.rc}', result)
38
+ self.result = result
39
+
40
+ @abc.abstractmethod
41
+ async def run_command(self, cmd: Command) -> Result:
42
+ raise NotImplementedError
43
+
44
+
45
+ class LocalCommandRunner(CommandRunner):
46
+ @dc.dataclass(frozen=True)
47
+ class Config:
48
+ cwd: str | None = None
49
+
50
+ def __init__(self, cfg: Config = Config()) -> None:
51
+ super().__init__()
52
+ self._cfg = check.isinstance(cfg, LocalCommandRunner.Config)
53
+
54
+ async def run_command(self, cmd: CommandRunner.Command) -> CommandRunner.Result:
55
+ proc = await asyncio.create_subprocess_exec(
56
+ *cmd.args,
57
+ stdin=io.BytesIO(cmd.in_) if cmd.in_ is not None else None,
58
+ stdout=asyncio.subprocess.PIPE,
59
+ stderr=asyncio.subprocess.PIPE,
60
+ **(dict(cwd=self._cfg.cwd) if self._cfg.cwd is not None else {}), # type: ignore
61
+ )
62
+
63
+ out, err = await proc.communicate()
64
+
65
+ return CommandRunner.Result(
66
+ rc=check.not_none(proc.returncode),
67
+ out=out,
68
+ err=err,
69
+ )
70
+
71
+
72
+ async def _a_main() -> None:
73
+ cmd = CommandRunner.Command(
74
+ ['ls', '-al'],
75
+ )
76
+
77
+ rc = await LocalCommandRunner().run_command(cmd)
78
+ check.equal(rc.rc, 0)
79
+ print(rc.out.decode())
80
+
81
+
82
+ if __name__ == '__main__':
83
+ asyncio.run(_a_main())
File without changes