當前位置: 首頁>>代碼示例>>Python>>正文


Python stem.process方法代碼示例

本文整理匯總了Python中stem.process方法的典型用法代碼示例。如果您正苦於以下問題:Python stem.process方法的具體用法?Python stem.process怎麽用?Python stem.process使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在stem的用法示例。


在下文中一共展示了stem.process方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: close

# 需要導入模塊: import stem [as 別名]
# 或者: from stem import process [as 別名]
def close(self):
        self.logger.info("Beginning Crawler exit process...")
        if "tb_driver" in dir(self):
            self.logger.info("Closing Tor Browser...")
            self.tb_driver.quit()
        if "virtual_framebuffer" in dir(self):
            self.logger.info("Closing the virtual framebuffer...")
	    # A bug in pyvirtualdisplay triggers a KeyError exception when closing a
            # virtual framebuffer if the $DISPLAY environment variable is not set.
            try:
                stop_xvfb(self.virtual_framebuffer)
            except KeyError:
                pass
        if "cell_log" in dir(self):
            self.logger.info("Closing the Tor cell stream...")
            self.cell_log.close()
        if "tor_process" in dir(self):
            self.logger.info("Killing the tor process...")
            self.tor_process.kill()
        self.logger.info("Crawler exit completed.") 
開發者ID:freedomofpress,項目名稱:fingerprint-securedrop,代碼行數:22,代碼來源:crawler.py

示例2: start_tor

# 需要導入模塊: import stem [as 別名]
# 或者: from stem import process [as 別名]
def start_tor():
  tor_process = system.pid_by_port(SOCKS_PORT)
  if  tor_process is None:
    tor_process = system.pid_by_name('tor')
  if  tor_process is None:
    tor_process = stem.process.launch_tor_with_config(
      config={
        'SocksPort': str(SOCKS_PORT),
        'ControlPort': str(CONTROL_PORT),
        'ExitNodes': '{ru}',
      },
      init_msg_handler=print_bootstrap_lines,
    )
  else:
    print "tor already running, no need to start" 
開發者ID:stevensshi,項目名稱:smart-realestate,代碼行數:17,代碼來源:tor.py

示例3: stop_process_on_name

# 需要導入模塊: import stem [as 別名]
# 或者: from stem import process [as 別名]
def stop_process_on_name():
  process =  system.pid_by_name('tor')
  if  process is not None:
    os.kill(process, 2) 
開發者ID:stevensshi,項目名稱:smart-realestate,代碼行數:6,代碼來源:tor.py

示例4: tor_new_process

# 需要導入模塊: import stem [as 別名]
# 或者: from stem import process [as 別名]
def tor_new_process():
    """
    Drops privileges to TOR_USER user and start a new Tor process
    """
    debian_tor_uid = getpwnam(TOR_USER).pw_uid
    debian_tor_gid = getpwnam(TOR_USER).pw_gid
    os.setgid(debian_tor_gid)
    os.setuid(debian_tor_uid)
    os.setegid(debian_tor_gid)
    os.seteuid(debian_tor_uid)
    os.environ['HOME'] = "/var/lib/tor"

    tor_process = stem.process.launch_tor_with_config(
      config = {
        'SocksPort': '6666',
        'ControlPort': '6969',
        'DNSPort': '9053',
        'DNSListenAddress': '127.0.0.1',
        'AutomapHostsOnResolve': '1',
        'AutomapHostsSuffixes': '.exit,.onion',
        'VirtualAddrNetwork': '10.192.0.0/10',
        'TransPort': '9040',
        'TransListenAddress': '127.0.0.1',
        'AvoidDiskWrites': '1',
        'WarnUnsafeSocks': '1',
      }) 
開發者ID:stevensshi,項目名稱:smart-realestate,代碼行數:28,代碼來源:tortp.py

示例5: restart_tor

# 需要導入模塊: import stem [as 別名]
# 或者: from stem import process [as 別名]
def restart_tor(self):
        """Kill current Tor process and run a new one."""
        self.kill_tor_proc()
        self.launch_tor_service(self.log_file) 
開發者ID:pankajb64,項目名稱:webfp-crawler-phantomjs,代碼行數:6,代碼來源:torutils_pj.py

示例6: kill_tor_proc

# 需要導入模塊: import stem [as 別名]
# 或者: from stem import process [as 別名]
def kill_tor_proc(self):
        """Kill Tor process."""
        if self.tor_process:
            wl_log.info("Killing tor process")
            self.tor_process.kill()
        if self.tmp_tor_data_dir and os.path.isdir(self.tmp_tor_data_dir):
            wl_log.info("Removing tmp tor data dir")
            shutil.rmtree(self.tmp_tor_data_dir) 
開發者ID:pankajb64,項目名稱:webfp-crawler-phantomjs,代碼行數:10,代碼來源:torutils_pj.py

示例7: launch_tor_service

# 需要導入模塊: import stem [as 別名]
# 或者: from stem import process [as 別名]
def launch_tor_service(self, logfile='/dev/null'):
        """Launch Tor service and return the process."""
        self.log_file = logfile
        self.tmp_tor_data_dir = ut.clone_dir_with_timestap(
            cm.get_tor_data_path(self.tbb_version))

        self.torrc_dict.update({'DataDirectory': self.tmp_tor_data_dir,
                                'Log': ['INFO file %s' % logfile]})

        wl_log.debug("Tor config: %s" % self.torrc_dict)
        try:
            self.tor_process = stem.process.launch_tor_with_config(
                config=self.torrc_dict,
                init_msg_handler=self.tor_log_handler,
                tor_cmd=cm.get_tor_bin_path(self.tbb_version),
                timeout=270
                )
            self.controller = Controller.from_port()
            self.controller.authenticate()
            return self.tor_process

        except stem.SocketError as exc:
            wl_log.critical("Unable to connect to tor on port %s: %s" %
                            (cm.SOCKS_PORT, exc))
            sys.exit(1)
        except:
            # most of the time this is due to another instance of
            # tor running on the system
            wl_log.critical("Error launching Tor", exc_info=True)
            sys.exit(1)

        wl_log.info("Tor running at port {0} & controller port {1}."
                    .format(cm.SOCKS_PORT, cm.CONTROLLER_PORT))
        return self.tor_process 
開發者ID:pankajb64,項目名稱:webfp-crawler-phantomjs,代碼行數:36,代碼來源:torutils_pj.py


注:本文中的stem.process方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。