• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python parse.find_python_traceback函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_find_python_traceback

    def test_find_python_traceback(self):
        def run(*args):
            return Popen(args, stdout=PIPE, stderr=PIPE).communicate()

        # sanity-check normal operations
        ok_stdout, ok_stderr = run('python', '-c', "print sorted('321')")
        self.assertEqual(ok_stdout.rstrip(), "['1', '2', '3']")
        self.assertEqual(find_python_traceback(StringIO(ok_stderr)), None)

        # Oops, can't sort a number.
        stdout, stderr = run('python', '-c', "print sorted(321)")

        # We expect something like this:
        #
         # Traceback (most recent call last):
        #   File "<string>", line 1, in <module>
        # TypeError: 'int' object is not iterable
        self.assertEqual(stdout, '')
        # save the traceback for the next step
        tb = find_python_traceback(StringIO(stderr))
        self.assertNotEqual(tb, None)
        assert isinstance(tb, list)
        # The first line ("Traceback...") is not skipped
        self.assertEqual(len(tb), 3)

        # make sure we can find the same traceback in noise
        verbose_stdout, verbose_stderr = run(
            'python', '-v', '-c', "print sorted(321)")
        self.assertEqual(verbose_stdout, '')
        self.assertNotEqual(verbose_stderr, stderr)
        verbose_tb = find_python_traceback(StringIO(verbose_stderr))
        self.assertEqual(verbose_tb, tb)
开发者ID:Asana,项目名称:mrjob,代码行数:32,代码来源:test_parse.py


示例2: _wait_for_process

    def _wait_for_process(self, proc_dict, step_num):
        # handle counters, status msgs, and other stuff on stderr
        proc = proc_dict['proc']

        stderr_lines = self._process_stderr_from_script(
            proc.stderr, step_num=step_num)
        tb_lines = find_python_traceback(stderr_lines)

        # proc.stdout isn't always defined
        if proc.stdout:
            proc.stdout.close()
        proc.stderr.close()

        returncode = proc.wait()

        if returncode != 0:
            # show counters before raising exception
            counters = self._counters[step_num]
            if counters:
                log.info(_format_counters(counters))

            # try to throw a useful exception
            if tb_lines:
                for line in tb_lines:
                    log.error(line.rstrip('\r\n'))

            reason = str(
                CalledProcessError(returncode, proc_dict['args']))
            raise StepFailedException(
                reason=reason, step_num=step_num,
                num_steps=len(self._get_steps()))
开发者ID:gitbenedict,项目名称:mrjob,代码行数:31,代码来源:local.py


示例3: _wait_for_process

    def _wait_for_process(self, proc_dict, step_num):
        # handle counters, status msgs, and other stuff on stderr
        proc = proc_dict['proc']

        stderr_lines = self._process_stderr_from_script(
            proc.stderr, step_num=step_num)
        tb_lines = find_python_traceback(stderr_lines)

        # proc.stdout isn't always defined
        if proc.stdout:
            proc.stdout.close()
        proc.stderr.close()

        returncode = proc.wait()

        if returncode != 0:
            self.print_counters([step_num + 1])
            # try to throw a useful exception
            if tb_lines:
                raise Exception(
                    'Command %r returned non-zero exit status %d:\n%s' %
                    (proc_dict['args'], returncode, ''.join(tb_lines)))
            else:
                raise Exception(
                    'Command %r returned non-zero exit status %d' %
                    (proc_dict['args'], returncode))
开发者ID:Roguelazer,项目名称:mrjob,代码行数:26,代码来源:local.py


示例4: _invoke_step

    def _invoke_step(self, args, outfile_name, env=None):
        """Run the given command, outputting into outfile, and reading
        from the previous outfile (or, for the first step, from our
        original output files).

        outfile is a path relative to our local tmp dir. commands are run
        inside self._working_dir

        We'll intelligently handle stderr from the process.
        """
        # keep the current environment because we need PATH to find binaries
        # and make PYTHONPATH work
        env = combine_local_envs(
            {'PYTHONPATH': os.getcwd()},
            os.environ,
            self._get_cmdenv(),
            env or {})

        # decide where to get input
        if self._prev_outfile is not None:
            input_paths = [self._prev_outfile]
        else:
            input_paths = []
            for path in self._input_paths:
                if path == '-':
                    input_paths.append(self._dump_stdin_to_local_file())
                else:
                    input_paths.append(path)

        # add input to the command line
        for path in input_paths:
            args.append(os.path.abspath(path))

        log.info('> %s' % cmd_line(args))

        # set up outfile
        outfile = os.path.join(self._get_local_tmp_dir(), outfile_name)
        log.info('writing to %s' % outfile)
        log.debug('')

        self._prev_outfile = outfile
        write_to = open(outfile, 'w')

        # run the process
        proc = Popen(args, stdout=write_to, stderr=PIPE,
                     cwd=self._working_dir, env=env)

        # handle counters, status msgs, and other stuff on stderr
        stderr_lines = self._process_stderr_from_script(proc.stderr)
        tb_lines = find_python_traceback(stderr_lines)

        self._print_counters()

        returncode = proc.wait()
        if returncode != 0:
            # try to throw a useful exception
            if tb_lines:
                raise Exception(
                    'Command %r returned non-zero exit status %d:\n%s' %
                    (args, returncode, ''.join(tb_lines)))
            else:
                raise Exception(
                    'Command %r returned non-zero exit status %d: %s' %
                    (args, returncode))

        # flush file descriptors
        write_to.flush()
开发者ID:boursier,项目名称:mrjob,代码行数:67,代码来源:local.py


示例5: test_find_python_traceback_with_more_stderr_2

 def test_find_python_traceback_with_more_stderr_2(self):
     total_traceback = self.EXAMPLE_STDERR_TRACEBACK_2 + 'junk\n'
     tb = find_python_traceback(StringIO(total_traceback))
     self.assertEqual(''.join(tb), self.EXAMPLE_STDERR_TRACEBACK_2)
开发者ID:Asana,项目名称:mrjob,代码行数:4,代码来源:test_parse.py


示例6: test_find_multiple_python_tracebacks

 def test_find_multiple_python_tracebacks(self):
     total_traceback = self.EXAMPLE_TRACEBACK + 'junk\n'
     tb = find_python_traceback(StringIO(total_traceback))
     self.assertEqual(''.join(tb), self.EXAMPLE_TRACEBACK)
开发者ID:Asana,项目名称:mrjob,代码行数:4,代码来源:test_parse.py


示例7: test_find_python_traceback_with_more_stderr_2

 def test_find_python_traceback_with_more_stderr_2(self):
     total_traceback = self.EXAMPLE_STDERR_TRACEBACK_2 + b'junk\n'
     tb = find_python_traceback(BytesIO(total_traceback))
     self.assertEqual(''.join(tb),
                      self.EXAMPLE_STDERR_TRACEBACK_2.decode('ascii'))
开发者ID:DanisHack,项目名称:mrjob,代码行数:5,代码来源:test_parse.py


示例8: test_find_multiple_python_tracebacks

 def test_find_multiple_python_tracebacks(self):
     total_traceback = self.EXAMPLE_TRACEBACK + b'junk\n'
     tb = find_python_traceback(BytesIO(total_traceback))
     self.assertEqual(''.join(tb),
                      self.EXAMPLE_TRACEBACK.decode('ascii'))
开发者ID:DanisHack,项目名称:mrjob,代码行数:5,代码来源:test_parse.py


示例9: parse

 def parse(self, lines):
     return find_python_traceback(lines)
开发者ID:GabbleEngineer,项目名称:mrjob,代码行数:2,代码来源:logparsers.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python parse.is_s3_uri函数代码示例发布时间:2022-05-27
下一篇:
Python options.add_basic_opts函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap