Skip to content

Commit

Permalink
Merge pull request doronz88#812 from doronz88/bugfix/cli-ignore-impor…
Browse files Browse the repository at this point in the history
…t-errors

cli: fix ignoring `ImportError`
  • Loading branch information
doronz88 authored Jan 28, 2024
2 parents 88ff187 + 2c8c1d2 commit cbbb04d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
27 changes: 26 additions & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 1 addition & 5 deletions pymobiledevice3/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
'remote': 'remote',
'restore': 'restore',
'springboard': 'springboard',
'status': 'status',
'syslog': 'syslog',
'usbmux': 'usbmux',
'webinspector': 'webinspector',
Expand All @@ -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:
Expand Down
12 changes: 10 additions & 2 deletions pymobiledevice3/remote/core_device_tunnel_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit cbbb04d

Please sign in to comment.