Esempio n. 1
0
def phantomjs(script, args, socks_proxy_port=None, timelimit=60):
    # returns the <returncode> returned by phantomjs, or None if it timed out
    options = []
    if socks_proxy_port:
        options = ['--proxy-type=socks5', '--proxy=localhost:%s' % str(socks_proxy_port)]
    command = ['phantomjs'] + options + [script] + list(args)
    print '$ %s' % ' '.join(command)
    return timeout.run(subprocess.call, timelimit, command)
Esempio n. 2
0
def find_proxy(hostname_iterator, local_port):
    for hostname in hostname_iterator:
        process = timeout.run(start_proxy, 15, hostname, local_port)
        if process == None:
            # it must have timed out, other process would be a Popen process
            stderr('Tunnel creation timed out after 15s.')
        else:
            return process

    stderr('Could not find a valid hostname.')
    return None
Esempio n. 3
0
def phantomjs(script, args, socks_proxy_port=None, timelimit=60):
    # returns the <returncode> returned by phantomjs, or None if it timed out
    options = []
    if socks_proxy_port:
        options = [
            '--proxy-type=socks5',
            '--proxy=localhost:%s' % str(socks_proxy_port)
        ]
    command = ['phantomjs'] + options + [script] + list(args)
    print '$ %s' % ' '.join(command)
    return timeout.run(subprocess.call, timelimit, command)