当前位置: 首页>>代码示例>>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;未经允许,请勿转载。