primitive 0.1.94__py3-none-any.whl → 0.1.96__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 CHANGED
@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2024-present Dylan Stein <dylan@primitive.tech>
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- __version__ = "0.1.94"
4
+ __version__ = "0.1.96"
@@ -8,6 +8,7 @@ from primitive.__about__ import __version__
8
8
  from primitive.utils.actions import BaseAction
9
9
 
10
10
  from ..utils.cache import get_sources_cache
11
+ from ..utils.exceptions import P_CLI_100
11
12
  from .runner import AgentRunner
12
13
  from .uploader import Uploader
13
14
 
@@ -181,5 +182,11 @@ class Agent(BaseAction):
181
182
  sleep(5)
182
183
  except KeyboardInterrupt:
183
184
  logger.info(" [*] Stopping primitive...")
184
- self.primitive.hardware.check_in_http(is_available=False, is_online=False)
185
+ try:
186
+ self.primitive.hardware.check_in_http(
187
+ is_available=False, is_online=False, stopping_agent=True
188
+ )
189
+ except P_CLI_100 as exception:
190
+ logger.error(" [*] Error stopping primitive.")
191
+ logger.error(str(exception))
185
192
  sys.exit()
primitive/git/actions.py CHANGED
@@ -1,4 +1,5 @@
1
1
  from pathlib import Path
2
+ import shutil
2
3
  from subprocess import run, CalledProcessError, DEVNULL
3
4
 
4
5
  from gql import gql
@@ -51,6 +52,8 @@ class Git(BaseAction):
51
52
  stderr=DEVNULL,
52
53
  )
53
54
  except CalledProcessError:
55
+ # Clean up directory if checkout failed
56
+ shutil.rmtree(path=source_dir)
54
57
  raise Exception("Failed to checkout ref")
55
58
 
56
59
  return source_dir
@@ -17,6 +17,7 @@ from primitive.utils.memory_size import MemorySize
17
17
 
18
18
  from ..utils.auth import guard
19
19
  from ..utils.config import update_config_file
20
+ from ..utils.exceptions import P_CLI_100
20
21
  from .graphql.mutations import (
21
22
  hardware_checkin_mutation,
22
23
  hardware_update_mutation,
@@ -384,6 +385,7 @@ class Hardware(BaseAction):
384
385
  is_available: bool = False,
385
386
  is_online: bool = True,
386
387
  fingerprint: Optional[str] = None,
388
+ stopping_agent: Optional[bool] = False,
387
389
  ):
388
390
  # if no fingerprint supplied from argument try from the host_config
389
391
  if not fingerprint:
@@ -457,9 +459,12 @@ class Hardware(BaseAction):
457
459
  raise Exception(message)
458
460
  return result
459
461
  except client_exceptions.ClientConnectorError as exception:
460
- message = " [*] Failed to check in! "
461
- logger.exception(message)
462
- raise exception
462
+ if not stopping_agent:
463
+ message = " [*] Failed to check in! "
464
+ logger.error(message)
465
+ raise exception
466
+ else:
467
+ raise P_CLI_100
463
468
 
464
469
  @guard
