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

Python sos._函数代码示例

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

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



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

示例1: encryptResults

    def encryptResults(self):
        # make sure a report exists
        if not self.report_file:
           return False

        print _("Encrypting archive...")
        gpgname = self.report_file + ".gpg"

        try:
           keyring = self.cInfo['config'].get("general", "gpg_keyring")
        except:
           keyring = "/usr/share/sos/rhsupport.pub"

        try:
           recipient = self.cInfo['config'].get("general", "gpg_recipient")
        except:
           recipient = "[email protected]"

        p = Popen("""/usr/bin/gpg --trust-model always --batch --keyring "%s" --no-default-keyring --compress-level 0 --encrypt --recipient "%s" --output "%s" "%s" """ % (keyring, recipient, gpgname, self.report_file),
                    shell=True, stdout=PIPE, stderr=PIPE, bufsize=-1)
        stdout, stderr = p.communicate()
        if p.returncode == 0:
            os.unlink(self.report_file)
            self.report_file = gpgname
        else:
           print _("There was a problem encrypting your report.")
           sys.exit(1)
开发者ID:miclark,项目名称:sosreport,代码行数:27,代码来源:policyredhat.py


示例2: pre_work

    def pre_work(self):
        # this method will be called before the gathering begins

        localname = self.get_local_name()

        if not self.commons['cmdlineopts'].batch and not self.commons['cmdlineopts'].quiet:
            try:
                self.report_name = raw_input(_("Please enter your first initial and last name [%s]: ") % localname)

                self.ticket_number = raw_input(_("Please enter the case number that you are generating this report for: "))
                self._print()
            except:
                self._print()
                sys.exit(0)

        if len(self.report_name) == 0:
            self.report_name = localname

        if self.commons['cmdlineopts'].customer_name:
            self.report_name = self.commons['cmdlineopts'].customer_name

        if self.commons['cmdlineopts'].ticket_number:
            self.ticket_number = self.commons['cmdlineopts'].ticket_number

        self.report_name = self.sanitize_report_name(self.report_name)
        if self.ticket_number:
            self.ticket_number = self.sanitize_ticket_number(self.ticket_number)

        if (self.report_name == ""):
            self.report_name = "default"
        
        return
开发者ID:Nick-Harvey,项目名称:sosreport,代码行数:32,代码来源:__init__.py


示例3: final_work

    def final_work(self):

        # package up the results for the support organization
        if not self.opts.build:
            self.ui_log.info(_("Creating compressed archive..."))

            # compression could fail for a number of reasons
            try:
                final_filename = self.archive.finalize(self.opts.compression_type)
            except:
                if self.opts.debug:
                    raise
                else:
                    return False

            # automated submission will go here
            if not self.opts.upload:
                self.policy.display_results(final_filename)
            else:
                self.policy.upload_results(final_filename)

        else:
            self.ui_log.info(_("\n  sosreport build tree is located at : %s\n"
                            % self.archive.get_archive_path()))

        self._finish_logging()

        self.tempfile_util.clean()

        return True
开发者ID:battlemidget,项目名称:sosreport,代码行数:30,代码来源:sosreport.py


示例4: packageResults

    def packageResults(self):

        if len(self.ticketNumber):
            self.reportName = self.reportName + "." + self.ticketNumber
        else:
            self.reportName = self.reportName

        curwd = os.getcwd()
        os.chdir(os.path.dirname(self.cInfo['dstroot']))
        oldmask = os.umask(077)

        print _("Creating compressed archive...")

        if os.path.isfile("/usr/bin/xz"):
            self.report_file_ext = "tar.xz"
            self.renameResults("sosreport-%s-%s.%s" % (self.reportName, time.strftime("%Y%m%d%H%M%S"), self.report_file_ext))
            cmd = "/bin/tar -c %s | /usr/bin/xz -1 > %s" % (os.path.basename(self.cInfo['dstroot']),self.report_file)
            p = Popen(cmd, shell=True, bufsize=-1)
            sts = os.waitpid(p.pid, 0)[1]
        else:
            self.report_file_ext = "tar.bz2"
            self.renameResults("sosreport-%s-%s.%s" % (self.reportName, time.strftime("%Y%m%d%H%M%S"), self.report_file_ext))
            tarcmd = "/bin/tar -jcf %s %s" % (self.report_file, os.path.basename(self.cInfo['dstroot']))
            p = Popen(tarcmd, shell=True, stdout=PIPE, stderr=PIPE, bufsize=-1)
            output = p.communicate()[0]

        os.umask(oldmask)
        os.chdir(curwd)
        return
开发者ID:miclark,项目名称:sosreport,代码行数:29,代码来源:policyredhat.py


示例5: preWork

    def preWork(self):
        # this method will be called before the gathering begins

        localname = self.getLocalName()

        if not self.commons['cmdlineopts'].batch and not self.commons['cmdlineopts'].silent:
            try:
                self.reportName = raw_input(_("Please enter your first initial and last name [%s]: ") % localname)
                self.reportName = re.sub(r"[^a-zA-Z.0-9]", "", self.reportName)

                self.ticketNumber = raw_input(_("Please enter the case number that you are generating this report for: "))
                self.ticketNumber = re.sub(r"[^0-9]", "", self.ticketNumber)
                self._print()
            except:
                self._print()
                sys.exit(0)

        if len(self.reportName) == 0:
            self.reportName = localname

        if self.commons['cmdlineopts'].customerName:
            self.reportName = self.commons['cmdlineopts'].customerName
            self.reportName = re.sub(r"[^a-zA-Z.0-9]", "", self.reportName)

        if self.commons['cmdlineopts'].ticketNumber:
            self.ticketNumber = self.commons['cmdlineopts'].ticketNumber
            self.ticketNumber = re.sub(r"[^0-9]", "", self.ticketNumber)

        return
开发者ID:jclairem,项目名称:sosreport,代码行数:29,代码来源:__init__.py


示例6: displayResults

    def displayResults(self, final_filename=None):

        self.report_file = final_filename

        # make sure a report exists
        if not self.report_file:
           return False

        # calculate md5
        fp = open(self.report_file, "r")
        self.report_md5 = md5(fp.read()).hexdigest()
        fp.close()

        # store md5 into file
        fp = open(self.report_file + ".md5", "w")
        fp.write(self.report_md5 + "\n")
        fp.close()

        self._print()
        self._print(_("Your sosreport has been generated and saved in:\n  %s") % self.report_file)
        self._print()
        if len(self.report_md5):
            self._print(_("The md5sum is: ") + self.report_md5)
            self._print()
        self._print(_("Please send this file to your support representative."))
        self._print()
开发者ID:StatensPensjonskasse,项目名称:jboss-as,代码行数:26,代码来源:redhat.py


示例7: display_results

    def display_results(self, archive, directory, checksum):
        # Display results is called from the tail of SoSReport.final_work()
        #
        # Logging is already shutdown and all terminal output must use the
        # print() call.

        # make sure a report exists
        if not archive and not directory:
            return False

        self._print()

        if archive:
            self._print(_("Your sosreport has been generated and saved "
                        "in:\n  %s") % archive, always=True)
        else:
            self._print(_("sosreport build tree is located at : %s" %
                        directory), always=True)

        self._print()
        if checksum:
            self._print(_("The checksum is: ") + checksum)
            self._print()
            self._print(_("Please send this file to your support "
                        "representative."))
        self._print()
开发者ID:TurboTurtle,项目名称:sos,代码行数:26,代码来源:__init__.py


示例8: display_results

    def display_results(self, final_filename=None, build=False):

        # make sure a report exists
        if not final_filename:
           return False

        self._print()

        if not build:
            # store checksum into file
            fp = open(final_filename + "." + get_hash_name(), "w")
            checksum = self._create_checksum(final_filename)
            if checksum:
                fp.write(checksum + "\n")
            fp.close()

            self._print(_("Your sosreport has been generated and saved in:\n  %s") % final_filename)
        else:
            checksum = None
            self._print(_("sosreport build tree is located at : %s" % final_filename))

        self._print()
        if checksum:
            self._print(_("The checksum is: ") + checksum)
            self._print()
            self._print(_("Please send this file to your support representative."))
        self._print()
开发者ID:hspencer77,项目名称:sosreport,代码行数:27,代码来源:__init__.py


示例9: final_work

    def final_work(self):

        # package up the results for the support organization
        self.policy.package_results(self.archive.name())

        self._finish_logging()

        final_filename = self.archive.compress(self.opts.compression_type)

        # automated submission will go here
        if not self.opts.upload:
            self.policy.display_results(final_filename)
        else:
            self.policy.upload_results(final_filename)

        self.tempfile_util.clean()

        # if the user wants the sosreport chown'ed to someone else
        if self.opts.save_as:
            try:
                # get uid, this may raise KeyError if it can't lookup
                save_uid = pwd.getpwnam(self.opts.save_as).pw_uid
                # change UID, leave GID as-is, may raise OSError
                os.chown(final_filename, save_uid, -1)
            except KeyError:
                self.soslog.error(_("unable to find user %s, saving as current user" % (self.opts.save_as)))
            except OSError:
                self.soslog.error(_("unable to save report as %s, saving as current user" % (self.opts.save_as)))

        return final_filename
开发者ID:nigeljonez,项目名称:sosreport,代码行数:30,代码来源:sosreport.py


示例10: load_plugins

    def load_plugins(self):

        import sos.plugins
        helper = ImporterHelper(sos.plugins)
        plugins = helper.get_modules()
        self.plugin_names = deque()

        # validate and load plugins
        for plug in plugins:
            plugbase, ext = os.path.splitext(plug)
            try:
                plugin_classes = import_plugin(
                    plugbase, tuple(self.policy.valid_subclasses))
                if not len(plugin_classes):
                    # no valid plugin classes for this policy
                    continue

                plugin_class = self.policy.match_plugin(plugin_classes)
                if not self.policy.validate_plugin(plugin_class):
                    self.soslog.warning(
                        _("plugin %s does not validate, skipping") % plug)
                    if self.opts.verbosity > 0:
                        self._skip(plugin_class, _("does not validate"))
                        continue

                if plugin_class.requires_root and not self._is_root:
                    self.soslog.info(_("plugin %s requires root permissions"
                                       "to execute, skipping") % plug)
                    self._skip(plugin_class, _("requires root"))
                    continue

                # plug-in is valid, let's decide whether run it or not
                self.plugin_names.append(plugbase)

                if self._is_skipped(plugbase):
                    self._skip(plugin_class, _("skipped"))
                    continue

                if self._is_inactive(plugbase, plugin_class):
                    self._skip(plugin_class, _("inactive"))
                    continue

                if self._is_not_default(plugbase, plugin_class):
                    self._skip(plugin_class, _("not default"))
                    continue

                if self._is_not_specified(plugbase):
                    self._skip(plugin_class, _("not specified"))
                    continue

                self._load(plugin_class)
            except Exception as e:
                self.soslog.warning(_("plugin %s does not install, "
                                    "skipping: %s") % (plug, e))
                if self.raise_plugins:
                    raise
开发者ID:goern,项目名称:sos,代码行数:56,代码来源:sosreport.py


示例11: prework

 def prework(self):
     self.policy.pre_work()
     try:
         self.ui_log.info(_(" Setting up archive ..."))
         compression_methods = ('auto', 'zip', 'bzip2', 'gzip', 'xz')
         method = self.opts.compression_type
         if method not in compression_methods:
             compression_list = ', '.join(compression_methods)
             self.ui_log.error("")
             self.ui_log.error("Invalid compression specified: " + method)
             self.ui_log.error("Valid types are: " + compression_list)
             self.ui_log.error("")
             self._exit(1)
         self._set_archive()
         self._make_archive_paths()
         return
     except (OSError, IOError) as e:
         if e.errno in fatal_fs_errors:
             self.ui_log.error("")
             self.ui_log.error(" %s while setting up archive" % e.strerror)
             self.ui_log.error("")
         else:
             raise e
     except Exception as e:
         import traceback
         self.ui_log.error("")
         self.ui_log.error(" Unexpected exception setting up archive:")
         traceback.print_exc(e)
         self.ui_log.error(e)
     self._exit(1)
开发者ID:goern,项目名称:sos,代码行数:30,代码来源:sosreport.py


示例12: final_work

    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:
                if self.opts.debug:
                    raise
                else:
                    return False

        else:
            final_filename = self.archive.get_archive_path()

        # automated submission will go here
        if not self.opts.upload:
            self.policy.display_results(final_filename, build = self.opts.build)
        else:
            self.policy.upload_results(final_filename)

        self.tempfile_util.clean()

        return True
开发者ID:rvbaz,项目名称:sosreport,代码行数:28,代码来源:sosreport.py


示例13: final_work

 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
开发者ID:goern,项目名称:sos,代码行数:28,代码来源:sosreport.py


示例14: collect

    def collect(self):
        self.ui_log.info(_(" Running plugins. Please wait ..."))
        self.ui_log.info("")

        plugruncount = 0
        for i in zip(self.loaded_plugins):
            plugruncount += 1
            plugname, plug = i[0]
            status_line = ("  Running %d/%d: %s...        "
                           % (plugruncount, len(self.loaded_plugins),
                              plugname))
            if self.opts.verbosity == 0:
                status_line = "\r%s" % status_line
            else:
                status_line = "%s\n" % status_line
            if not self.opts.quiet:
                sys.stdout.write(status_line)
                sys.stdout.flush()
            try:
                plug.collect()
            except KeyboardInterrupt:
                raise
            except (OSError, IOError) as e:
                if e.errno in fatal_fs_errors:
                    self.ui_log.error("")
                    self.ui_log.error(" %s while collecting plugin data"
                                      % e.strerror)
                    self.ui_log.error("")
                    self._exit(1)
            except:
                if self.raise_plugins:
                    raise
                else:
                    self._log_plugin_exception(plugname)
        self.ui_log.info("")
开发者ID:goern,项目名称:sos,代码行数:35,代码来源:sosreport.py


示例15: main

def main(args):
    """The main entry point"""
    try:
        sos = SoSReport(args)

        if sos.opts.listPlugins:
            sos.list_plugins()

        sos.ensure_plugins()
        sos.batch()

        if sos.opts.diagnose:
            sos.diagnose()

        sos.prework()
        sos.setup()

        sos.ui_log.info(_(" Running plugins. Please wait ..."))
        sos.ui_log.info("")

        sos.copy_stuff()

        sos.ui_log.info("")

        if sos.opts.report:
            sos.report()
            sos.html_report()
            sos.plain_report()

        sos.postproc()
        sos.version()

        return sos.final_work()
    except SystemExit:
        return None
开发者ID:StatensPensjonskasse,项目名称:jboss-as,代码行数:35,代码来源:sosreport.py


示例16: batch

 def batch(self):
     if self.opts.batch:
         self.ui_log.info(self.msg)
     else:
         self.msg += _("Press ENTER to continue, or CTRL-C to quit.\n")
         try:
             raw_input(self.msg)
         except:
             self.ui_log.info("")
             self._exit()
开发者ID:StatensPensjonskasse,项目名称:jboss-as,代码行数:10,代码来源:sosreport.py


示例17: batch

 def batch(self):
     if self.opts.batch:
         self.ui_log.info(self.policy.get_msg())
     else:
         msg = self.policy.get_msg()
         msg += _("Press ENTER to continue, or CTRL-C to quit.\n")
         try:
             input(msg)
         except:
             self.ui_log.info("")
             self._exit()
开发者ID:goern,项目名称:sos,代码行数:11,代码来源:sosreport.py


示例18: displayResults

    def displayResults(self):
        # make sure a report exists
        if not self.report_file:
           return False

        # calculate md5
        fp = open(self.report_file, "r")
        self.report_md5 = md5(fp.read()).hexdigest()
        fp.close()

        self.renameResults("sosreport-%s-%s-%s.%s" % (self.reportName, 
                                                      time.strftime("%Y%m%d%H%M%S"),
                                                      self.report_md5[-4:], 
                                                      self.report_file_ext))

        # store md5 into file
        fp = open(self.report_file + ".md5", "w")
        fp.write(self.report_md5 + "\n")
        fp.close()

        print
        print _("Your sosreport has been generated and saved in:\n  %s") % self.report_file
        print
        if len(self.report_md5):
            print _("The md5sum is: ") + self.report_md5
            print
        print _("Please send this file to your support representative.")
        print
开发者ID:miclark,项目名称:sosreport,代码行数:28,代码来源:policyredhat.py


示例19: pre_work

    def pre_work(self):
        # this method will be called before the gathering begins

        cmdline_opts = self.commons['cmdlineopts']
        customer_name = cmdline_opts.customer_name
        localname = customer_name if customer_name else self.get_local_name()
        caseid = cmdline_opts.case_id if cmdline_opts.case_id else ""

        if not cmdline_opts.batch and not \
                cmdline_opts.quiet:
            try:
                self.report_name = input(_("Please enter your first initial "
                                         "and last name [%s]: ") % localname)

                self.case_id = input(_("Please enter the case id "
                                       "that you are generating this "
                                       "report for [%s]: ") % caseid)
                self._print()
            except:
                self._print()
                self.report_name = localname

        if len(self.report_name) == 0:
            self.report_name = localname

        if customer_name:
            self.report_name = customer_name

        if cmdline_opts.case_id:
            self.case_id = cmdline_opts.case_id

        self.report_name = self.sanitize_report_name(self.report_name)
        if self.case_id:
            self.case_id = self.sanitize_case_id(self.case_id)

        if (self.report_name == ""):
            self.report_name = "default"

        return
开发者ID:freyes,项目名称:sos,代码行数:39,代码来源:__init__.py


示例20: load_plugins

    def load_plugins(self):

        helper = ImporterHelper(package_path=os.path.join('sos', 'plugins'))
        plugins = helper.get_modules()
        self.plugin_names = deque()

        # validate and load plugins
        for plug in plugins:
            plugbase, ext = os.path.splitext(plug)
            try:
                plugin_classes = import_plugin(plugbase)

                for plugin_class in plugin_classes:
                    if not self.policy.validatePlugin(plugin_class):
                        self.soslog.debug(_("plugin %s does not validate, skipping") % plug)
                        self._skip(plugin_class, "does not validate")
                        continue

                    if plugin_class.requires_root and not self._is_root:
                        self.soslog.debug(_("plugin %s requires root permissions to execute, skipping") % plug)
                        self._skip(plugin_class, "requires root")
                        continue

                    # plug-in is valid, let's decide whether run it or not
                    self.plugin_names.append(plugbase)

                    if any((self._is_skipped(plugbase),
                            self._is_inactive(plugbase, plugin_class),
                            self._is_not_default(plugbase, plugin_class),
                            self._is_not_specified(plugbase),
                            )):
                        self._skip(plugin_class, "inactive")
                        continue

                    self._load(plugin_class)
            except Exception, e:
                self.soslog.warning(_("plugin %s does not install, skipping: %s") % (plug, e))
                if self.raise_plugins:
                    raise
开发者ID:StatensPensjonskasse,项目名称:jboss-as,代码行数:39,代码来源:sosreport.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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