当前位置: 首页>>代码示例>>Python>>正文


Python output.println函数代码示例

本文整理汇总了Python中test.output.println函数的典型用法代码示例。如果您正苦于以下问题:Python println函数的具体用法?Python println怎么用?Python println使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了println函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _start_tor

  def _start_tor(self, tor_cmd):
    """
    Initializes a tor process. This blocks until initialization completes or we
    error out.

    :param str tor_cmd: command to start tor with

    :raises: OSError if we either fail to create the tor process or reached a timeout without success
    """

    println("Starting tor...\n", STATUS)
    start_time = time.time()

    try:
      # wait to fully complete if we're running tests with network activity,
      # otherwise finish after local bootstraping
      complete_percent = 100 if Target.ONLINE in self.attribute_targets else 5

      # prints output from tor's stdout while it starts up
      print_init_line = lambda line: println("  %s" % line, SUBSTATUS)

      torrc_dst = os.path.join(self._test_dir, "torrc")
      self._tor_process = stem.process.launch_tor(tor_cmd, None, torrc_dst, complete_percent, print_init_line)

      runtime = time.time() - start_time
      println("  done (%i seconds)\n" % runtime, STATUS)
    except OSError, exc:
      test.output.print_error("  failed to start tor: %s\n" % exc)
      raise exc
开发者ID:sree-dev,项目名称:stem,代码行数:29,代码来源:runner.py

示例2: python3_run_tests

def python3_run_tests():
  println()
  println()

  python3_runner = os.path.join(get_python3_destination(), "run_tests.py")
  exit_status = os.system("python3 %s %s" % (python3_runner, " ".join(sys.argv[1:])))
  sys.exit(exit_status)
开发者ID:axitkhurana,项目名称:stem,代码行数:7,代码来源:util.py

示例3: run

  def run(self):
    println('  %s...' % self.label, STATUS, NO_NL)

    padding = 50 - len(self.label)
    println(' ' * padding, NO_NL)

    try:
      if self.args:
        self.result = self.runner(*self.args)
      else:
        self.result = self.runner()

      self.is_successful = True
      output_msg = 'done'

      if self.print_result and isinstance(self.result, str):
        output_msg = self.result

      println(output_msg, STATUS)

      if self.print_result and isinstance(self.result, (list, tuple)):
        for line in self.result:
          println('    %s' % line, STATUS)
    except Exception as exc:
      output_msg = str(exc)

      if not output_msg or self.is_required:
        output_msg = 'failed'

      println(output_msg, ERROR)
      self.error = exc
开发者ID:FedericoCeratto,项目名称:stem,代码行数:31,代码来源:util.py

示例4: run

  def run(self):
    println("  %s..." % self.label, STATUS, NO_NL)

    padding = 50 - len(self.label)
    println(" " * padding, NO_NL)

    try:
      if self.args:
        result = self.runner(*self.args)
      else:
        result = self.runner()

      output_msg = "done"

      if isinstance(result, str):
        output_msg = result

      println(output_msg, STATUS)

      if isinstance(result, (list, tuple)):
        for line in result:
          println("    %s" % line, STATUS)
    except Exception as exc:
      output_msg = str(exc)

      if not output_msg or self.is_required:
        output_msg = "failed"

      println(output_msg, ERROR)
      self.error = exc
开发者ID:axitkhurana,项目名称:stem,代码行数:30,代码来源:util.py

示例5: main

def main():
  start_time = time.time()

  try:
    stem.prereq.check_requirements()
  except ImportError, exc:
    println("%s\n" % exc)
    sys.exit(1)
开发者ID:sree-dev,项目名称:stem,代码行数:8,代码来源:run_tests.py

示例6: _run_test

def _run_test(test_class, output_filters, logging_buffer):
  test.output.print_divider(test_class.__module__)
  suite = unittest.TestLoader().loadTestsFromTestCase(test_class)

  test_results = StringIO.StringIO()
  run_result = unittest.TextTestRunner(test_results, verbosity=2).run(suite)

  sys.stdout.write(test.output.apply_filters(test_results.getvalue(), *output_filters))
  println()
  test.output.print_logging(logging_buffer)

  return run_result
开发者ID:sree-dev,项目名称:stem,代码行数:12,代码来源:run_tests.py

