snapctl 0.49.0__py3-none-any.whl → 0.49.2__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.

Potentially problematic release.


This version of snapctl might be problematic. Click here for more details.

snapctl/commands/byows.py CHANGED
@@ -87,9 +87,8 @@ class Byows:
87
87
  info(line.decode().rstrip())
88
88
 
89
89
  @staticmethod
90
- def _write_export_command_to_console(snap_ids, port):
90
+ def _get_export_commands(snap_ids, port):
91
91
  '''
92
- TODO: This is not used anymore
93
92
  Generate export commands for the given snap IDs and port.
94
93
  '''
95
94
  env_vars = []
@@ -104,12 +103,10 @@ class Byows:
104
103
 
105
104
  if system == "Windows":
106
105
  # PowerShell syntax
107
- return "; ".join([f'$env:{env_vars[i].replace("=", " = ")}; $env:{env_vars[i+1].replace("=", " = ")}'
108
- for i in range(0, len(env_vars), 2)])
106
+ return "; ".join([f'$env:{env_vars[i].replace("=", " = ")}' for i in range(len(env_vars))])
109
107
  else:
110
108
  # Linux or macOS bash/zsh syntax
111
- return "export \\\n" + " \\\n".join([f" {env_vars[i]} {env_vars[i+1]}"
112
- for i in range(0, len(env_vars), 2)])
109
+ return "\n".join([f"{env_vars[i]}" for i in range(len(env_vars))])
113
110
 
114
111
  @staticmethod
115
112
  def _generate_env_file(snap_ids, port):
@@ -141,21 +138,6 @@ class Byows:
141
138
 
142
139
  return env_file
143
140
 
144
- @staticmethod
145
- def _generate_env(snap_ids, port):
146
- '''
147
- Generate environment variables for the given snap IDs and port.
148
- '''
149
- env_file = Byows._generate_env_file(snap_ids, port)
150
- info(f"Environment variables written to {env_file}")
151
- system = platform.system()
152
- if system == "Windows":
153
- info(
154
- f"Run the following command to set them in your session:\n\n . {env_file}\n")
155
- else:
156
- info(
157
- f"Run the following command to set them in your shell:\n\n source {env_file}\n")
158
-
159
141
  @staticmethod
160
142
  def _format_portal_http_error(msg, http_err, response):
161
143
  """
@@ -213,21 +195,19 @@ class Byows:
213
195
  with open(pub_file, 'w') as f:
214
196
  f.write(public_key)
215
197
 
216
- # Let user know about the forwarding
217
- # TODO: AJ, needs to be the proper base url
218
- info(f"Forwarding {self.base_snapend_url}/{snapend_id}/v1/{snap_id}" +
219
- f"-> http://localhost:{incoming_http}/*")
220
- info(
221
- f"Your BYOSnap HTTP server should listen on: localhost:{incoming_http}")
198
+ # Combine all the information into a single info() call
222
199
  info(
223
- f"Connect to other snaps over HTTP on: localhost:{outgoing_http}")
224
- Byows._generate_env(snap_ids, port)
225
- info('Press <ctrl-c> to stop forwarding')
200
+ f"Forwarding {self.base_snapend_url}/{snapend_id}/v1/{snap_id} -> http://localhost:{incoming_http}/*\n"
201
+ f"Your BYOSnap HTTP server should listen on: localhost:{incoming_http}\n"
202
+ f"Connect to other snaps over HTTP on: localhost:{outgoing_http}\n"
203
+ f"Set the environment variables before starting your local server:\n\n"
204
+ f"{Byows._get_export_commands(snap_ids, port)}\n\n"
205
+ f"Run the following command to set them in your session:\n\n"
206
+ f" source {Byows._generate_env_file(snap_ids, port)}\n\n"
207
+ f"Press <ctrl-c> to stop forwarding"
208
+ )
226
209
 
227
- # TODO: ??? AJ get the ssh host for the current environ from BYOWS_SSH_HOSTS contact in endpoints.py
228
210
  ssh_addr = ssh_connect_addr
229
- if not ssh_addr:
230
- snapctl_error(message=f"{env} is missing or empty in BYOWS_SSH_HOSTS", code=SNAPCTL_INPUT_ERROR)
231
211
 
232
212
  # Extract the port from the ssh_addr if present, otherwise default to 22
233
213
  if ':' in ssh_addr:
@@ -239,6 +219,8 @@ class Byows:
239
219
 
240
220
  ssh_command = [
241
221
  'ssh',
222
+ '-q',
223
+ '-4', # use IPv4
242
224
  '-o', 'ServerAliveInterval=60',
243
225
  '-o', 'StrictHostKeyChecking=no',
244
226
  '-o', 'UserKnownHostsFile=/dev/null',
@@ -252,7 +234,6 @@ class Byows:
252
234
  ssh_command += ['-R', f'{reverse_grpc_port}:localhost:{incoming_grpc}']
253
235
  ssh_command += [ssh_host]
254
236
 
255
- # print(f'Running SSH command: {ssh_command}')
256
237
  process = None
257
238
  try:
258
239
  process = subprocess.Popen(
@@ -349,8 +330,7 @@ class Byows:
349
330
  transient=True,
350
331
  )
351
332
  progress.start()
352
- progress.add_task(
353
- description='Setting up BYOWs port forward...', total=None)
333
+ progress.add_task(description='Setting up BYOWs port forward...', total=None)
354
334
  try:
355
335
  url = f"{self.base_url}/v1/snapser-api/byows/snapends/" + \
356
336
  f"{self.snapend_id}/snaps/{self.byosnap_id}"
@@ -359,15 +339,14 @@ class Byows:
359
339
  headers={'api-key': self.api_key},
360
340
  json={
361
341
  "snapend_id": self.snapend_id,
362
- "snap_id": self.byosnap_id
342
+ "snap_id": self.byosnap_id,
343
+ "internal_grpc_port": self.grpc_port,
363
344
  },
364
345
  timeout=SERVER_CALL_TIMEOUT
365
346
  )
366
347
  res.raise_for_status()
367
348
  response_json = res.json()
368
349
 
369
- # For debugging
370
- #print(f"BYOWS Response:\n{json.dumps(response_json, indent=2)}")
371
350
 
372
351
  if res.ok and 'workstationPort' in response_json and \
373
352
  'workstationReversePort' in response_json and \
@@ -383,6 +362,8 @@ class Byows:
383
362
 
384
363
  outgoing_http_port = response_json['workstationPort']
385
364
 
365
+ progress.stop()
366
+
386
367
  self._setup_port_forward(
387
368
  response_json['proxyPrivateKey'],
388
369
  response_json['proxyPublicKey'],
@@ -3,7 +3,7 @@ Constants used by snapctl
3
3
  """
4
4
  COMPANY_NAME = 'Snapser'
5
5
  VERSION_PREFIX = 'beta-'
6
- VERSION = '0.49.0'
6
+ VERSION = '0.49.2'
7
7
  CONFIG_FILE_MAC = '~/.snapser/config'
8
8
  CONFIG_FILE_WIN = '%homepath%\\.snapser\\config'
9
9
 
@@ -1,12 +1,9 @@
1
1
  ## beta-0.49.0
2
- ##### May 9, 2025
2
+ ##### May 5, 2025
3
3
 
4
4
  ### Breaking Change
5
5
  1. Renamed SDK type `server` to `api-key` to be consistent with the Snapser Web app.
6
6
 
7
- ### Features
8
- 1. You can now download the new Omni SDK via Snapctl.
9
-
10
7
  ### Bug Fixes
11
8
  1. The `snapctl byosnap generate-profile` command was not working when outside the root snapctl folder. This is now fixed.
12
9
  2. The `snapctl release-notes` commands were not working when outside the root snapctl folder. This is now fixed.
@@ -0,0 +1,6 @@
1
+ ## beta-0.49.1
2
+ ##### May 9, 2025
3
+
4
+ ### Features
5
+ 1. Bring your own workstation (BYOW) support - You can now connect your BYOSnap to a Snapend. Allowing you to debug and test your BYOSnap code locally.
6
+
@@ -0,0 +1,6 @@
1
+ ## beta-0.49.2
2
+ ##### May 12, 2025
3
+
4
+ ### Bug Fixes
5
+ 1. Bring your own workstation (BYOW) - An issue with incoming gRPC connections not using the appropriate port has been fixed.
6
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: snapctl
3
- Version: 0.49.0
3
+ Version: 0.49.2
4
4
  Summary: Snapser CLI Tool
5
5
  Author: Ajinkya Apte
6
6
  Author-email: aj@snapser.com
@@ -3,13 +3,13 @@ snapctl/__main__.py,sha256=43jKoTk8b85hk_MT6499N3ruHdEfM8WBImd_-3VzjI8,116
3
3
  snapctl/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  snapctl/commands/byogs.py,sha256=WumLZRriCVF0SSnMn8TUL--iWhh3Yub3yQ-jz30faI0,19486
5
5
  snapctl/commands/byosnap.py,sha256=9Xe75VAi-KPFALSleUyMJsrvDJEG6cxBiGiF267PSJA,76897
6
- snapctl/commands/byows.py,sha256=T6SjB0PpYDYDVDI6c3nhZ4dUY_TGQKbtzMmgqB6i6GM,16714
6
+ snapctl/commands/byows.py,sha256=JMwrRtD5_NXXjN-eWimoIJleAYMWlxVnum8VkKR76ZU,15824
7
7
  snapctl/commands/game.py,sha256=lAABIWIibrwcqvpKvTy_7UzzLtbiP6gdk4_qPBHFKOI,5248
