Skip to content

Commit

Permalink
Make android_backup an optional dependency (#476)
Browse files Browse the repository at this point in the history
Related to #474
  • Loading branch information
rytilahti authored Feb 9, 2019
1 parent 74b966d commit 6e0a099
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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 @@ -50,13 +50,16 @@ def readme():
'cryptography',
'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

0 comments on commit 6e0a099

Please sign in to comment.