Remove curl download code, since the Python implementation is working

just fine.
This commit is contained in:
Stefan Bethke 2017-04-13 23:47:46 +02:00
parent 50d7857b85
commit 28067b7632

View file

@ -323,13 +323,6 @@ def getAvail(dir):
return s.f_bsize * s.f_bavail
def quit_process(pid):
try:
os.kill(pid, signal.SIGQUIT)
except OSError:
pass
class FdLogger(threading.Thread):
def __init__(self, logger, lvl, fd):
self.logger = logger
@ -349,58 +342,8 @@ class FdLogger(threading.Thread):
self.logger.exception("")
def waitForProcs(pids):
success = True
while len(pids) > 0:
(spid, sse) = os.wait()
pids.remove(spid)
if os.WIFSIGNALED(sse) \
or (os.WIFEXITED(sse) and os.WEXITSTATUS(sse) != 0):
if os.WIFSIGNALED(sse):
print "--- process %d was terminated by signal %d" % (spid, os.WTERMSIG(sse))
elif os.WIFEXITED(sse):
print "--- process %d exited with code %d" % (spid, os.WEXITSTATUS(sse))
else:
print "--- process %d terminated unsuccessfully" % spid
success = False
for pid in pids:
quit_process(pid)
if not success:
raise TivoException("error executing processes")
@timeout(43200)
def download_curl(item, mak, target):
global cookies
url = item.url
logger.info("--- downloading \"%s\"" % (url))
p_curl = subprocess.Popen(["curl", "--anyauth", "--fail", \
"--insecure", "--cookie", cookies, \
"--silent", "--show-error", \
"--user", "tivo:%s" % mak, "--url", url ], \
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p_decode = subprocess.Popen([tivodecode, "--mak", mak, \
"--no-verify", "--out", target, "-"], stdin=p_curl.stdout,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
FdLogger(logger, logging.INFO, p_curl.stderr)
FdLogger(logger, logging.INFO, p_decode.stdout)
FdLogger(logger, logging.INFO, p_decode.stderr)
try:
waitForProcs([p_curl.pid, p_decode.pid])
except Exception, e:
try:
os.remove(target)
except OSError:
pass
raise e
if os.path.getsize(target) < 1024:
print "error transcoding file: too small"
os.remove(target)
raise TivoException("downloaded file is too small")
@timeout(43200)
def download_py(item, mak, target):
def download_item(item, mak, target):
global session, proxies, headers
count = 0
start = time.time()
@ -483,7 +426,7 @@ def download_decode(item, mak):
except OSError:
pass
try:
download_curl(item, mak, target)
download_item(item, mak, target)
except Exception, e:
exc_info = sys.exc_info()
try: