prim-ctrl 0.7.0__tar.gz → 0.7.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prim-ctrl
3
- Version: 0.7.0
3
+ Version: 0.7.1
4
4
  Summary: Primitive Ctrl - Remote control of your phone's Primitive FTPd Android SFTP server and optionally Tailscale VPN.
5
5
  Home-page: https://github.com/lmagyar/prim-ctrl
6
6
  License: Apache-2.0
@@ -108,7 +108,8 @@ Optionally, if you want to edit or even contribute to the source, you also need
108
108
  - Click on the flow, edit the 2. block ("Set variable google_account to...), enter your Google account and press Save
109
109
  - Start the flow
110
110
  - Settings
111
- - Run on system startup: enable
111
+ - Safety
112
+ - Run on system startup: enable
112
113
 
113
114
  ### Primitive FTPd
114
115
 
@@ -82,7 +82,8 @@ Optionally, if you want to edit or even contribute to the source, you also need
82
82
  - Click on the flow, edit the 2. block ("Set variable google_account to...), enter your Google account and press Save
83
83
  - Start the flow
84
84
  - Settings
85
- - Run on system startup: enable
85
+ - Safety
86
+ - Run on system startup: enable
86
87
 
87
88
  ### Primitive FTPd
88
89
 
@@ -284,7 +284,7 @@ class Service(Manageable):
284
284
 
285
285
  self._connect_timeout = 2
286
286
  self._special_exceptions = ()
287
- self._special_exceptions_handler : Callable[[Exception], None] | None = None
287
+ self._special_exceptions_handler : Callable[[Exception], bool] | None = None
288
288
 
289
289
  async def _connect(self, host: str, port: int):
290
290
  logger.debug(" Connecting with TCP to %s:%d (timeout is %ds)", host, port, self._connect_timeout)
@@ -306,10 +306,13 @@ class Service(Manageable):
306
306
  except self._special_exceptions as e:
307
307
  if availability_hint is None or availability_hint:
308
308
  if self._special_exceptions_handler:
309
- self._special_exceptions_handler(e)
309
+ if self._special_exceptions_handler(e):
310
+ raise
311
+ else:
312
+ return False
310
313
  else:
311
314
  logger.debug(" Unexpected ping exception: %s", LazyStr(e))
312
- raise
315
+ raise
313
316
  else:
314
317
  return False
315
318
  except Exception as e:
@@ -323,12 +326,15 @@ class SshService(Service):
323
326
  self.keyfile = keyfile
324
327
 
325
328
  self._connect_timeout = 3
326
- self._special_exceptions = (asyncssh.misc.HostKeyNotVerifiable, asyncssh.misc.PermissionDenied)
329
+ self._special_exceptions = (asyncssh.misc.HostKeyNotVerifiable, asyncssh.misc.PermissionDenied, asyncssh.misc.DisconnectError)
327
330
  def _handle_special_exceptions(e: Exception):
328
331
  if isinstance(e, asyncssh.misc.HostKeyNotVerifiable):
329
332
  e.add_note("Check your known_hosts file, see the documentation of prim-sync for more details")
330
- else:
333
+ elif isinstance(e, asyncssh.misc.PermissionDenied):
331
334
  e.add_note("Check your private SSH key file, see the documentation of prim-sync for more details")
335
+ else:
336
+ return False
337
+ return True
332
338
  self._special_exceptions_handler = _handle_special_exceptions
333
339
 
334
340
  async def _connect(self, host: str, port: int):
@@ -970,8 +976,13 @@ class Control:
970
976
 
971
977
  async def execute(self, args, local: Local, phone: Phone):
972
978
  async def _stop(restore_state: dict | None, stop_only_started: bool = False):
973
- if local.vpn and phone.vpn and phone.remote_sftp and await local.vpn.test() and await phone.vpn.test():
974
- if (restore_state is None or not restore_state.get(Control.PHONE_SFTP, stop_only_started)) and await phone.remote_sftp.test():
979
+ async def _suppress(coro, default: bool):
980
+ try:
981
+ return await coro
982
+ except:
983
+ return default
984
+ if local.vpn and phone.vpn and phone.remote_sftp and await _suppress(local.vpn.test(), True) and await _suppress(phone.vpn.test(), True):
985
+ if (restore_state is None or not restore_state.get(Control.PHONE_SFTP, stop_only_started)) and await _suppress(phone.remote_sftp.test(), True):
975
986
  try:
976
987
  await phone.remote_sftp.stop(10, 30)
977
988
  except Exception as e:
@@ -1075,7 +1086,10 @@ class Control:
1075
1086
  state[Control.CONNECTED] = Control.ZEROCONF if zeroconf_accessible else Control.REMOTE
1076
1087
  print(StateSerializer.dumps(state))
1077
1088
  except Exception:
1078
- await _stop(state, stop_only_started = True)
1089
+ try:
1090
+ await _stop(state, stop_only_started = True)
1091
+ except Exception as e:
1092
+ logger.exception_or_error(e, args)
1079
1093
  raise
1080
1094
  else:
1081
1095
  try:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "prim-ctrl"
3
- version = "0.7.0"
3
+ version = "0.7.1"
4
4
  description = "Primitive Ctrl - Remote control of your phone's Primitive FTPd Android SFTP server and optionally Tailscale VPN."
5
5
  license = "Apache-2.0"
6
6
  authors = ["Laszlo Magyar <lmagyar1973@gmail.com>"]
File without changes