示例7: is_running

    def is_running(self):
        """
    Checks if we're running a tor test instance and that it's alive.

    :returns: True if we have a running tor test instance, False otherwise
    """

        with self._runner_lock:
            # Check for an unexpected shutdown by calling subprocess.Popen.poll(),
            # which returns the exit code or None if we're still running.

            if self._tor_process and self._tor_process.poll() is not None:
                # clean up the temporary resources and note the unexpected shutdown
                self.stop()
                println("tor shut down unexpectedly", ERROR)

            return bool(self._tor_process)
开发者ID:soult,项目名称:stem,代码行数:17,代码来源:runner.py

示例8: stop

  def stop(self):
    """
    Stops our tor test instance and cleans up any temporary resources.
    """

    with self._runner_lock:
      println('Shutting down tor... ', STATUS, NO_NL)

      if self._owner_controller:
        self._owner_controller.close()
        self._owner_controller = None

      if self._tor_process:
        # if the tor process has stopped on its own then the following raises
        # an OSError ([Errno 3] No such process)

        try:
          self._tor_process.kill()
        except OSError:
          pass

        self._tor_process.wait()  # blocks until the process is done

      # if we've made a temporary data directory then clean it up
      if self._test_dir and CONFIG['integ.test_directory'] == '':
        shutil.rmtree(self._test_dir, ignore_errors = True)

      # reverts any mocking of stem.socket.recv_message
      if self._original_recv_message:
        stem.socket.recv_message = self._original_recv_message
        self._original_recv_message = None

      # clean up our socket directory if we made one
      socket_dir = os.path.dirname(CONTROL_SOCKET_PATH)

      if os.path.exists(socket_dir):
        shutil.rmtree(socket_dir, ignore_errors = True)

      self._test_dir = ''
      self._tor_cmd = None
      self._tor_cwd = ''
      self._torrc_contents = ''
      self._custom_opts = None
      self._tor_process = None

      println('done', STATUS)
开发者ID:patrickod,项目名称:stem,代码行数:46,代码来源:runner.py

示例9: _start_tor

  def _start_tor(self, tor_cmd):
    """
    Initializes a tor process. This blocks until initialization completes or we
    error out.

    :param str tor_cmd: command to start tor with

    :raises: OSError if we either fail to create the tor process or reached a timeout without success
    """

    println('Starting %s...\n' % tor_cmd, STATUS)
    start_time = time.time()

    try:
      self._tor_process = stem.process.launch_tor(
        tor_cmd = tor_cmd,
        torrc_path = os.path.join(self._test_dir, 'torrc'),
        completion_percent = 100 if test.Target.ONLINE in self.attribute_targets else 5,
        init_msg_handler = lambda line: println('  %s' % line, SUBSTATUS),
        take_ownership = True,
      )

      runtime = time.time() - start_time
      println('  done (%i seconds)\n' % runtime, STATUS)
    except OSError as exc:
      println('  failed to start tor: %s\n' % exc, ERROR)
      raise exc
开发者ID:patrickod,项目名称:stem,代码行数:27,代码来源:runner.py

示例10: run_tasks

def run_tasks(category, *tasks):
  """
  Runs a series of :class:`test.util.Task` instances. This simply prints 'done'
  or 'failed' for each unless we fail one that is marked as being required. If
  that happens then we print its error message and call sys.exit().

  :param str category: label for the series of tasks
  :param list tasks: **Task** instances to be ran
  """

  test.output.print_divider(category, True)

  for task in tasks:
    task.run()

    if task.is_required and task.error:
      println("\n%s\n" % task.error, ERROR)
      sys.exit(1)

  println()
开发者ID:axitkhurana,项目名称:stem,代码行数:20,代码来源:util.py

示例11: run

  def run(self):
    start_time = time.time()
    println('  %s...' % self.label, STATUS, NO_NL)

    padding = 50 - len(self.label)
    println(' ' * padding, NO_NL)

    try:
      if self._is_background_task:
        def _run_wrapper(conn, runner, args):
          os.nice(15)
          conn.send(runner(*args) if args else runner())
          conn.close()

        self._background_pipe, child_pipe = multiprocessing.Pipe()
        self._background_process = multiprocessing.Process(target = _run_wrapper, args = (child_pipe, self.runner, self.args))
        self._background_process.start()
      else:
        self.result = self.runner(*self.args) if self.args else self.runner()

      self.is_successful = True
      output_msg = 'running' if self._is_background_task else 'done'

      if self.result and self.print_result and isinstance(self.result, str):
        output_msg = self.result
      elif self.print_runtime:
        output_msg += ' (%0.1fs)' % (time.time() - start_time)

      println(output_msg, STATUS)

      if self.print_result and isinstance(self.result, (list, tuple)):
        for line in self.result:
          println('    %s' % line, STATUS)
    except Exception as exc:
      output_msg = str(exc)

      if not output_msg or self.is_required:
        output_msg = 'failed'

      println(output_msg, ERROR)
      self.error = exc
开发者ID:patrickod,项目名称:stem,代码行数:41,代码来源:task.py

示例12: _start_tor

  def _start_tor(self, tor_cmd):
    """
    Initializes a tor process. This blocks until initialization completes or we
    error out.

    :param str tor_cmd: command to start tor with

    :raises: OSError if we either fail to create the tor process or reached a timeout without success
    """

    println('Starting %s...\n' % tor_cmd, STATUS)
    start_time = time.time()

    try:
      # wait to fully complete if we're running tests with network activity,
      # otherwise finish after local bootstraping

      complete_percent = 100 if Target.ONLINE in self.attribute_targets else 5

      def print_init_line(line):
        println('  %s' % line, SUBSTATUS)

      torrc_dst = os.path.join(self._test_dir, 'torrc')
      self._tor_process = stem.process.launch_tor(tor_cmd, None, torrc_dst, complete_percent, print_init_line, take_ownership = True)

      runtime = time.time() - start_time
      println('  done (%i seconds)\n' % runtime, STATUS)
    except OSError as exc:
      println('  failed to start tor: %s\n' % exc, ERROR)
      raise exc
开发者ID:sammyshj,项目名称:stem,代码行数:30,代码来源:runner.py

示例13: stop

  def stop(self):
    """
    Stops our tor test instance and cleans up any temporary resources.
    """

    with self._runner_lock:
      println("Shutting down tor... ", STATUS, NO_NL)

      if self._tor_process:
        # if the tor process has stopped on its own then the following raises
        # an OSError ([Errno 3] No such process)

        try:
          self._tor_process.kill()
        except OSError:
          pass

        self._tor_process.communicate()  # blocks until the process is done

      # if we've made a temporary data directory then clean it up
      if self._test_dir and CONFIG["integ.test_directory"] == "":
        shutil.rmtree(self._test_dir, ignore_errors = True)

      # reverts any mocking of stem.socket.recv_message
      if self._original_recv_message:
        stem.socket.recv_message = self._original_recv_message
        self._original_recv_message = None

      self._test_dir = ""
      self._tor_cmd = None
      self._tor_cwd = ""
      self._torrc_contents = ""
      self._custom_opts = None
      self._tor_process = None

      println("done", STATUS)
开发者ID:sree-dev,项目名称:stem,代码行数:36,代码来源:runner.py

示例14: _print_static_issues

def _print_static_issues(static_check_issues):
  if static_check_issues:
    println('STATIC CHECKS', STATUS)

    for file_path in static_check_issues:
      println('* %s' % file_path, STATUS)

      # Make a dict of line numbers to its issues. This is so we can both sort
      # by the line number and clear any duplicate messages.

      line_to_issues = {}

      for issue in static_check_issues[file_path]:
        line_to_issues.setdefault(issue.line_number, set()).add((issue.message, issue.line))

      for line_number in sorted(line_to_issues.keys()):
        for msg, line in line_to_issues[line_number]:
          line_count = '%-4s' % line_number
          println('  line %s - %-40s %s' % (line_count, msg, line.strip()))

      println()
开发者ID:FedericoCeratto,项目名称:stem,代码行数:21,代码来源:run_tests.py

示例15: _run_setup

  def _run_setup(self):
    """
    Makes a temporary runtime resources of our integration test instance.

    :raises: OSError if unsuccessful
    """

    # makes a temporary data directory if needed
    try:
      println("  making test directory (%s)... " % self._test_dir, STATUS, NO_NL)

      if os.path.exists(self._test_dir):
        println("skipped", STATUS)
      else:
        os.makedirs(self._test_dir)
        println("done", STATUS)
    except OSError, exc:
      test.output.print_error("failed (%s)" % exc)
      raise exc
开发者ID:sree-dev,项目名称:stem,代码行数:19,代码来源:runner.py


注:本文中的test.output.println函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。