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

Python conf.combine_envs函数代码示例

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

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



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

示例1: run_job

 def run_job(self, args=()):
     args = [sys.executable, MRTwoStepJob.mr_job_script()] + list(args) + ["--no-conf"]
     # add . to PYTHONPATH (in case mrjob isn't actually installed)
     env = combine_envs(os.environ, {"PYTHONPATH": os.path.abspath(".")})
     proc = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, env=env)
     stdout, stderr = proc.communicate(input="foo\nbar\nbar\n")
     return stdout, stderr, proc.returncode
开发者ID:ndimiduk,项目名称:mrjob,代码行数:7,代码来源:test_job.py


示例2: test_should_exit_when_invoked_as_script

 def test_should_exit_when_invoked_as_script(self):
     args = [sys.executable, MRJob.mr_job_script(), '--quux', 'baz']
     # add . to PYTHONPATH (in case mrjob isn't actually installed)
     env = combine_envs(os.environ, {'PYTHONPATH': os.path.abspath('.')})
     proc = Popen(args, stderr=PIPE, stdout=PIPE, env=env)
     proc.communicate()
     self.assertEqual(proc.returncode, 2)
开发者ID:bchess,项目名称:mrjob,代码行数:7,代码来源:test_job.py


示例3: test_should_exit_when_invoked_as_script

 def test_should_exit_when_invoked_as_script(self):
     args = [sys.executable, inspect.getsourcefile(MRJobLauncher), "--quux", "baz"]
     # add . to PYTHONPATH (in case mrjob isn't actually installed)
     env = combine_envs(os.environ, {"PYTHONPATH": os.path.abspath(".")})
     proc = Popen(args, stderr=PIPE, stdout=PIPE, env=env)
     proc.communicate()
     self.assertEqual(proc.returncode, 2)
开发者ID:duedil-ltd,项目名称:mrjob,代码行数:7,代码来源:test_launch.py


示例4: test_should_exit_when_invoked_as_script

    def test_should_exit_when_invoked_as_script(self):
        args = [sys.executable, inspect.getsourcefile(MRJobLauncher),
                '--quux', 'baz']

        # add . to PYTHONPATH (in case mrjob isn't actually installed)
        env = combine_envs(os.environ,
                           {'PYTHONPATH': mrjob_pythonpath()})
        proc = Popen(args, stderr=PIPE, stdout=PIPE, env=env)
        _, err = proc.communicate()
        self.assertEqual(proc.returncode, 2, err)
开发者ID:etiennebatise,项目名称:mrjob,代码行数:10,代码来源:test_launch.py


示例5: test_paths

 def test_paths(self):
     assert_equal(combine_envs(
         {'PATH': '/bin:/usr/bin',
          'PYTHONPATH': '/usr/lib/python/site-packages',
          'PS1': '> '},
         {'PATH': '/home/dave/bin',
          'PYTHONPATH': '/home/dave/python',
          'CLASSPATH': '/home/dave/java',
          'PS1': '\w> '}),
         {'PATH': '/home/dave/bin:/bin:/usr/bin',
          'PYTHONPATH': '/home/dave/python:/usr/lib/python/site-packages',
          'CLASSPATH': '/home/dave/java',
          'PS1': '\w> '})
开发者ID:gimlids,项目名称:LTPM,代码行数:13,代码来源:conf_test.py


示例6: test_clear_paths

 def test_clear_paths(self):
     self.assertEqual(
         combine_envs(
             {'PATH': '/bin:/usr/bin',
              'PYTHONPATH': '/usr/lib/python/site-packages',
              'PS1': '> '},
             {'PATH': ClearedValue('/home/dave/bin'),
              'PYTHONPATH': ClearedValue(None),
              'CLASSPATH': '/home/dave/java',
              'PS1': '\w> '}),
         {'PATH': '/home/dave/bin',
          'CLASSPATH': '/home/dave/java',
          'PS1': '\w> '})
开发者ID:Affirm,项目名称:mrjob,代码行数:13,代码来源:test_conf.py


示例7: test_clear_paths

 def test_clear_paths(self):
     self.assertEqual(
         combine_envs(
             {"PATH": "/bin:/usr/bin", "PYTHONPATH": "/usr/lib/python/site-packages", "PS1": "> "},
             {
                 "PATH": ClearedValue("/home/dave/bin"),
                 "PYTHONPATH": ClearedValue(None),
                 "CLASSPATH": "/home/dave/java",
                 "PS1": "\w> ",
             },
         ),
         {"PATH": "/home/dave/bin", "CLASSPATH": "/home/dave/java", "PS1": "\w> "},
     )
开发者ID:kartheek6,项目名称:mrjob,代码行数:13,代码来源:test_conf.py


示例8: test_skip_None

 def test_skip_None(self):
     assert_equal(combine_envs(None, {'USER': 'dave'}, None,
                               {'TERM': 'xterm'}, None),
                  {'USER': 'dave', 'TERM': 'xterm'})
开发者ID:gimlids,项目名称:LTPM,代码行数:4,代码来源:conf_test.py


示例9: test_later_values_take_precedence

 def test_later_values_take_precedence(self):
     assert_equal(
         combine_envs({'TMPDIR': '/tmp', 'HOME': '/home/dave'},
                      {'TMPDIR': '/var/tmp'}),
         {'TMPDIR': '/var/tmp', 'HOME': '/home/dave'})
开发者ID:gimlids,项目名称:LTPM,代码行数:5,代码来源:conf_test.py


示例10: test_empty

 def test_empty(self):
     assert_equal(combine_envs(), {})
开发者ID:gimlids,项目名称:LTPM,代码行数:2,代码来源:conf_test.py


示例11: test_empty

 def test_empty(self):
     self.assertEqual(combine_envs(), {})
开发者ID:icio,项目名称:mrjob,代码行数:2,代码来源:test_conf.py


示例12: test_skip_None

 def test_skip_None(self):
     self.assertEqual(
         combine_envs(None, {"USER": "dave"}, None, {"TERM": "xterm"}, None), {"USER": "dave", "TERM": "xterm"}
     )
开发者ID:nyccto,项目名称:mrjob,代码行数:4,代码来源:test_conf.py


示例13: test_later_values_take_precedence

 def test_later_values_take_precedence(self):
     self.assertEqual(
         combine_envs({"TMPDIR": "/tmp", "HOME": "/home/dave"}, {"TMPDIR": "/var/tmp"}),
         {"TMPDIR": "/var/tmp", "HOME": "/home/dave"},
     )
开发者ID:nyccto,项目名称:mrjob,代码行数:5,代码来源:test_conf.py


示例14: _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_envs(
            {'PYTHONPATH': os.getcwd()},
            os.environ,
            self._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:atiw003,项目名称:mrjob,代码行数:67,代码来源:local.py


示例15: _add_python_archive

 def _add_python_archive(self, path):
     file_dict = self._add_archive_for_upload(path)
     log.debug('adding %s to PYTHONPATH' % file_dict['name'])
     self._cmdenv = combine_envs(
         self._cmdenv, {'PYTHONPATH': file_dict['name']})
     self._python_archives.append(file_dict)
开发者ID:atiw003,项目名称:mrjob,代码行数:6,代码来源:runner.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python conf.combine_lists函数代码示例发布时间:2022-05-27
下一篇:
Python conf.combine_dicts函数代码示例发布时间: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