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


Python managercli.handle_exception函数代码示例

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


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

示例1: test_he_unicode

 def test_he_unicode(self):
     e = Exception("Ошибка при обновлении системных данных (см. /var/log/rhsm/rhsm.log")
     #    e = FakeException(msg="Ошибка при обновлении системных данных (см. /var/log/rhsm/rhsm.log")
     try:
         managercli.handle_exception("a: %s" % e, e)
     except SystemExit, e:
         self.assertEquals(e.code, -1)
开发者ID:beav,项目名称:subscription-manager,代码行数:7,代码来源:test_managercli.py

示例2: test_he_restlib_exception_unicode

 def test_he_restlib_exception_unicode(self):
     e = connection.RestlibException(404,
         "Ошибка при обновлении системных данных (см. /var/log/rhsm/rhsm.log")
     try:
         managercli.handle_exception("обновлении", e)
     except SystemExit, e:
         self.assertEquals(e.code, -1)
开发者ID:cgwalters,项目名称:subscription-manager,代码行数:7,代码来源:test_managercli.py

示例3: test_he_ssl_wrong_host

 def test_he_ssl_wrong_host(self):
     e = SSL.Checker.WrongHost("expectedHost.example.com",
                                "actualHost.example.com",
                                "subjectAltName")
     try:
         managercli.handle_exception("huh", e)
     except SystemExit, e:
         self.assertEquals(e.code, -1)
开发者ID:cgwalters,项目名称:subscription-manager,代码行数:8,代码来源:test_managercli.py

示例4: test_he_socket_error

 def test_he_socket_error(self):
     # these error messages are bare strings, so we need to update the tests
     # if those messages change
     expected_msg = 'Network error, unable to connect to server. Please see /var/log/rhsm/rhsm.log for more information.'
     managercli.log.set_expected_msg(expected_msg)
     try:
         managercli.handle_exception(self.msg, socket.error())
     except SystemExit, e:
         self.assertEquals(e.code, -1)
开发者ID:cgwalters,项目名称:subscription-manager,代码行数:9,代码来源:test_managercli.py

示例5: test_he_ssl_error

 def test_he_ssl_error(self):
     e = SSL.SSLError()
     try:
         managercli.handle_exception("huh", e)
     except SystemExit, e:
         self.assertEquals(e.code, -1)
开发者ID:beav,项目名称:subscription-manager,代码行数:6,代码来源:test_managercli.py

示例6: test_he_network_exception

 def test_he_network_exception(self):
     e = connection.NetworkException(1337)
     try:
         managercli.handle_exception("huh", e)
     except SystemExit, e:
         self.assertEquals(e.code, -1)
开发者ID:beav,项目名称:subscription-manager,代码行数:6,代码来源:test_managercli.py

示例7: test_he_remote_server_exception

 def test_he_remote_server_exception(self):
     e = connection.RemoteServerException(1984)
     try:
         managercli.handle_exception("huh", e)
     except SystemExit, e:
         self.assertEquals(e.code, -1)
开发者ID:beav,项目名称:subscription-manager,代码行数:6,代码来源:test_managercli.py

示例8: test_he_bad_certificate

 def test_he_bad_certificate(self):
     e = connection.BadCertificateException("/road/to/nowhwere")
     try:
         managercli.handle_exception("huh", e)
     except SystemExit, e:
         self.assertEquals(e.code, -1)
开发者ID:beav,项目名称:subscription-manager,代码行数:6,代码来源:test_managercli.py

示例9: test_he_restlib_exception

 def test_he_restlib_exception(self):
     e = connection.RestlibException(404, "this is a msg")
     try:
         managercli.handle_exception("huh", e)
     except SystemExit, e:
         self.assertEquals(e.code, -1)
开发者ID:beav,项目名称:subscription-manager,代码行数:6,代码来源:test_managercli.py

示例10: test_he

 def test_he(self):
     e = FakeException()
     try:
         managercli.handle_exception(self.msg, e)
     except SystemExit, e:
         self.assertEquals(e.code, -1)
开发者ID:beav,项目名称:subscription-manager,代码行数:6,代码来源:test_managercli.py

示例11: system_exit

    ga_loader.init_ga()

except KeyboardInterrupt:
    system_exit(0, "\nUser interrupted process.")
except ImportError as err:
    system_exit(2, "Unable to find Subscription Manager module.\n"
                   "Error: %s" % err)


def main():
    # execute
    try:
        return managercli.ManagerCLI().main()
    except KeyboardInterrupt:
        system_exit(0, "\nUser interrupted process.")

    return 0


if __name__ == '__main__':
    try:
        sys.exit(abs(main() or 0))
    except SystemExit as err:
        # This is a non-exceptional exception thrown by Python 2.4, just
        # re-raise, bypassing handle_exception
        raise err
    except KeyboardInterrupt:
        system_exit(0, "\nUser interrupted process.")
    except Exception as e:
        handle_exception("exception caught in subscription-manager", e)
开发者ID:Januson,项目名称:subscription-manager,代码行数:30,代码来源:subscription_manager.py

示例12: _

                # NOTE: this will fail across filesystems. We could add a force
                # flag to for creation of a specific name with approriate
                # warnings.
                dest_dir_name = os.path.join(self.options.destination, archive_name)

                # create the dest dir, and set it's perms, this is atomic ish
                self._makedir(dest_dir_name)

                # try to rename the dir atomically
                # rename only works on the same filesystem, but it is atomic.
                os.rename(content_path, dest_dir_name)

                print _("Wrote: %s/%s") % (self.options.destination, archive_name)

        except Exception, e:
            managercli.handle_exception(_("Unable to create zip file of system information: %s") % e, e)
            sys.exit(-1)
        finally:
            if assemble_path and os.path.exists(assemble_path):
                shutil.rmtree(assemble_path, True)

    def _make_code(self):
        return datetime.now().strftime("%Y%m%d-%f")

    def _get_version_info(self):
        return {
            "server type": self.server_versions["server-type"],
            "subscription management server": self.server_versions["candlepin"],
            "subscription-manager": self.client_versions["subscription-manager"],
            "python-rhsm": self.client_versions["python-rhsm"],
        }
开发者ID:jaredjennings,项目名称:subscription-manager,代码行数:31,代码来源:debug_commands.py

示例13: system_exit

    from subscription_manager.managercli import handle_exception
except KeyboardInterrupt:
    system_exit(0, "\nUser interrupted process.")
except ImportError as err:
    system_exit(2, "Unable to find Subscription Manager module.\n"
                   "Error: %s" % err)


def main():
    # execute
    try:
        return migrate.main(five_to_six_script=True)
    except KeyboardInterrupt:
        system_exit(0, "\nUser interrupted process.")

    return 0


if __name__ == '__main__':
    try:
        sys.exit(abs(main() or 0))
    except SystemExit as e:
        # this is a non-exceptional exception thrown by Python 2.4, just
        # re-raise, bypassing handle_exception
        raise e
    except KeyboardInterrupt:
        system_exit(0, "\nUser interrupted process.")
    except Exception as e:
        handle_exception("Exception caught in sat5to6", e)
开发者ID:Januson,项目名称:subscription-manager,代码行数:29,代码来源:sat5to6.py

示例14: system_exit

    from subscription_manager.migrate import migrate
    from subscription_manager.managercli import handle_exception
except KeyboardInterrupt:
    system_exit(0, "\nUser interrupted process.")
except ImportError as err:
    system_exit(2, "Unable to find Subscription Manager module.\n"
                   "Error: %s" % err)


def main():
    # execute
    try:
        return migrate.main()
    except KeyboardInterrupt:
        system_exit(0, "\nUser interrupted process.")

    return 0


if __name__ == '__main__':
    try:
        sys.exit(abs(main() or 0))
    except SystemExit as sys_err:
        # this is a non-exceptional exception thrown by Python 2.4, just
        # re-raise, bypassing handle_exception
        raise sys_err
    except KeyboardInterrupt:
        system_exit(0, "\nUser interrupted process.")
    except Exception as err:
        handle_exception("Exception caught in rhm-migrate-classic-to-rhsm", err)
开发者ID:Januson,项目名称:subscription-manager,代码行数:30,代码来源:rhn_migrate_classic_to_rhsm.py

示例15: _do_command


#.........这里部分代码省略.........
        archive_name = "rhsm-debug-system-%s" % code
        tar_file_name = "%s.tar.gz" % archive_name
        # /var/spool/rhsm/debug/rhsm-debug-system-20131212-121234/
        content_path = os.path.join(self.assemble_path, archive_name)
        # /var/spool/rhsm/debug/rhsm-debug-system-20131212-123413.tar.gz
        tar_file_path = os.path.join(self.assemble_path, tar_file_name)

        try:
            # assemble path is in the package, so should always exist
            self._makedir(content_path)

            owner = self.cp.getOwner(consumer.uuid)

            self._write_flat_file(content_path, "consumer.json",
                                  self.cp.getConsumer(consumer.uuid))
            self._write_flat_file(content_path, "compliance.json",
                                  self.cp.getCompliance(consumer.uuid))
            self._write_flat_file(content_path, "entitlements.json",
                                  self.cp.getEntitlementList(consumer.uuid))
            self._write_flat_file(content_path, "pools.json",
                                  self.cp.getPoolsList(consumer.uuid, True, None, owner['key']))
            self._write_flat_file(content_path, "version.json",
                                  self._get_version_info())

            # FIXME: we need to anon proxy passwords?
            sos = self.options.sos
            defaults = conf.defaults()
            # sosreport collects /etc/rhsm/* and /var/*/rhsm/*, so these would
            # be redundant for sos
            if not sos:
                # copy rhsm.conf specifically
                self._copy_cert_directory("/etc/rhsm", content_path)
                self._copy_directory('/var/log/rhsm', content_path)
                self._copy_directory('/var/lib/rhsm', content_path)

            if not sos:
                self._copy_cert_directory(DEFAULT_PRODUCT_CERT_DIR, content_path)

            if defaults['productcertdir'] != conf['rhsm']['productCertDir'] or not sos:
                self._copy_cert_directory(conf['rhsm']['productCertDir'], content_path)

            if defaults['entitlementcertdir'] != conf['rhsm']['entitlementCertDir'] or not sos:
                self._copy_cert_directory(conf['rhsm']['entitlementCertDir'], content_path)

            if defaults['consumercertdir'] != conf['rhsm']['consumerCertDir'] or not sos:
                self._copy_cert_directory(conf['rhsm']['consumerCertDir'], content_path)

            # If ca_cert_dir and pluginconfdif are configured as subdirs of /etc/rhsm
            # (as is the default) we will have already copied there contents,
            # so ignore directory exists errors
            try:
                if defaults['ca_cert_dir'] != conf['rhsm']['ca_cert_dir'] or not sos:
                    self._copy_cert_directory(conf['rhsm']['ca_cert_dir'], content_path)
            except EnvironmentError as e:
                if e.errno != errno.EEXIST:
                    raise

            try:
                if defaults['pluginconfdir'] != conf['rhsm']['pluginconfdir'] or not sos:
                    self._copy_directory(conf['rhsm']['pluginconfdir'], content_path)
            except EnvironmentError as e:
                if e.errno != errno.EEXIST:
                    raise

            # build an archive by default
            if self.options.archive:
                try:
                    tf = tarfile.open(tar_file_path, "w:gz")
                    tf.add(content_path, archive_name)
                finally:
                    tf.close()

                final_path = os.path.join(self.options.destination, "rhsm-debug-system-%s.tar.gz" % code)

                self.final_destination_path = final_path

                sfm = SaferFileMove()
                sfm.move(tar_file_path, final_path)
                print(_("Wrote: %s") % final_path)
            else:
                # NOTE: this will fail across filesystems. We could add a force
                # flag to for creation of a specific name with approriate
                # warnings.
                dest_dir_name = os.path.join(self.options.destination, archive_name)

                # create the dest dir, and set it's perms, this is atomic ish
                self._makedir(dest_dir_name)

                # try to rename the dir atomically
                # rename only works on the same filesystem, but it is atomic.
                os.rename(content_path, dest_dir_name)

                print(_("Wrote: %s") % dest_dir_name)

        except Exception as e:
            managercli.handle_exception(_("Unable to create zip file of system information: %s") % e, e)
            sys.exit(os.EX_SOFTWARE)
        finally:
            if content_path and os.path.isdir(content_path):
                shutil.rmtree(content_path, True)
开发者ID:Lorquas,项目名称:subscription-manager,代码行数:101,代码来源:debug_commands.py


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