def _init_proxy(self): _logger.debug('Initialize proxy') proxy = QNetworkProxy(QNetworkProxy.HttpProxy, "localhost", self._proxy_port) QNetworkProxy.setApplicationProxy(proxy) self._proxy_proc = subprocess.Popen(['python', '-m', 'tornado_proxy.proxy', str(self._proxy_port)]) atexit.register(self._proxy_proc.terminate)
def setProxy(self): inst = Jaime.getInstance() proxy_host = inst.getParam('proxy_host','') proxy_port = inst.getParam('proxy_port','') proxy_user = '' proxy_pass = '' if proxy_host and proxy_port : self.logger.info('Setting proxy to %s:%s with us/pass (%s,%s)' % (proxy_host, proxy_port, proxy_user, proxy_pass)) proxy = QNetworkProxy() proxy.setType(QNetworkProxy.Socks5Proxy) proxy.setHostName(proxy_host) proxy.setPort(int(proxy_port)) QNetworkProxy.setApplicationProxy(proxy)