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)
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
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)