Remove curl download code, since the Python implementation is working
just fine.
This commit is contained in:
parent
50d7857b85
commit
28067b7632
1 changed files with 2 additions and 59 deletions
61
tivomirror
61
tivomirror
|
@ -323,13 +323,6 @@ def getAvail(dir):
|
||||||
return s.f_bsize * s.f_bavail
|
return s.f_bsize * s.f_bavail
|
||||||
|
|
||||||
|
|
||||||
def quit_process(pid):
|
|
||||||
try:
|
|
||||||
os.kill(pid, signal.SIGQUIT)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class FdLogger(threading.Thread):
|
class FdLogger(threading.Thread):
|
||||||
def __init__(self, logger, lvl, fd):
|
def __init__(self, logger, lvl, fd):
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
|
@ -349,58 +342,8 @@ class FdLogger(threading.Thread):
|
||||||
self.logger.exception("")
|
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)
|
@timeout(43200)
|
||||||
def download_curl(item, mak, target):
|
def download_item(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):
|
|
||||||
global session, proxies, headers
|
global session, proxies, headers
|
||||||
count = 0
|
count = 0
|
||||||
start = time.time()
|
start = time.time()
|
||||||
|
@ -483,7 +426,7 @@ def download_decode(item, mak):
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
download_curl(item, mak, target)
|
download_item(item, mak, target)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
exc_info = sys.exc_info()
|
exc_info = sys.exc_info()
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue