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


Python TarFileArchive.cleanup方法代码示例

本文整理汇总了Python中sos.archive.TarFileArchive.cleanup方法的典型用法代码示例。如果您正苦于以下问题:Python TarFileArchive.cleanup方法的具体用法?Python TarFileArchive.cleanup怎么用?Python TarFileArchive.cleanup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sos.archive.TarFileArchive的用法示例。


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

示例1: SoSReport

# 需要导入模块: from sos.archive import TarFileArchive [as 别名]
# 或者: from sos.archive.TarFileArchive import cleanup [as 别名]

#.........这里部分代码省略.........
            except:
                if self.raise_plugins:
                    raise
            else:
                rfd.write(html)
        rfd.write("</body></html>")
        rfd.flush()
        self.archive.add_file(rfd.name, dest=os.path.join('sos_reports',
                                                          'sos.html'))

    def postproc(self):
        for plugname, plug in self.loaded_plugins:
            try:
                plug.postproc()
            except (OSError, IOError) as e:
                if e.errno in fatal_fs_errors:
                    self.ui_log.error("")
                    self.ui_log.error(" %s while post-processing plugin data"
                                      % e.strerror)
                    self.ui_log.error("")
                    self._exit(1)
            except:
                if self.raise_plugins:
                    raise

    def final_work(self):
        # this must come before archive creation to ensure that log
        # files are closed and cleaned up at exit.
        self._finish_logging()
        # package up the results for the support organization
        if not self.opts.build:
            print(_("Creating compressed archive..."))
            # compression could fail for a number of reasons
            try:
                final_filename = self.archive.finalize(
                    self.opts.compression_type)
            except (OSError, IOError) as e:
                if e.errno in fatal_fs_errors:
                    self.ui_log.error("")
                    self.ui_log.error(" %s while finalizing archive"
                                      % e.strerror)
                    self.ui_log.error("")
                    self._exit(1)
            except:
                if self.opts.debug:
                    raise
                else:
                    return False
        else:
            final_filename = self.archive.get_archive_path()
        self.policy.display_results(final_filename, build=self.opts.build)
        self.tempfile_util.clean()
        return True

    def verify_plugins(self):
        if not self.loaded_plugins:
            self.soslog.error(_("no valid plugins were enabled"))
            return False
        return True

    def set_global_plugin_option(self, key, value):
        self.global_plugin_options[key] = value

    def execute(self):
        try:
            self._setup_logging()
            self.policy.set_commons(self.get_commons())
            self.print_header()
            self.load_plugins()
            self._set_all_options()
            self._set_tunables()
            self._check_for_unknown_plugins()
            self._set_plugin_options()

            if self.opts.list_plugins:
                self.list_plugins()
                return True

            # verify that at least one plug-in is enabled
            if not self.verify_plugins():
                return False

            self.batch()
            self.prework()
            self.setup()
            self.collect()
            if not self.opts.report:
                self.report()
                self.html_report()
                self.plain_report()
            self.postproc()
            self.version()

            return self.final_work()
        except (SystemExit, KeyboardInterrupt):
            if self.archive:
                self.archive.cleanup()
            if self.tempfile_util:
                self.tempfile_util.clean()
            return False
开发者ID:goern,项目名称:sos,代码行数:104,代码来源:sosreport.py


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