Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Commit

Permalink
Make python-magic dependency actually optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyude committed Apr 29, 2016
1 parent 9cbb9e8 commit b7df49e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ However, if you want to install manually, you will need:

- websocket-client - ```pip install websocket-client```
- requests - ```pip install requests```

And for automatic file type detection for pushFile (optional):
- python-magic - ```pip install python-magic```

You can get your API Key from https://www.pushbullet.com/#settings/account
Expand Down
6 changes: 5 additions & 1 deletion pushbullet/pushbullet.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ def pushFile(self, recipient, file_name, body, file, file_type=None, recipient_t
"""

if not file_type:
import magic
try:
import magic
except ImportError:
raise Exception("No file_type given and python-magic isn't installed")

file_type = magic.from_buffer(file.read(1024))
file.seek(0)

Expand Down
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
zip_safe=False,
install_requires=[
'websocket-client',
'requests',
'python-magic'
])
'requests'
],
extras_require={
'magic': ['python-magic']
})

0 comments on commit b7df49e

Please sign in to comment.