8
8
  snapctl/commands/generate.py,sha256=9-NlZVQllBT2LZT_t9S3ztwtHzTbM-C8_x0f6z70U3g,5606
9
9
  snapctl/commands/release_notes.py,sha256=QlhBlywLiRTKBs3SlaxHf-0E0OEU_47Xjld9gGtj4Zw,1943
10
10
  snapctl/commands/snapend.py,sha256=4hY4ffLtZ2mxbKRgwDPi8erc78nGl-6kxmCf56HODpk,39382
11
11
  snapctl/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- snapctl/config/constants.py,sha256=AZPwrRdh3rT4H7M08uI7PqOyUlm1yJS9rKX1PadoApA,3653
12
+ snapctl/config/constants.py,sha256=ltJNuRZqE3zTkzS4-O5dB5fjuZVoOgY_84XvEixpGOU,3653
13
13
  snapctl/config/endpoints.py,sha256=jD0n5ocJBbIkrb97F2_r9hqAHzUuddAqzqqBAPUKDTI,477
14
14
  snapctl/config/hashes.py,sha256=3OKAyOxQPnn--_hvPIzFJnhC8NVfQK4WT-RH4PHEV1w,5242
15
15
  snapctl/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -24,15 +24,17 @@ snapctl/data/releases/beta-0.47.0.mdx,sha256=p-bp0NUVcSKELHXtHJaq884_O4yTZDTCUbW
24
24
  snapctl/data/releases/beta-0.47.1.mdx,sha256=YqQ7ncHDW9pCbQNnQic1o_xQt3DinOFEo3YW0hJVUAk,645
25
25
  snapctl/data/releases/beta-0.47.2.mdx,sha256=9FQuJj6ntu0gG5Mf-d8lgCRqmzkuFyESqI_Gf5jLNmo,135
26
26
  snapctl/data/releases/beta-0.48.0.mdx,sha256=b9Dz-a2FAaZx2BnFTyle7PgJ2RuNv6Zj1KsT2TfaNH8,1244
27
- snapctl/data/releases/beta-0.49.0.mdx,sha256=U0GvmiwJFfhJWihyNGHY4p-cgqc0OFldfS9qg2fvhaA,459
27
+ snapctl/data/releases/beta-0.49.0.mdx,sha256=pqJP7NfM3ZMxs4SoeANCdDqTxjR9IBGbBI3ThKTEbpw,391
28
+ snapctl/data/releases/beta-0.49.1.mdx,sha256=4EXupEegYffnL5bu_XWxGbzIPp9xOzl7t4xbmhq52fU,200
29
+ snapctl/data/releases/beta-0.49.2.mdx,sha256=Vv_OIQyPieEGI9FgTUT0v5Gm0PC2JWa2FqcCUhnvx6s,176
28
30
  snapctl/main.py,sha256=TT3osIBAJJLYERevPSNt-OxLwF0Rsxxu3GMzu72niPM,25203
29
31
  snapctl/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
32
  snapctl/types/definitions.py,sha256=EQzLeiXkJ8ISRlCqHMviNVsWWpmhWjpKaOBLdlvOTmY,644
31
33
  snapctl/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
34
  snapctl/utils/echo.py,sha256=V0qgjqqGXRiueMkq31enmNmdqciC8S90qGRcK8UupXA,1090
33
35
  snapctl/utils/helper.py,sha256=7ugGs1GE7Rywf1-tQxrgqXUU97EQYFjS3JUDpk9SX_Q,6850
34
- snapctl-0.49.0.dist-info/LICENSE,sha256=6AcXm54KFSpmUI1ji9NIBd4Xl-DtjTqiyjBzfVb_CEk,2804
35
- snapctl-0.49.0.dist-info/METADATA,sha256=1ALedesLOoQ31uxMWipWlL9W8kagIgCK_hqY8FwOs74,35965
36
- snapctl-0.49.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
37
- snapctl-0.49.0.dist-info/entry_points.txt,sha256=tkKW9MzmFdRs6Bgkv29G78i9WEBK4WIOWunPfe3t2Wg,44
38
- snapctl-0.49.0.dist-info/RECORD,,
36
+ snapctl-0.49.2.dist-info/LICENSE,sha256=6AcXm54KFSpmUI1ji9NIBd4Xl-DtjTqiyjBzfVb_CEk,2804
37
+ snapctl-0.49.2.dist-info/METADATA,sha256=VSxYtNdGK73ALZE0d_ROoWDDdVmZFGgfealw4xn7BRc,35965
38
+ snapctl-0.49.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
39
+ snapctl-0.49.2.dist-info/entry_points.txt,sha256=tkKW9MzmFdRs6Bgkv29G78i9WEBK4WIOWunPfe3t2Wg,44
40
+ snapctl-0.49.2.dist-info/RECORD,,