From f2788dc63ca7b4afd08d1d78586b82e78e2ce105 Mon Sep 17 00:00:00 2001 From: inpos Date: Sun, 6 Mar 2016 13:19:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pyrrent2http/engine.py | 2 +- lib/pyrrent2http/pyrrent2http.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/pyrrent2http/engine.py b/lib/pyrrent2http/engine.py index 16ba6b5..925d340 100644 --- a/lib/pyrrent2http/engine.py +++ b/lib/pyrrent2http/engine.py @@ -17,7 +17,7 @@ from . import SessionStatus, FileStatus, PeerInfo, MediaType, Encryption from util import can_bind, find_free_port, ensure_fs_encoding import threading -LOGGING = False +LOGGING = True class Engine: """ diff --git a/lib/pyrrent2http/pyrrent2http.py b/lib/pyrrent2http/pyrrent2http.py index 0d566dc..ee78bde 100644 --- a/lib/pyrrent2http/pyrrent2http.py +++ b/lib/pyrrent2http/pyrrent2http.py @@ -4,6 +4,7 @@ import argparse import sys, os import json import chardet +STANDALONE = False try: from python_libtorrent import get_libtorrent lt=get_libtorrent() @@ -673,12 +674,16 @@ class Pyrrent2http(object): uriPath = uriPath[1:] try: absPath = os.path.abspath(urllib.unquote(uriPath)) - logging.info('Opening local file: %s' % (absPath,)) + logging.info('Opening local torrent file: %s' % (absPath,)) with open(absPath, 'rb') as f: - torrent_info = lt.torrent_info(lt.bdecode(f.read())) + btorrent_info = f.read() + logging.info(repr(btorrent_info)) + dtorrent_info = lt.bdecode(btorrent_info) + logging.info(repr(dtorrent_info)) + torrent_info = lt.torrent_info(dtorrent_info) except Exception as e: strerror = e.args - logging.error(strerror) + logging.error('Build torrent params error is (%s)' % (strerror,)) if STANDALONE: sys.exit(1) else: @@ -1095,7 +1100,7 @@ class Pyrrent2http(object): return -STANDALONE = False + if __name__ == '__main__': STANDALONE = True try: