From e23e447a1b3c88349a4094cfb58f96e4523d3982 Mon Sep 17 00:00:00 2001 From: inpos Date: Sun, 27 Mar 2016 15:27:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BF=D0=B0=D1=83=D0=B7=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addon.xml | 2 +- lib/pyrrent2http/engine.py | 5 +++++ lib/pyrrent2http/pyrrent2http.py | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/addon.xml b/addon.xml index 2ad983b..64184ad 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + diff --git a/lib/pyrrent2http/engine.py b/lib/pyrrent2http/engine.py index 210de6d..7d4b573 100644 --- a/lib/pyrrent2http/engine.py +++ b/lib/pyrrent2http/engine.py @@ -247,6 +247,11 @@ class Engine: def activate_file(self, index): self.pyrrent2http.TorrentFS.file(index) + + def pause(self): + self.pyrrent2http.pause = True + def resume(self): + self.pyrrent2http.pause = False def check_torrent_error(self, status=None): """ diff --git a/lib/pyrrent2http/pyrrent2http.py b/lib/pyrrent2http/pyrrent2http.py index 59f290e..0abe6a9 100644 --- a/lib/pyrrent2http/pyrrent2http.py +++ b/lib/pyrrent2http/pyrrent2http.py @@ -412,6 +412,9 @@ def HttpHandlerFactory(): buf = bytearray(chunk) try: if f.Read(buf) < 1: break + while self.server.root_obj.pause: + time.sleep(0.1) + continue self.wfile.write(buf) except: break @@ -461,6 +464,7 @@ def HttpHandlerFactory(): return HttpHandler class Pyrrent2http(object): + pause = False def __init__(self, uri = '', bindAddress = 'localhost:5001', downloadPath = '.', idleTimeout = -1, keepComplete = False, keepIncomplete = False, keepFiles = False, showAllStats = False,