465
470
  def get_hardware_list(
primitive/utils/auth.py CHANGED
@@ -43,6 +43,7 @@ def guard(func):
43
43
  @backoff.on_exception(
44
44
  backoff.expo,
45
45
  (
46
+ ConnectionRefusedError,
46
47
  ClientConnectorError,
47
48
  TransportServerError,
48
49
  ),
@@ -0,0 +1,12 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass
5
+ class P_CLI_100(Exception):
6
+ """Check In Connection Failure while Stopping Agent"""
7
+
8
+ codename: str = "P_CLI_100"
9
+ message: str = "Check In Connection Failure while Stopping Agent"
10
+
11
+ def __str__(self):
12
+ return f"{self.codename}: {self.message}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: primitive
3
- Version: 0.1.94
3
+ Version: 0.1.96
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,9 +1,9 @@
1
- primitive/__about__.py,sha256=KXegEIne06p7p51yURPxgSDL9t-28iyLfXrBT-skS_Q,130
1
+ primitive/__about__.py,sha256=N-WpwYEL915AE9PxudLLops_jEd8RUQcVrUx1AntwYs,130
2
2
  primitive/__init__.py,sha256=bwKdgggKNVssJFVPfKSxqFMz4IxSr54WWbmiZqTMPNI,106
3
3
  primitive/cli.py,sha256=CiI60bG3UZyNFuLTpchr0KeJRG5SALj455Ob11CegGE,2412
4
4
  primitive/client.py,sha256=PPyIQRvKKSqCF9RRF5mJJ4Vqqolpzy1YXqffNLKIvAA,2390
5
5
  primitive/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- primitive/agent/actions.py,sha256=s9hOVKsgjwt7iXnpGOpoR5Ctxh9g7g-g1xu5QjtvPbc,7636
6
+ primitive/agent/actions.py,sha256=4Q6igYx5ILD7euWOJcrmFNR0LjKo4fglrQ5TNJMDm2c,7908
7
7
  primitive/agent/commands.py,sha256=-dVDilELfkGfbZB7qfEPs77Dm1oT62qJj4tsIk4KoxI,254
8
8
  primitive/agent/process.py,sha256=32eoj0W1-LG-9xxeHia-jk9jTah1cnmjCYnvczgXYGU,3538
9
9
  primitive/agent/provision.py,sha256=rmwnro1K5F8mwtd45XAq7RVQmpDWnbBCQ8X_qgWhm3M,1546
@@ -31,7 +31,7 @@ primitive/files/graphql/fragments.py,sha256=II6WHZjzSqX4IELwdiWokqHTKvDq6mMHF5gp
31
31
  primitive/files/graphql/mutations.py,sha256=Da_e6WSp-fsCYVE9A6SGkIQy9WDzjeQycNyHEn7vJqE,935
32
32
  primitive/files/graphql/queries.py,sha256=_ky-IRz928sKeSJuqaggTPxV4CGgmho3OyaAFu1z7nw,397
33
33
  primitive/git/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
- primitive/git/actions.py,sha256=UKzPAK5zw9jKumY0LBcG6vcS1YCCX6tiL6hkSMqnxe0,1636
34
+ primitive/git/actions.py,sha256=7mOhpujYYXGxjtpjsxH-mle-O1WXv1Vvx0bD6LUDGxY,1745
35
35
  primitive/git/commands.py,sha256=sCeSjkRgSEjCEsB5seXgB_h6xfk0KpvMvzMKoRfUbRA,1177
36
36
  primitive/git/graphql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  primitive/git/graphql/queries.py,sha256=I1HGlqBb1lHIAWVSsC8tVY9JdsQ8DJVqs4nqSTcL30M,98
@@ -40,7 +40,7 @@ primitive/graphql/relay.py,sha256=bmij2AjdpURQ6GGVCxwWhauF-r_SxuAU2oJ4sDbLxpI,72
40
40
  primitive/graphql/sdk.py,sha256=DBFH8vw8FAGvRy8_FZc9WcjnwaQDlXmI8fiYmhCg-b0,1458
41
41
  primitive/graphql/utility_fragments.py,sha256=uIjwILC4QtWNyO5vu77VjQf_p0jvP3A9q_6zRq91zqs,303
42
42
  primitive/hardware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
- primitive/hardware/actions.py,sha256=tmsr50UPz_xFXPdeSa89e7NgDlw9vMwqWUUXlFGzmQs,25775
43
+ primitive/hardware/actions.py,sha256=ZX-Wt4sU18u_eJXTV4B7tHo_Izzya3ZxPwIyXr-YJ8U,25957
44
44
  primitive/hardware/android.py,sha256=tu7pBPxWFrIwb_mm5CEdFFf1_veNDOKjOCQg13i_Lh4,2758
45
45
  primitive/hardware/commands.py,sha256=cWl8j0XtkXQtPHtpO_C6Gh0-dnAEysOFryf3VnDOTOo,5650
46
46
  primitive/hardware/graphql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -81,10 +81,11 @@ primitive/reservations/graphql/mutations.py,sha256=IqzwQL7OclN7RpIcidrTQo9cGYofY
81
81
  primitive/reservations/graphql/queries.py,sha256=x31wTRelskX2fc0fx2qrY7XT1q74nvzLv_Xef3o9weg,746
82
82
  primitive/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
83
83
  primitive/utils/actions.py,sha256=HOFrmM3-0A_A3NS84MqrZ6JmQEiiPSoDqEeuu6b_qfQ,196
84
- primitive/utils/auth.py,sha256=_BJ_25ACq-GVzLvF4eHFJ1Q_gk2A_HkDg52geNzxIAc,1495
84
+ primitive/utils/auth.py,sha256=mfO4CwWZtiRZhF498d6v9qeUnLJxi_3jTViuIZI7ijs,1531
85
85
  primitive/utils/cache.py,sha256=FHGmVWYLJFQOazpXXcEwI0YJEZbdkgG39nOLdOv6VNk,1575
86
86
  primitive/utils/chunk_size.py,sha256=PAuVuirUTA9oRXyjo1c6MWxo31WVBRkWMuWw-AS58Bw,2914
87
87
  primitive/utils/config.py,sha256=DlFM5Nglo22WPtbpZSVtH7NX-PTMaKYlcrUE7GPRG4c,1058
88
+ primitive/utils/exceptions.py,sha256=DrYHTcCAJGC7cCUwOx_FmdlVLWRdpzvDvpLb82heppE,311
88
89
  primitive/utils/files.py,sha256=QUa7c4t2PNvKOtyndLAxQMGvDM4cBftSeFh28xprVbM,752
89
90
  primitive/utils/git.py,sha256=1qNOu8X-33CavmrD580BmrFhD_WVO9PGWHUUboXJR_g,663
90
91
  primitive/utils/memory_size.py,sha256=4xfha21kW82nFvOTtDFx9Jk2ZQoEhkfXii-PGNTpIUk,3058
@@ -92,8 +93,8 @@ primitive/utils/printer.py,sha256=f1XUpqi5dkTL3GWvYRUGlSwtj2IxU1q745T4Fxo7Tn4,37
92
93
  primitive/utils/shell.py,sha256=vpjr2Y7UQGYOvPGa6_RYXPPjqScfa9k7kT3tugF9h4Y,1837
93
94
  primitive/utils/text.py,sha256=XiESMnlhjQ534xE2hMNf08WehE1SKaYFRNih0MmnK0k,829
94
95
  primitive/utils/verible.py,sha256=Zb5NUISvcaIgEvgCDBWr-GCoceMa79Tcwvr5Wl9lfnA,2252
95
- primitive-0.1.94.dist-info/METADATA,sha256=jF78rkKKUBDKv-30b--nmW4RsQfUIPdzOkWVoD7HUpE,3670
96
- primitive-0.1.94.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
97
- primitive-0.1.94.dist-info/entry_points.txt,sha256=p1K8DMCWka5FqLlqP1sPek5Uovy9jq8u51gUsP-z334,48
98
- primitive-0.1.94.dist-info/licenses/LICENSE.txt,sha256=B8kmQMJ2sxYygjCLBk770uacaMci4mPSoJJ8WoDBY_c,1098
99
- primitive-0.1.94.dist-info/RECORD,,
96
+ primitive-0.1.96.dist-info/METADATA,sha256=xnSQ2jAY2Lhw4xw9kFWvKaZXyWniB5GCWUYXf_SF1eQ,3670
97
+ primitive-0.1.96.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
98
+ primitive-0.1.96.dist-info/entry_points.txt,sha256=p1K8DMCWka5FqLlqP1sPek5Uovy9jq8u51gUsP-z334,48
99
+ primitive-0.1.96.dist-info/licenses/LICENSE.txt,sha256=B8kmQMJ2sxYygjCLBk770uacaMci4mPSoJJ8WoDBY_c,1098
100
+ primitive-0.1.96.dist-info/RECORD,,