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

Python log.OutputParser类代码示例

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

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



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

示例1: upload_repacks

    def upload_repacks(self):
        c = self.config
        dirs = self.query_abs_dirs()
        locales = self.query_locales()
        make = self.query_exe("make")
        base_package_name = self.query_base_package_name()
        version = self.query_version()
        upload_env = self.query_upload_env()
        success_count = total_count = 0
        buildnum = None
        if c.get('release_config_file'):
            rc = self.query_release_config()
            buildnum = rc['buildnum']
        for locale in locales:
            if self.query_failure(locale):
                self.warning("Skipping previously failed locale %s." % locale)
                continue
            total_count += 1
            if c.get('base_post_upload_cmd'):
                upload_env['POST_UPLOAD_CMD'] = c['base_post_upload_cmd'] % \
                    {'version': version, 'locale': locale, 'buildnum': str(buildnum),
                        'post_upload_extra': ' '.join(c.get('post_upload_extra', []))}
            output = self.get_output_from_command_m(
                # Ugly hack to avoid |make upload| stderr from showing up
                # as get_output_from_command errors
                "%s upload AB_CD=%s 2>&1" % (make, locale),
                cwd=dirs['abs_locales_dir'],
                env=upload_env,
                silent=True
            )
            parser = OutputParser(config=self.config, log_obj=self.log_obj,
                                  error_list=MakefileErrorList)
            parser.add_lines(output)
            if parser.num_errors:
                self.add_failure(locale, message="%s failed in make upload!" % (locale))
                continue
            package_name = base_package_name % {'locale': locale}
            r = re.compile("(http.*%s)" % package_name)
            for line in output.splitlines():
                m = r.match(line)
                if m:
                    self.upload_urls[locale] = m.groups()[0]
                    self.info("Found upload url %s" % self.upload_urls[locale])

            # XXX Move the files to a SIMPLE_NAME format until we can enable
            #     Simple names in the build system
            if self.config.get("simple_name_move"):
                # Assume an UPLOAD PATH
                upload_target = self.config["upload_env"]["UPLOAD_PATH"]
                target_path = os.path.join(upload_target, locale)
                self.mkdir_p(target_path)
                glob_name = "*.%s.android-arm.*" % locale
                for f in glob.glob(os.path.join(upload_target, glob_name)):
                    glob_extension = f[f.rfind('.'):]
                    self.move(os.path.join(f),
                              os.path.join(target_path, "target%s" % glob_extension))
                self.log("Converted uploads for %s to simple names" % locale)
            success_count += 1
        self.summarize_success_count(success_count, total_count,
                                     message="Make Upload for %d of %d locales successful.")
开发者ID:luke-chang,项目名称:gecko-1,代码行数:60,代码来源:mobile_l10n.py


示例2: upload_repacks

 def upload_repacks(self):
     c = self.config
     dirs = self.query_abs_dirs()
     locales = self.query_locales()
     make = self.query_exe("make")
     base_package_name = self.query_base_package_name()
     version = self.query_version()
     upload_env = self.query_upload_env()
     success_count = total_count = 0
     buildnum = None
     if c.get("release_config_file"):
         rc = self.query_release_config()
         buildnum = rc["buildnum"]
     for locale in locales:
         if self.query_failure(locale):
             self.warning("Skipping previously failed locale %s." % locale)
             continue
         total_count += 1
         if c.get("base_post_upload_cmd"):
             upload_env["POST_UPLOAD_CMD"] = c["base_post_upload_cmd"] % {
                 "version": version,
                 "locale": locale,
                 "buildnum": str(buildnum),
             }
         output = self.get_output_from_command_m(
             # Ugly hack to avoid |make upload| stderr from showing up
             # as get_output_from_command errors
             "%s upload AB_CD=%s 2>&1" % (make, locale),
             cwd=dirs["abs_locales_dir"],
             env=upload_env,
             silent=True,
         )
         parser = OutputParser(config=self.config, log_obj=self.log_obj, error_list=MakefileErrorList)
         parser.add_lines(output)
         if parser.num_errors:
             self.add_failure(locale, message="%s failed in make upload!" % (locale))
             continue
         package_name = base_package_name % {"locale": locale}
         r = re.compile("(http.*%s)" % package_name)
         success = False
         for line in output.splitlines():
             m = r.match(line)
             if m:
                 self.upload_urls[locale] = m.groups()[0]
                 self.info("Found upload url %s" % self.upload_urls[locale])
                 success = True
         if not success:
             self.add_failure(locale, message="Failed to detect %s url in make upload!" % (locale))
             print output
             continue
         success_count += 1
     self.summarize_success_count(success_count, total_count, message="Uploaded %d of %d binaries successfully.")
开发者ID:Belxjander,项目名称:tenfourfox,代码行数:52,代码来源:mobile_l10n.py


示例3: _query_make_variable

 def _query_make_variable(self, variable, make_args=None):
     make = self.query_exe("make")
     env = self.query_repack_env()
     dirs = self.query_abs_dirs()
     if make_args is None:
         make_args = []
     # TODO error checking
     output = self.get_output_from_command_m(
         [make, "echo-variable-%s" % variable] + make_args, cwd=dirs["abs_locales_dir"], silent=True, env=env
     )
     parser = OutputParser(config=self.config, log_obj=self.log_obj, error_list=MakefileErrorList)
     parser.add_lines(output)
     return output.strip()
开发者ID:Belxjander,项目名称:tenfourfox,代码行数:13,代码来源:mobile_l10n.py


示例4: _query_make_ident_output

 def _query_make_ident_output(self):
     """Get |make ident| output from the objdir.
     Only valid after setup is run.
     """
     if self.make_ident_output:
         return self.make_ident_output
     env = self.query_repack_env()
     dirs = self.query_abs_dirs()
     output = self.get_output_from_command_m(
         ["make", "ident"], cwd=dirs["abs_locales_dir"], env=env, silent=True, halt_on_failure=True
     )
     parser = OutputParser(config=self.config, log_obj=self.log_obj, error_list=MakefileErrorList)
     parser.add_lines(output)
     self.make_ident_output = output
     return output
开发者ID:Belxjander,项目名称:tenfourfox,代码行数:15,代码来源:mobile_l10n.py


示例5: upload_repacks

 def upload_repacks(self):
     """calls make upload <locale>"""
     config = self.config
     dirs = self.query_abs_dirs()
     locales = self.query_locales()
     version = self.query_version()
     upload_env = self.query_repack_env()
     success_count = 0
     total_count = 0
     cwd = dirs['abs_locales_dir']
     for locale in locales:
         if self.query_failure(locale):
             self.warning("Skipping previously failed locale %s." % locale)
             continue
         total_count += 1
         if config.get('base_post_upload_cmd'):
             upload_cmd = {'version': version, 'locale': locale}
             upload_cmd = config['base_post_upload_cmd'] % upload_cmd
             upload_env['POST_UPLOAD_CMD'] = upload_cmd
         target = ["upload", "AB_CD=%s" % locale]
         output = self._get_output_from_make(target, cwd=cwd, env=upload_env)
         parser = OutputParser(config=self.config, log_obj=self.log_obj,
                               error_list=MakefileErrorList)
         parser.add_lines(output)
         if parser.num_errors:
             msg = "%s failed in make upload!" % (locale)
             self.add_failure(locale, message=msg)
             continue
         package_name = self.query_base_package_name(locale)
         r = re.compile("(http.*%s)" % package_name)
         success = False
         for line in output.splitlines():
             m = r.match(line)
             if m:
                 self.upload_urls[locale] = m.groups()[0]
                 self.info("Found upload url %s" % self.upload_urls[locale])
                 success = True
         if not success:
             msg = "Failed to detect %s url in make upload!" % locale
             self.add_failure(locale, message=msg)
             self.debug(output)
             continue
         success_count += 1
         msg = "Uploaded %d of %d binaries successfully." % (success_count,
                                                             total_count)
     self.summarize_success_count(success_count, total_count, message=msg)
开发者ID:seraphs,项目名称:cssfixer,代码行数:46,代码来源:desktop_l10n.py


示例6: sign_apk

 def sign_apk(self, apk, keystore, storepass, keypass, key_alias,
              remove_signature=True, error_list=None,
              log_level=INFO, error_level=ERROR):
     """
     Signs an apk with jarsigner.
     """
     jarsigner = self.query_exe('jarsigner')
     if remove_signature:
         status = self.unsign_apk(apk)
         if status:
             self.error("Can't remove signature in %s!" % apk)
             return -1
     if error_list is None:
         error_list = JarsignerErrorList[:]
     # This needs to run silently, so no run_command() or
     # get_output_from_command() (though I could add a
     # suppress_command_echo=True or something?)
     self.log("(signing %s)" % apk, level=log_level)
     try:
         p = subprocess.Popen([jarsigner, "-keystore", keystore,
                              "-storepass", storepass,
                              "-keypass", keypass,
                              apk, key_alias],
                              stdout=subprocess.PIPE,
                              stderr=subprocess.STDOUT)
     except OSError:
         self.exception("Error while signing %s (missing %s?):" % (apk, jarsigner))
         return -2
     except ValueError:
         self.exception("Popen called with invalid arguments during signing?")
         return -3
     parser = OutputParser(config=self.config, log_obj=self.log_obj,
                           error_list=error_list)
     loop = True
     while loop:
         if p.poll() is not None:
             """Avoid losing the final lines of the log?"""
             loop = False
         for line in p.stdout:
             parser.add_lines(line)
     if parser.num_errors:
         self.log("(failure)", level=error_level)
     else:
         self.log("(success)", level=log_level)
     return parser.num_errors
开发者ID:KevinGrandon,项目名称:build-mozharness,代码行数:45,代码来源:signing.py


示例7: upload_repacks

 def upload_repacks(self):
     c = self.config
     dirs = self.query_abs_dirs()
     locales = self.query_locales()
     make = self.query_exe("make")
     base_package_name = self.query_base_package_name()
     version = self.query_version()
     upload_env = self.query_upload_env()
     success_count = total_count = 0
     buildnum = None
     if c.get('release_config_file'):
         rc = self.query_release_config()
         buildnum = rc['buildnum']
     for locale in locales:
         if self.query_failure(locale):
             self.warning("Skipping previously failed locale %s." % locale)
             continue
         total_count += 1
         if c.get('base_post_upload_cmd'):
             upload_env['POST_UPLOAD_CMD'] = c['base_post_upload_cmd'] % {'version': version, 'locale': locale, 'buildnum': str(buildnum), 'post_upload_extra': ' '.join(c.get('post_upload_extra', []))}
         output = self.get_output_from_command_m(
             # Ugly hack to avoid |make upload| stderr from showing up
             # as get_output_from_command errors
             "%s upload AB_CD=%s 2>&1" % (make, locale),
             cwd=dirs['abs_locales_dir'],
             env=upload_env,
             silent=True
         )
         parser = OutputParser(config=self.config, log_obj=self.log_obj,
                               error_list=MakefileErrorList)
         parser.add_lines(output)
         if parser.num_errors:
             self.add_failure(locale, message="%s failed in make upload!" % (locale))
             continue
         package_name = base_package_name % {'locale': locale}
         r = re.compile("(http.*%s)" % package_name)
         for line in output.splitlines():
             m = r.match(line)
             if m:
                 self.upload_urls[locale] = m.groups()[0]
                 self.info("Found upload url %s" % self.upload_urls[locale])
         success_count += 1
     self.summarize_success_count(success_count, total_count,
                                  message="Make Upload for %d of %d locales successful.")
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:44,代码来源:mobile_l10n.py


示例8: run_command

    def run_command(self, command, cwd=None, error_list=None, parse_at_end=False,
                    halt_on_failure=False, success_codes=None,
                    env=None, return_type='status', throw_exception=False):
        """Run a command, with logging and error parsing.

        TODO: parse_at_end, context_lines
        TODO: retry_interval?
        TODO: error_level_override?
        TODO: Add a copy-pastable version of |command| if it's a list.
        TODO: print env if set

        error_list example:
        [{'regex': re.compile('^Error: LOL J/K'), level=IGNORE},
         {'regex': re.compile('^Error:'), level=ERROR, contextLines='5:5'},
         {'substr': 'THE WORLD IS ENDING', level=FATAL, contextLines='20:'}
        ]
        """
        if error_list is None:
            error_list = []
        if success_codes is None:
            success_codes = [0]
        if cwd:
            if not os.path.isdir(cwd):
                level = ERROR
                if halt_on_failure:
                    level = FATAL
                self.log("Can't run command %s in non-existent directory %s!" % \
                         (command, cwd), level=level)
                return -1
            self.info("Running command: %s in %s" % (command, cwd))
        else:
            self.info("Running command: %s" % command)
        if self.config.get('noop'):
            self.info("(Dry run; skipping)")
            return
        shell = True
        if isinstance(command, list):
            shell = False
        p = subprocess.Popen(command, shell=shell, stdout=subprocess.PIPE,
                             cwd=cwd, stderr=subprocess.STDOUT, env=env)
        parser = OutputParser(config=self.config, log_obj=self.log_obj,
                              error_list=error_list)
        loop = True
        while loop:
            if p.poll() is not None:
                """Avoid losing the final lines of the log?"""
                loop = False
            for line in p.stdout:
                parser.add_lines(line)
        return_level = INFO
        if p.returncode not in success_codes:
            return_level = ERROR
            if throw_exception:
                raise subprocess.CalledProcessError(p.returncode, command)
        self.log("Return code: %d" % p.returncode, level=return_level)
        if halt_on_failure:
            if parser.num_errors or p.returncode not in success_codes:
                self.fatal("Halting on failure while running %s" % command,
                           exit_code=p.returncode)
        if return_type == 'num_errors':
            return parser.num_errors
        return p.returncode
开发者ID:Callek,项目名称:mozharness,代码行数:62,代码来源:script.py


示例9: isinstance

     self.info("Copy/paste: %s" % subprocess.list2cmdline(command))
 shell = True
 if isinstance(command, list):
     shell = False
 try:
     p = subprocess.Popen(command, shell=shell, stdout=subprocess.PIPE,
                          cwd=cwd, stderr=subprocess.STDOUT, env=env)
 except OSError, e:
     level = ERROR
     if halt_on_failure:
         level = FATAL
     self.log('caught OS error %s: %s while running %s' % (e.errno,
              e.strerror, command), level=level)
     return -1
 if output_parser is None:
     parser = OutputParser(config=self.config, log_obj=self.log_obj,
                           error_list=error_list)
 else:
     parser = output_parser
 loop = True
 while loop:
     if p.poll() is not None:
         """Avoid losing the final lines of the log?"""
         loop = False
     while True:
         line = p.stdout.readline()
         if not line:
             break
         parser.add_lines(line)
 return_level = INFO
 if p.returncode not in success_codes:
     return_level = ERROR
开发者ID:catlee,项目名称:build-mozharness,代码行数:32,代码来源:script.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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