Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make android_backup an optional dependency #476

Merged
merged 1 commit into from
Feb 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion miio/extract_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import attr
import click
from android_backup import AndroidBackup
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes

Expand Down Expand Up @@ -190,6 +189,12 @@ def read_yeelight_database(tar):
devices = []
reader = BackupDatabaseReader(dump_raw)
if backup.endswith(".ab"):
try:
from android_backup import AndroidBackup
except ModuleNotFoundError:
click.echo("You need to install android_backup to extract "
"tokens from Android backup files.")
return

with AndroidBackup(backup, stream=False) as f:
tar = f.read_data(password)
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,16 @@ def readme():
'pretty_cron',
'zeroconf',
'attrs',
'android_backup',
'pytz',
'appdirs',
'tqdm',
'netifaces',
],

extras_require={
'Android backup extraction': 'android_backup',
},

entry_points={
'console_scripts': [
'mirobo=miio.vacuum_cli:cli',
Expand Down