primitive 0.2.12__py3-none-any.whl → 0.2.13__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.
- primitive/__about__.py +1 -1
- primitive/daemons/actions.py +37 -6
- primitive/daemons/launch_agents.py +8 -18
- primitive/daemons/launch_service.py +6 -13
- primitive/utils/daemons.py +1 -1
- {primitive-0.2.12.dist-info → primitive-0.2.13.dist-info}/METADATA +1 -1
- {primitive-0.2.12.dist-info → primitive-0.2.13.dist-info}/RECORD +10 -10
- {primitive-0.2.12.dist-info → primitive-0.2.13.dist-info}/WHEEL +0 -0
- {primitive-0.2.12.dist-info → primitive-0.2.13.dist-info}/entry_points.txt +0 -0
- {primitive-0.2.12.dist-info → primitive-0.2.13.dist-info}/licenses/LICENSE.txt +0 -0
primitive/__about__.py
CHANGED
primitive/daemons/actions.py
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
import platform
|
2
|
+
import subprocess
|
2
3
|
import typing
|
3
|
-
from
|
4
|
+
from pathlib import Path
|
5
|
+
from typing import Dict, List, Optional
|
4
6
|
|
5
7
|
if typing.TYPE_CHECKING:
|
6
8
|
from ..client import Primitive
|
7
9
|
|
10
|
+
from ..utils.daemons import Daemon
|
8
11
|
from .launch_agents import LaunchAgent
|
9
12
|
from .launch_service import LaunchService
|
10
|
-
|
13
|
+
|
14
|
+
HOME_DIRECTORY = Path.home()
|
15
|
+
PRIMITIVE_BINARY_PATH = Path(HOME_DIRECTORY / ".pyenv" / "shims" / "primitive")
|
11
16
|
|
12
17
|
|
13
18
|
class Daemons:
|
@@ -15,16 +20,42 @@ class Daemons:
|
|
15
20
|
self.primitive: Primitive = primitive
|
16
21
|
self.os_family = platform.system()
|
17
22
|
|
23
|
+
found_primitive_binary_path = PRIMITIVE_BINARY_PATH
|
24
|
+
if not PRIMITIVE_BINARY_PATH.exists():
|
25
|
+
result = subprocess.run(["which", "primitive"], capture_output=True)
|
26
|
+
if result.returncode == 0:
|
27
|
+
found_primitive_binary_path = result.stdout.decode().rstrip("\n")
|
28
|
+
else:
|
29
|
+
raise Exception(
|
30
|
+
f"primitive binary not found at {PRIMITIVE_BINARY_PATH}"
|
31
|
+
)
|
32
|
+
|
33
|
+
base_primitive_command = f'/bin/sh -lc "{found_primitive_binary_path} "'
|
34
|
+
|
18
35
|
match self.os_family:
|
19
36
|
case "Darwin":
|
20
37
|
self.daemons: Dict[str, Daemon] = {
|
21
|
-
"agent": LaunchAgent(
|
22
|
-
|
38
|
+
"agent": LaunchAgent(
|
39
|
+
"tech.primitive.agent",
|
40
|
+
executable=str(found_primitive_binary_path),
|
41
|
+
command="agent --debug",
|
42
|
+
),
|
43
|
+
"monitor": LaunchAgent(
|
44
|
+
"tech.primitive.monitor",
|
45
|
+
executable=str(found_primitive_binary_path),
|
46
|
+
command="monitor --debug",
|
47
|
+
),
|
23
48
|
}
|
24
49
|
case "Linux":
|
25
50
|
self.daemons: Dict[str, Daemon] = {
|
26
|
-
"agent": LaunchService(
|
27
|
-
|
51
|
+
"agent": LaunchService(
|
52
|
+
"tech.primitive.agent",
|
53
|
+
command=f"{base_primitive_command} agent --debug",
|
54
|
+
),
|
55
|
+
"monitor": LaunchService(
|
56
|
+
"tech.primitive.monitor",
|
57
|
+
command=f"{base_primitive_command} monitor --debug",
|
58
|
+
),
|
28
59
|
}
|
29
60
|
case _:
|
30
61
|
raise NotImplementedError(f"{self.os_family} is not supported.")
|
@@ -1,18 +1,21 @@
|
|
1
1
|
import os
|
2
|
-
from pathlib import Path
|
3
2
|
import subprocess
|
3
|
+
from pathlib import Path
|
4
|
+
|
4
5
|
from loguru import logger
|
6
|
+
|
5
7
|
from ..utils.daemons import Daemon
|
6
8
|
|
7
9
|
HOME_DIRECTORY = Path.home()
|
8
10
|
CURRENT_USER = str(HOME_DIRECTORY.expanduser()).lstrip("/Users/")
|
9
|
-
PRIMITIVE_BINARY_PATH = Path(HOME_DIRECTORY / ".pyenv" / "shims" / "primitive")
|
10
11
|
|
11
12
|
|
12
13
|
class LaunchAgent(Daemon):
|
13
|
-
def __init__(self, label: str):
|
14
|
+
def __init__(self, label: str, executable: str, command: str):
|
14
15
|
self.label = label
|
15
16
|
self.name = label.split(".")[-1]
|
17
|
+
self.executable = executable
|
18
|
+
self.command = command
|
16
19
|
|
17
20
|
@property
|
18
21
|
def file_path(self) -> Path:
|
@@ -22,10 +25,6 @@ class LaunchAgent(Daemon):
|
|
22
25
|
def logs(self) -> Path:
|
23
26
|
return Path(HOME_DIRECTORY / "Library" / "Logs" / f"{self.label}.log")
|
24
27
|
|
25
|
-
@property
|
26
|
-
def cmd(self) -> str:
|
27
|
-
return self.label.split(".")[-1]
|
28
|
-
|
29
28
|
def stop(self, unload: bool = True) -> bool:
|
30
29
|
try:
|
31
30
|
stop_existing_process = f"launchctl stop {self.label}"
|
@@ -107,15 +106,6 @@ class LaunchAgent(Daemon):
|
|
107
106
|
self.file_path.parent.mkdir(parents=True, exist_ok=True)
|
108
107
|
self.file_path.touch()
|
109
108
|
|
110
|
-
found_primitive_binary_path = PRIMITIVE_BINARY_PATH
|
111
|
-
if not PRIMITIVE_BINARY_PATH.exists():
|
112
|
-
result = subprocess.run(["which", "primitive"], capture_output=True)
|
113
|
-
if result.returncode == 0:
|
114
|
-
found_primitive_binary_path = result.stdout.decode().rstrip("\n")
|
115
|
-
else:
|
116
|
-
logger.error("primitive binary not found")
|
117
|
-
return False
|
118
|
-
|
119
109
|
self.file_path.write_text(
|
120
110
|
f"""<?xml version="1.0" encoding="UTF-8"?>
|
121
111
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
@@ -134,8 +124,8 @@ class LaunchAgent(Daemon):
|
|
134
124
|
</array>
|
135
125
|
<key>ProgramArguments</key>
|
136
126
|
<array>
|
137
|
-
<string>{
|
138
|
-
<string>{self.
|
127
|
+
<string>{self.executable}</string>
|
128
|
+
<string>{self.command}</string>
|
139
129
|
</array>
|
140
130
|
<key>RunAtLoad</key>
|
141
131
|
<true/>
|
@@ -1,18 +1,20 @@
|
|
1
|
-
import os
|
2
1
|
import configparser
|
2
|
+
import os
|
3
3
|
import subprocess
|
4
4
|
from pathlib import Path
|
5
|
+
|
5
6
|
from loguru import logger
|
7
|
+
|
6
8
|
from ..utils.daemons import Daemon
|
7
9
|
|
8
10
|
HOME_DIRECTORY = Path.home()
|
9
|
-
PRIMITIVE_BINARY_PATH = Path(HOME_DIRECTORY / ".pyenv" / "shims" / "primitive")
|
10
11
|
|
11
12
|
|
12
13
|
class LaunchService(Daemon):
|
13
|
-
def __init__(self, label: str):
|
14
|
+
def __init__(self, label: str, command: str):
|
14
15
|
self.label = label
|
15
16
|
self.name = label.split(".")[-1]
|
17
|
+
self.command = command
|
16
18
|
|
17
19
|
@property
|
18
20
|
def service_name(self) -> str:
|
@@ -119,17 +121,8 @@ class LaunchService(Daemon):
|
|
119
121
|
"After": "network.target",
|
120
122
|
}
|
121
123
|
|
122
|
-
found_primitive_binary_path = PRIMITIVE_BINARY_PATH
|
123
|
-
if not PRIMITIVE_BINARY_PATH.exists():
|
124
|
-
result = subprocess.run(["which", "primitive"], capture_output=True)
|
125
|
-
if result.returncode == 0:
|
126
|
-
found_primitive_binary_path = result.stdout.decode().rstrip("\n")
|
127
|
-
else:
|
128
|
-
print("primitive binary not found")
|
129
|
-
return False
|
130
|
-
|
131
124
|
config["Service"] = {
|
132
|
-
"ExecStart":
|
125
|
+
"ExecStart": self.command,
|
133
126
|
"Restart": "always",
|
134
127
|
"StandardError": f"append:{self.logs}",
|
135
128
|
"StandardOutput": f"append:{self.logs}",
|
primitive/utils/daemons.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: primitive
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.13
|
4
4
|
Project-URL: Documentation, https://github.com//primitivecorp/primitive-cli#readme
|
5
5
|
Project-URL: Issues, https://github.com//primitivecorp/primitive-cli/issues
|
6
6
|
Project-URL: Source, https://github.com//primitivecorp/primitive-cli
|
@@ -1,4 +1,4 @@
|
|
1
|
-
primitive/__about__.py,sha256=
|
1
|
+
primitive/__about__.py,sha256=bGWt1PkABewYSRyq23zRxqOW2ES-H58OSO6OmpHi7ac,130
|
2
2
|
primitive/__init__.py,sha256=bwKdgggKNVssJFVPfKSxqFMz4IxSr54WWbmiZqTMPNI,106
|
3
3
|
primitive/cli.py,sha256=g7EtHI9MATAB0qQu5w-WzbXtxz_8zu8z5E7sETmMkKU,2509
|
4
4
|
primitive/client.py,sha256=h8WZVnQylVe0vbpuyC8YZHl2JyITSPC-1HbUcmrE5pc,3623
|
@@ -13,10 +13,10 @@ primitive/auth/commands.py,sha256=2z5u5xX64n0yILucx9emtWh3uQXLvs2QQQQIldZGr94,23
|
|
13
13
|
primitive/auth/graphql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
14
|
primitive/auth/graphql/queries.py,sha256=jhrr_VFzHIn8vcVprMIzUx7V4kkWYdR6CKMKPoVFv60,180
|
15
15
|
primitive/daemons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
|
-
primitive/daemons/actions.py,sha256=
|
16
|
+
primitive/daemons/actions.py,sha256=jUE2DSNI5GDbbAZiGaauwfh50UQZf_uDLqpZLEwDq6w,3292
|
17
17
|
primitive/daemons/commands.py,sha256=Xt4qFymNrDLdHJhRnEH_4Re-2xX6w1OT-chV9k7dFCs,2670
|
18
|
-
primitive/daemons/launch_agents.py,sha256=
|
19
|
-
primitive/daemons/launch_service.py,sha256=
|
18
|
+
primitive/daemons/launch_agents.py,sha256=VQ-c9PVTOr3JVt2jfLxIPDS1glKyBM2oDAzSUsFP9_A,7455
|
19
|
+
primitive/daemons/launch_service.py,sha256=JA2kj1obCzu9sGmLFUMdEVKI-aj018b_tZBor0wVJSQ,7531
|
20
20
|
primitive/daemons/ui.py,sha256=Af3OJWJ0jdGlb1nfA5yaGYdhBEqqpM8zP2U2vUQdCbw,1236
|
21
21
|
primitive/db/base.py,sha256=mH7f2d_jiyxJSSx9Gk53QBXRa3LiKBsBjkFgvmtH1WA,83
|
22
22
|
primitive/db/models.py,sha256=GfnJdAq4Tb68CI4BKAuJDZVqioGavveaAHbCPeLNngw,2840
|
@@ -90,14 +90,14 @@ primitive/utils/auth.py,sha256=uBIZNPF2CpbaPV2UMi6eWVUKghV6WIm-pG3-UM29bNs,1465
|
|
90
90
|
primitive/utils/cache.py,sha256=FHGmVWYLJFQOazpXXcEwI0YJEZbdkgG39nOLdOv6VNk,1575
|
91
91
|
primitive/utils/chunk_size.py,sha256=PAuVuirUTA9oRXyjo1c6MWxo31WVBRkWMuWw-AS58Bw,2914
|
92
92
|
primitive/utils/config.py,sha256=DlFM5Nglo22WPtbpZSVtH7NX-PTMaKYlcrUE7GPRG4c,1058
|
93
|
-
primitive/utils/daemons.py,sha256=
|
93
|
+
primitive/utils/daemons.py,sha256=mSoSHitiGfS4KYAEK9sKsiv_YcACHKgY3qISnDpUUIE,1086
|
94
94
|
primitive/utils/exceptions.py,sha256=DrYHTcCAJGC7cCUwOx_FmdlVLWRdpzvDvpLb82heppE,311
|
95
95
|
primitive/utils/memory_size.py,sha256=4xfha21kW82nFvOTtDFx9Jk2ZQoEhkfXii-PGNTpIUk,3058
|
96
96
|
primitive/utils/printer.py,sha256=f1XUpqi5dkTL3GWvYRUGlSwtj2IxU1q745T4Fxo7Tn4,370
|
97
97
|
primitive/utils/shell.py,sha256=jWzb7ky7p987dJas6ZvarK3IJNZ5cwBXcryRWb9Uh6U,2072
|
98
98
|
primitive/utils/text.py,sha256=XiESMnlhjQ534xE2hMNf08WehE1SKaYFRNih0MmnK0k,829
|
99
|
-
primitive-0.2.
|
100
|
-
primitive-0.2.
|
101
|
-
primitive-0.2.
|
102
|
-
primitive-0.2.
|
103
|
-
primitive-0.2.
|
99
|
+
primitive-0.2.13.dist-info/METADATA,sha256=Zq5jWlNGydETK3dKcPdCw0yUZsnJkwCsxuRq1LC4fnM,3733
|
100
|
+
primitive-0.2.13.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
101
|
+
primitive-0.2.13.dist-info/entry_points.txt,sha256=p1K8DMCWka5FqLlqP1sPek5Uovy9jq8u51gUsP-z334,48
|
102
|
+
primitive-0.2.13.dist-info/licenses/LICENSE.txt,sha256=B8kmQMJ2sxYygjCLBk770uacaMci4mPSoJJ8WoDBY_c,1098
|
103
|
+
primitive-0.2.13.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|