def main(args): global time_of_last_run time_of_last_run = time.time() if sys.argv[1] == "additional": print(bcolors.HEADER + "We will be using a max of {} threads, a queue of {} {} releases. passwordstatus range {} to -1".format(run_threads, "{:,}".format(len(datas)), sys.argv[1], maxtries) + bcolors.ENDC) elif sys.argv[1] == "nfo": print(bcolors.HEADER + "We will be using a max of {} threads, a queue of {} {} releases. nfostatus range {} to -1".format(run_threads, "{:,}".format(len(datas)), sys.argv[1], maxtries) + bcolors.ENDC) else: print(bcolors.HEADER + "We will be using a max of {} threads, a queue of {} {} releases.".format(run_threads, "{:,}".format(len(datas)), sys.argv[1]) + bcolors.ENDC) time.sleep(2) def signal_handler(signal, frame): sys.exit(0) signal.signal(signal.SIGINT, signal_handler) if True: #spawn a pool of place worker threads for i in range(run_threads): p = queue_runner(my_queue) p.setDaemon(False) p.start() #now load some arbitrary jobs into the queue if sys.argv[1] == "additional": for release in datas: time.sleep(.02) my_queue.put(u("%s =+= %s =+= %s =+= %s =+= %s =+= %s =+= %s =+= %s =+= %s") % (release[0], release[1], release[2], release[3], release[4], release[5], release[6], release[7], release[8])) elif sys.argv[1] == "nfo": for release in datas: time.sleep(.02) my_queue.put(u("%s =+= %s =+= %s =+= %s") % (release[0], release[1], release[2], release[3])) elif sys.argv[1] == "movie": for release in datas: time.sleep(.02) my_queue.put(u("%s =+= %s =+= %s") % (release[0], release[1], release[2])) elif sys.argv[1] == "tv": for release in datas: time.sleep(.02) my_queue.put(u("%s =+= %s") % (release[0], release[1])) my_queue.join() if sys.argv[1] == "nfo": cur = info.connect() cur[0].execute("SELECT id from releases WHERE nfostatus <= -6") final = cur[0].fetchall() if len(datas) > 0: for item in final: run = "DELETE FROM releasenfo WHERE nfo IS NULL AND releaseid = %s" cur[0].execute(run, (item[0])) final = cur[0].fetchall() #close connection to mysql info.disconnect(cur[0], cur[1]) print(bcolors.HEADER + "\nPostProcess {} Threaded Completed at {}".format(sys.argv[1],datetime.datetime.now().strftime("%H:%M:%S")) + bcolors.ENDC) print(bcolors.HEADER + "Running time: {}\n\n".format(str(datetime.timedelta(seconds=time.time() - start_time))) + bcolors.ENDC)
def main(args): global time_of_last_run time_of_last_run = time.time() print(bcolors.HEADER + "We will be using a max of {} threads, a queue of {}.".format(run_threads, "{:,}".format(len(datas))) + bcolors.ENDC) time.sleep(2) def signal_handler(signal, frame): sys.exit(0) signal.signal(signal.SIGINT, signal_handler) if True: #spawn a pool of place worker threads for i in range(run_threads): p = queue_runner(my_queue) p.setDaemon(False) p.start() #now load some arbitrary jobs into the queue if sys.argv[1] == "additional": for release in datas: time.sleep(.02) my_queue.put(u("%s %s") % (sys.argv[1], release[0])) elif sys.argv[1] == "nfo": for release in datas: time.sleep(.02) my_queue.put(u("%s %s") % (sys.argv[1], release[0])) elif sys.argv[1] == "movie": for release in datas: time.sleep(.02) my_queue.put(u("%s %s") % (sys.argv[1], release[0])) elif sys.argv[1] == "tv": for release in datas: time.sleep(.02) my_queue.put(u("%s %s") % (sys.argv[1], release[0])) my_queue.join() if sys.argv[1] == "nfo": cur = info.connect() cur[0].execute("SELECT id from releases WHERE nfostatus <= -6") final = cur[0].fetchall() if len(datas) > 0: for item in final: run = "DELETE FROM release_nfos WHERE nfo IS NULL AND releaseid = %s" cur[0].execute(run, (item[0])) final = cur[0].fetchall() #close connection to mysql info.disconnect(cur[0], cur[1]) print(bcolors.HEADER + "\nPostProcess {} Threaded Completed at {}".format(sys.argv[1],datetime.datetime.now().strftime("%H:%M:%S")) + bcolors.ENDC) print(bcolors.HEADER + "Running time: {}\n\n".format(str(datetime.timedelta(seconds=time.time() - start_time))) + bcolors.ENDC)
where = "r.proc_par2 = 0" elif sys.argv[1] == "miscsorter": where = "r.nfostatus = 1 AND r.proc_nfo = 1 AND r.proc_sorter = 0 AND r.isrenamed = 0" elif sys.argv[1] == "predbft": extrawhere = "" where = "1=1" rowlimit = "LIMIT %s" % (threads) cur[0].execute("SELECT %s FROM releases r %s WHERE %s %s %s %s %s" % (select, join, where, extrawhere, groupby, orderby, rowlimit)) datas = cur[0].fetchall() guids = int(len(datas)) #close connection to mysql info.disconnect(cur[0], cur[1]) if not datas: print(bcolors.HEADER + "No Work to Process" + bcolors.ENDC) sys.exit() my_queue = queue.Queue() time_of_last_run = time.time() class queue_runner(threading.Thread): def __init__(self, my_queue): threading.Thread.__init__(self) self.my_queue = my_queue def run(self):
datas = cur[0].fetchall() elif sys.argv[1] == "movie" and len(sys.argv) == 3 and sys.argv[2] == "clean": cur[0].execute("SELECT LEFT(guid, 1) FROM releases WHERE nzbstatus = 1 AND isrenamed = 1 AND searchname IS NOT NULL AND imdbid IS NULL AND categoryid BETWEEN 2000 AND 2999 GROUP BY LEFT(guid, 1) "+orderBY+" LIMIT 16") datas = cur[0].fetchall() elif sys.argv[1] == "movie": cur[0].execute("SELECT LEFT(guid, 1) FROM releases WHERE nzbstatus = 1 AND searchname IS NOT NULL AND imdbid IS NULL AND categoryid BETWEEN 2000 AND 2999 GROUP BY LEFT(guid, 1) "+orderBY+" LIMIT 16") datas = cur[0].fetchall() elif sys.argv[1] == "tv" and len(sys.argv) == 3 and sys.argv[2] == "clean": cur[0].execute("SELECT LEFT(guid, 1) FROM releases WHERE nzbstatus = 1 AND isrenamed = 1 AND searchname IS NOT NULL AND rageid = -1 AND categoryid BETWEEN 5000 AND 5999 GROUP BY LEFT(guid, 1) "+orderBY+" LIMIT 16") datas = cur[0].fetchall() elif sys.argv[1] == "tv": cur[0].execute("SELECT LEFT(guid, 1) FROM releases WHERE nzbstatus = 1 AND searchname IS NOT NULL AND rageid = -1 AND categoryid BETWEEN 5000 AND 5999 GROUP BY LEFT(guid, 1) "+orderBY+" LIMIT 16") datas = cur[0].fetchall() #close connection to mysql info.disconnect(cur[0], cur[1]) if not datas: print(bcolors.HEADER + "No Work to Process" + bcolors.ENDC) sys.exit() my_queue = queue.Queue() time_of_last_run = time.time() class queue_runner(threading.Thread): def __init__(self, my_queue): threading.Thread.__init__(self) self.my_queue = my_queue def run(self): global time_of_last_run