Exemple #1
0
    def run_test(self, all, judges, judge_identifier_l, block_list_l):
        global plist
        global threadPool
        global renig_judges
        global pool_size
        global chan_mode
        global proxy
        global theVar
        global x
        global phase_one_complete
        global phase_two_complete
        global block_list
        global judge_identifier

        test_list = []
        no_test_list = []
        return_batch = []
        block_list = block_list_l
        judge_identifier = judge_identifier_l
        thresh = 0.5

        """flags"""
        # black = dead from the start, 0/2 tests
        # 	   = for ex. failed past 2 tests

        # Test everything that hasn't failed the last two tests

        for proxy in all:
            if proxy.is_dead():
                no_test_list.append(proxy)
            else:
                test_list.append(proxy)

        if len(test_list) == 0:
            return all

        start = time.time()
        update_freq = 1000
        all = []
        test_size = 10000

        print "CHAN_MODE: ", chan_mode

        print strftime("%a, %d %b %Y %H:%M:%S", time.localtime()), "\n",
        print "Booting up proxy test"
        g = 0
        i = -1
        batch = []
        return_batch = []
        temp = []
        batch_list = []
        v = 0

        total = len(test_list)
        if pool_size > total:
            pool_size = total
        jnum = 0

        while jnum < total * 2:
            for j in judges:
                judgePool.put(j)
                jnum += 1

        while 1:
            if len(test_list) > test_size:
                batch_list.append(test_list[:test_size])
                del test_list[:test_size]
            else:
                if len(test_list) > 0:
                    batch_list.append(test_list[:])
                break

        print "Test params"
        print "Testing ", total, "total proxies."

        a = 0
        x = 0
        theVar = 0
        number_of_batches = len(batch_list)

        # ~ for batch in batch_list:
        # ~ batch_number = batch_list.index(batch)
        # ~ print "* batch", batch_number, " is ", len(batch_list[batch_number]), "proxies long"
        phase_one_complete = False
        phase_two_complete = False
        print "Starting phase_two processor..."
        self.phase_two()
        print "started."

        for batch in batch_list:
            batch_number = batch_list.index(batch)

            for proxy in batch:
                threadPool.put(proxy)
            plist = []

            while theVar < len(batch):
                if x < pool_size:
                    theVar = theVar + 1
                    self.run_in_thread(chan_mode)
                    x += 1
            theVar = 0
            x = 0
        phase_one_complete = True
        print "Phase one is done. Waiting for phase two."

        # ~ while not phase_two_complete:
        # ~ print "phase_twoPool.qsize:", phase_twoPool.qsize()
        # ~ print "threadPool.qsize:", threadPool.qsize()
        # ~ print "processedPool.qsize:", processedPool.qsize()
        # ~ time.sleep(5)

        for i in range(total):
            plist.append(processedPool.get())

        print "Elapsed Time: %s" % (time.time() - start)
        return_batch.extend(plist)
        return_batch.extend(no_test_list)

        print len(return_batch)
        return return_batch
Exemple #2
0
			print len_all, " proxies loaded."
			proxies_loaded = True
		except Exception, e:
			print e
			sys.exit()
	output = []
	test_list = []
	
	for proxy in all:
		if proxy.get_country_code().find("CA") > -1:
			output.append(proxy)
	
	output = sorted(output, key=attrgetter('resp'))
	
	for proxy in output:
		if not proxy.is_dead():
			test_list.append(proxy)
	judges = []
	jfile = []
	
	f =open("judges.txt")
	for line in f:
		jfile.append(line.strip())
	f.close()
	
	jtest = judgestest.judgesTest()
	judges = jtest.run_test(jfile)
	proxy_test = proxytest.Proxytest()
	test_result = proxy_test.run_test(test_list, judges)
	
	with open("/home/sleven/.mozilla/firefox/fqxkj6v8.default/foxyproxy.xml") as f: