From 65ff1da174add6f9fe386bad3fd154b1c8eef09e Mon Sep 17 00:00:00 2001 From: doronz Date: Sun, 28 Jan 2024 13:25:09 +0200 Subject: [PATCH 1/2] cli: fix ignoring `ImportError` --- pymobiledevice3/__main__.py | 6 +----- pymobiledevice3/remote/core_device_tunnel_service.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pymobiledevice3/__main__.py b/pymobiledevice3/__main__.py index bbe8c5306..cbbfdcbce 100644 --- a/pymobiledevice3/__main__.py +++ b/pymobiledevice3/__main__.py @@ -64,7 +64,6 @@ 'remote': 'remote', 'restore': 'restore', 'springboard': 'springboard', - 'status': 'status', 'syslog': 'syslog', 'usbmux': 'usbmux', 'webinspector': 'webinspector', @@ -79,10 +78,7 @@ def list_commands(self, ctx): def get_command(self, ctx, name): if name not in CLI_GROUPS.keys(): ctx.fail(f'No such command {name!r}.') - try: - mod = __import__(f'pymobiledevice3.cli.{CLI_GROUPS[name]}', None, None, ['cli']) - except ImportError: - return + mod = __import__(f'pymobiledevice3.cli.{CLI_GROUPS[name]}', None, None, ['cli']) command = mod.cli.get_command(ctx, name) # Some cli groups have different names than the index if not command: diff --git a/pymobiledevice3/remote/core_device_tunnel_service.py b/pymobiledevice3/remote/core_device_tunnel_service.py index 1b65fc801..bd9254a64 100644 --- a/pymobiledevice3/remote/core_device_tunnel_service.py +++ b/pymobiledevice3/remote/core_device_tunnel_service.py @@ -14,7 +14,11 @@ from asyncio import CancelledError, StreamReader, StreamWriter from collections import namedtuple from contextlib import asynccontextmanager, suppress -from os import chown, getenv + +if sys.platform != 'win32': + from os import chown + +from os import getenv from pathlib import Path from socket import AF_INET6, create_connection from ssl import VerifyMode @@ -33,7 +37,11 @@ from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305 from cryptography.hazmat.primitives.kdf.hkdf import HKDF from opack import dumps -from pytun_pmd3 import TunTapDevice + +if sys.platform != 'win32': + from pytun_pmd3 import TunTapDevice +else: + TunTapDevice = None from qh3.asyncio import QuicConnectionProtocol from qh3.asyncio.client import connect as aioquic_connect from qh3.asyncio.protocol import QuicStreamHandler From 2c8c1d239f768f6389a30db6f1cefe643cee162b Mon Sep 17 00:00:00 2001 From: doronz Date: Sun, 28 Jan 2024 13:42:12 +0200 Subject: [PATCH 2/2] ci: test all subcommands exist on all platforms --- .github/workflows/python-app.yml | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index b01edf072..9021819b1 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -41,4 +41,29 @@ jobs: python -m pip install -U . - name: Test show usage run: | - python -m pymobiledevice3 + python -m pymobiledevice3 --help + python -m pymobiledevice3 activation --help + python -m pymobiledevice3 afc --help + python -m pymobiledevice3 amfi --help + python -m pymobiledevice3 apps --help + python -m pymobiledevice3 backup2 --help + python -m pymobiledevice3 bonjour --help + python -m pymobiledevice3 companion --help + python -m pymobiledevice3 crash --help + python -m pymobiledevice3 developer --help + python -m pymobiledevice3 diagnostics --help + python -m pymobiledevice3 lockdown --help + python -m pymobiledevice3 mounter --help + python -m pymobiledevice3 notification --help + python -m pymobiledevice3 pcap --help + python -m pymobiledevice3 power-assertion --help + python -m pymobiledevice3 processes --help + python -m pymobiledevice3 profile --help + python -m pymobiledevice3 provision --help + python -m pymobiledevice3 remote --help + python -m pymobiledevice3 restore --help + python -m pymobiledevice3 springboard --help + python -m pymobiledevice3 syslog --help + python -m pymobiledevice3 usbmux --help + python -m pymobiledevice3 webinspector --help + python -m pymobiledevice3 version --help \ No newline at end of file