Skip to content

Commit

Permalink
Fix #15 replace BencodePy by bcoding.
Browse files Browse the repository at this point in the history
  • Loading branch information
llaumgui committed Aug 17, 2017
1 parent 98b3973 commit 0e7df25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
paramiko>=2.2.1
bencodepy>=0.9.5
bcoding>=1.5
prettytable>=0.7.2
22 changes: 11 additions & 11 deletions seedboxsync/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@

# Try to import bencodepy
try:
from bencodepy import decode_from_file as bdecode
from bencodepy import DecodingError
from bcoding import bdecode
except ImportError:
raise DependencyException('bencodepy library isn\'t installed on system.')
raise DependencyException('bcoding library isn\'t installed on system.')


#
Expand Down Expand Up @@ -55,16 +54,17 @@ def get_torrent_infos(torrent_path):
:param str torrent_path: the path to the torrent file
"""
torrent_info = None
with open(torrent_path, 'rb') as torrent:
torrent_info = None

try:
torrent_info = bdecode(torrent_path)
except DecodingError as exc:
Helper.log_print('Not valid torrent: ' + str(exc), msg_type='error')
except Exception as exc:
Helper.log_print('Torrent decoding error: ' + str(exc), msg_type='error')
try:
torrent_info = bdecode(torrent.read())
except Exception as exc:
Helper.log_print('Not valid torrent: ' + str(exc), msg_type='error')
finally:
torrent.close()

return torrent_info
return torrent_info

@classmethod
def print(cls, *args):
Expand Down

0 comments on commit 0e7df25

Please sign in to comment.