def run(self): while len(self.links) > 0: link = None # get download info try: job_lock.acquire() if len(self.links) > 0: link = self.links.pop(0) else: break filename, url = DOWNLOAD_DIR + link[1] + ".torrent", link[2] print "downloading", link[1] finally: job_lock.release() # try download success = download(url, filename, 7) job_lock.acquire() if success: print "finished downloading", link[1] else: # assume not yet downloaded print "connection error on downloading {0}, retrying later".format( link[1]) links.append(link) job_lock.release()
def run(self): while len(self.links) > 0: link = None # get download info try: job_lock.acquire() if len(self.links) > 0: link = self.links.pop(0) else: break filename, url = DOWNLOAD_DIR + link[1] + ".torrent", link[2] print "downloading", link[1] finally: job_lock.release() # try download success = download(url, filename, 7) job_lock.acquire() if success: print "finished downloading", link[1] else: # assume not yet downloaded print "connection error on downloading {0}, retrying later".format(link[1]) links.append(link) job_lock.release()
def run(self): for link in self.links: filename, url = DOWNLOAD_DIR + link[1] + ".torrent", link[2] download(url, filename) os.chmod(filename, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
links.append((ret[n]['link'], ret[n]['name'] + ".torrent")) n = n + 1 if (n == 0): print key, "is already updated" else: updates[key] = [None, None, ret[0]['name']] print key, "has", n, "new update(s)!" for i in range(n): print ret[i]['name'] else: print "Connection error on checking", key print return links, updates # create and load database object to be checked db = NyaaSQLiteDB() links, updates = checkUpdate(db.load()) n = len(links) # download available torrent(s) if applicable if n > 0: print "Download all", n, "torrent(s)? [y/n]", var = raw_input() if var=="y": for e in links: try: download(e[0],e[1]) print "Downloaded", e[1] except IOError: print "Connection Error" db.update(updates)
n = n + 1 if (n == 0): print key, "is already updated" else: updates[key] = [None, None, ret[0]['name']] print key, "has", n, "new update(s)!" for i in range(n): print ret[i]['name'] else: print "Connection error on checking", key print return links, updates # create and load database object to be checked db = NyaaSQLiteDB() links, updates = checkUpdate(db.load()) n = len(links) # download available torrent(s) if applicable if n > 0: print "Download all", n, "torrent(s)? [y/n]", var = raw_input() if var == "y": for e in links: try: download(e[0], e[1]) print "Downloaded", e[1] except IOError: print "Connection Error" db.update(updates)