primitive 0.1.95__py3-none-any.whl → 0.1.97__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.95"
4
+ __version__ = "0.1.97"
@@ -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
 
@@ -146,11 +147,11 @@ class Agent(BaseAction):
146
147
  )
147
148
  )
148
149
  except Exception as exception:
149
- logger.error(
150
- f"Error downloading source: {exception}"
151
- )
150
+ logger.error(f"Error downloading source: {exception}")
152
151
  self.primitive.jobs.job_run_update(
153
- job_run["id"], status="request_completed", conclusion="failure"
152
+ job_run["id"],
153
+ status="request_completed",
154
+ conclusion="failure",
154
155
  )
155
156
  continue
156
157
 
@@ -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/agent/runner.py CHANGED
@@ -140,6 +140,10 @@ class AgentRunner:
140
140
 
141
141
  # Initialize the environment with the system
142
142
  environment = os.environ
143
+
144
+ # Add local variables
145
+ environment["PRIMITIVE_GIT_SHA"] = str(self.job_run["gitCommit"]["sha"])
146
+
143
147
  if "provision" in self.job:
144
148
  logger.info(f"Provisioning for {self.job['provision']} environment")
145
149
  environment = self.provision()
@@ -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:
@@ -419,7 +421,7 @@ class Hardware(BaseAction):
419
421
  logger.debug(message.get("message"))
420
422
 
421
423
  if checkin_success:
422
- if self.status_cache.get(fingerprint):
424
+ if fingerprint in self.status_cache:
423
425
  previous_status = self.status_cache[fingerprint]
424
426
  else:
425
427
  previous_status = {
@@ -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.95
3
+ Version: 0.1.97
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,13 +1,13 @@
1
- primitive/__about__.py,sha256=ouSBabAcgPjZIDVCBckH88mjsRPM8LpwffKy_EhIcvc,130
1
+ primitive/__about__.py,sha256=VlPlizaJ28NM3NAQfHbIEgioaK258vAJovVqUbc4ahY,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=v7-KZQWmpAyavjv2P06rx6i7oULZcUriTr66P8j90-o,7911
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
10
- primitive/agent/runner.py,sha256=gVr-IWizw7UiP-9vgDviGzmrJBi5jLMXMw-0aVusPIs,9487
10
+ primitive/agent/runner.py,sha256=v_c5DtyQNCOQzgtvHfHv3DXQcHbo-EPJaILas6xAxTA,9600
11
11
  primitive/agent/uploader.py,sha256=OkgwXhWKoECOJnW_ZmpzmUS_cpb-orC_uebNcmf5byw,2948
12
12
  primitive/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  primitive/auth/actions.py,sha256=MPsG9LcKcOPwA7gZ9Ewk0PZJhTQvIrGfODdz4GxSzgA,999
@@ -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=6tZCAqSYl6YuZ0u52MIkON77_RX-BR38TXuOMq2NKEI,25955
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.95.dist-info/METADATA,sha256=o67ITMkiWAPBHvnyaICfDEsrwyQqm0VyRPfKzwGJRPo,3670
96
- primitive-0.1.95.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
97
- primitive-0.1.95.dist-info/entry_points.txt,sha256=p1K8DMCWka5FqLlqP1sPek5Uovy9jq8u51gUsP-z334,48
98
- primitive-0.1.95.dist-info/licenses/LICENSE.txt,sha256=B8kmQMJ2sxYygjCLBk770uacaMci4mPSoJJ8WoDBY_c,1098
99
- primitive-0.1.95.dist-info/RECORD,,
96
+ primitive-0.1.97.dist-info/METADATA,sha256=Bc_2IjZVv-zJZBIfw-_Csk-kD46whiyTU5TIBcehyjQ,3670
97
+ primitive-0.1.97.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
98
+ primitive-0.1.97.dist-info/entry_points.txt,sha256=p1K8DMCWka5FqLlqP1sPek5Uovy9jq8u51gUsP-z334,48
99
+ primitive-0.1.97.dist-info/licenses/LICENSE.txt,sha256=B8kmQMJ2sxYygjCLBk770uacaMci4mPSoJJ8WoDBY_c,1098
100
+ primitive-0.1.97.dist-info/RECORD,,