def test_init(self): jobs = Job_Queue(5) assert_equal(jobs._queued, []) assert_equal(jobs._running, []) assert_equal(jobs._completed, []) assert_equal(jobs._num_of_jobs, 0) assert_equal(jobs._max, 5) assert_false(jobs._finished) assert_false(jobs._closed) assert_false(jobs._debug) jobs._debug = True assert_true(jobs._debug)
def populate(self): jobs = Job_Queue(5) def foo(): return 10 for x in range(10): jobs.append(self.Bucket( target=foo, args=[], kwargs={}, )) return jobs
def populate(self): jobs = Job_Queue(5) def foo(): return 10 for x in range(10): jobs.append(self.Bucket( target = foo, args = [], kwargs = {}, )) return jobs
def populate(self,queue_size=5,job_size=10,debug=False): jobs = Job_Queue(queue_size) jobs._debug = debug def foo(): return 10 for x in range(job_size): jobs.append(self.Bucket( target = foo, args = [], kwargs = {}, )) return jobs
#!/usr/bin/env python2 import argparse import json import os import sqlite3 as lite import time import virustotal from job_queue import Job_Queue from multiprocessing import Process jobs = Job_Queue(64) # Parameter is number of procs at a time. parser = argparse.ArgumentParser( description='Scan a directory with VirusTotal.') parser.add_argument('directory', type=str) args = parser.parse_args() def scan(fname): print("[" + fname + "] Scanning.") v = virustotal.VirusTotal('8488f4b84e9c2010c95b17df236466a42f46e6762a2739da4caa6cf1c9178ad3') report = None; attempts = 0; while report is None and attempts < 5: try: report = v.scan(args.directory+"/"+fname) report.join() except: print("[" + fname + "] Limit reached (or other error). Waiting 15s.") time.sleep(15) # Seconds. attempts = attempts + 1
#!/usr/bin/env python2 import argparse import json import os import sqlite3 as lite import time import virustotal from job_queue import Job_Queue from multiprocessing import Process jobs = Job_Queue(64) # Parameter is number of procs at a time. parser = argparse.ArgumentParser( description='Scan a directory with VirusTotal.') parser.add_argument('directory', type=str) args = parser.parse_args() def scan(fname): print("[" + fname + "] Scanning.") v = virustotal.VirusTotal( '8488f4b84e9c2010c95b17df236466a42f46e6762a2739da4caa6cf1c9178ad3') report = None attempts = 0 while report is None and attempts < 5: try: report = v.scan(args.directory + "/" + fname) report.join() except: