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

Python cli.system_exit函数代码示例

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

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



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

示例1: register

    def register(self, credentials, org, environment):
        # For registering the machine, use the CLI tool to reuse the username/password (because the GUI will prompt for them again)
        # Prepended a \n so translation can proceed without hitch
        print ("")
        print _("Attempting to register system to Red Hat Subscription Management...")
        cmd = [
            "subscription-manager",
            "register",
            "--username=" + credentials.username,
            "--password=" + credentials.password,
        ]
        if self.options.serverurl:
            cmd.insert(2, "--serverurl=" + self.options.serverurl)

        if org:
            cmd.append("--org=" + org)
        if environment:
            cmd.append("--environment=" + environment)

        result = subprocess.call(cmd)

        identity = inj.require(inj.IDENTITY)
        identity.reload()

        if result != 0:
            system_exit(
                2, _("\nUnable to register.\nFor further assistance, please contact Red Hat Global Support Services.")
            )
        else:
            print _("System '%s' successfully registered to Red Hat Subscription Management.\n") % identity.name
        return identity
开发者ID:jaredjennings,项目名称:subscription-manager,代码行数:31,代码来源:migrate.py


示例2: get_subscribed_channels_list

 def get_subscribed_channels_list(self):
     try:
         subscribed_channels = map(lambda x: x["label"], getChannels().channels())
     except Exception:
         log.error(traceback.format_exc())
         system_exit(1, _("Problem encountered getting the list of subscribed channels.  Exiting."))
     return subscribed_channels
开发者ID:jaredjennings,项目名称:subscription-manager,代码行数:7,代码来源:migrate.py


示例3: get_org

 def get_org(self, username):
     try:
         owner_list = self.cp.getOwnerList(username)
     except Exception, e:
         log.error(e)
         log.error(traceback.format_exc())
         system_exit(1, CONNECTION_FAILURE % e)
开发者ID:jaredjennings,项目名称:subscription-manager,代码行数:7,代码来源:migrate.py


示例4: legacy_purge

    def legacy_purge(self, rpc_session, session_key):
        system_id_path = self.rhncfg["systemIdPath"]

        log.info("Deleting system %s from legacy server...", self.system_id)
        try:
            result = rpc_session.system.deleteSystems(session_key, self.system_id)
        except Exception:
            log.exception("Could not delete system %s from legacy server" % self.system_id)
            # If we time out or get a network error, log it and keep going.
            shutil.move(system_id_path, system_id_path + ".save")
            print(_("Did not receive a completed unregistration message from legacy server for system %s.") % self.system_id)

            if self.is_hosted:
                print(_("Please investigate on the Customer Portal at https://access.redhat.com."))
            return

        if result:
            log.info("System %s deleted.  Removing system id file and disabling rhnplugin.conf", self.system_id)
            os.remove(system_id_path)
            try:
                self.disable_yum_rhn_plugin()
            except Exception:
                pass
            print(_("System successfully unregistered from legacy server."))
        else:
            # If the legacy server reports that deletion just failed, then quit.
            system_exit(1, _("Unable to unregister system from legacy server.  ") + SEE_LOG_FILE)
开发者ID:Lorquas,项目名称:subscription-manager,代码行数:27,代码来源:migrate.py


示例5: __init__

    def __init__(self, options):
        self.rhncfg = initUp2dateConfig()
        self.rhsmcfg = config.Config(initConfig())

        # Sometimes we need to send up the entire contents of the system id file
        # which is referred to in Satellite 5 nomenclature as a "certificate"
        # although it is not an X509 certificate.
        try:
            self.system_id_contents = open(self.rhncfg["systemIdPath"], 'r').read()
        except IOError:
            system_exit(os.EX_IOERR, _("Could not read legacy system id at %s") % self.rhncfg["systemIdPath"])

        self.system_id = self.get_system_id(self.system_id_contents)

        self.proxy_host = None
        self.proxy_port = None
        self.proxy_user = None
        self.proxy_pass = None

        self.cp = None
        self.db = ProductDatabase()

        self.consumer_id = None

        self.options = options
        self.is_hosted = is_hosted()
开发者ID:Lorquas,项目名称:subscription-manager,代码行数:26,代码来源:migrate.py


示例6: load_transition_data

 def load_transition_data(self, rpc_session):
     try:
         transition_data = rpc_session.system.transitionDataForSystem(self.system_id_contents)
         self.consumer_id = transition_data['uuid']
     except Exception as e:
         log.exception(e)
         system_exit(1, _("Could not retrieve system migration data from legacy server.  ") + SEE_LOG_FILE)
开发者ID:Lorquas,项目名称:subscription-manager,代码行数:7,代码来源:migrate.py


示例7: register

    def register(self, credentials, org, environment):
        # For registering the machine, use the CLI tool to reuse the username/password (because the GUI will prompt for them again)
        # Prepended a \n so translation can proceed without hitch
        print ("")
        print _("Attempting to register system to destination server...")
        cmd = ['subscription-manager', 'register', '--username=' + credentials.username, '--password=' + credentials.password]
        if self.options.destination_url:
            cmd.append('--serverurl=' + self.options.destination_url)

        if org:
            cmd.append('--org=' + org)
        if environment:
            cmd.append('--environment=' + environment)

        if self.options.five_to_six:
            if self.consumer_exists(self.consumer_id):
                cmd.append('--consumerid=' + self.consumer_id)

        if self.options.auto:
            cmd.append('--auto-attach')

        if self.options.service_level:
            servicelevel = self.select_service_level(org, self.options.service_level)
            cmd.append('--servicelevel=' + servicelevel)

        subprocess.call(cmd)

        identity = inj.require(inj.IDENTITY)
        identity.reload()

        if not identity.is_valid():
            system_exit(2, _("\nUnable to register.\nFor further assistance, please contact Red Hat Global Support Services."))

        print _("System '%s' successfully registered.\n") % identity.name
        return identity
开发者ID:stbenjam,项目名称:subscription-manager,代码行数:35,代码来源:migrate.py


示例8: transfer_http_proxy_settings

    def transfer_http_proxy_settings(self):
        if self.rhncfg["enableProxy"]:
            http_proxy = self.rhncfg["httpProxy"]
            if http_proxy[:7] == "http://":
                http_proxy = http_proxy[7:]
            try:
                self.proxy_host, self.proxy_port = http_proxy.split(":")
            except ValueError, e:
                log.exception(e)
                system_exit(1, _("Unable to read RHN proxy settings."))

            if self.rhncfg["enableProxyAuth"]:
                self.proxy_user = self.rhncfg["proxyUser"]
                self.proxy_pass = self.rhncfg["proxyPassword"]

            log.info("Using proxy %s:%s" % (self.proxy_host, self.proxy_port))
            if self.options.noproxy:
                # If the user doesn't want to use a proxy to connect to their subscription
                # management server, then remove any proxy information that may have crept in.
                self.rhsmcfg.set("server", "proxy_hostname", "")
                self.rhsmcfg.set("server", "proxy_port", "")
                self.rhsmcfg.set("server", "proxy_user", "")
                self.rhsmcfg.set("server", "proxy_password", "")
            else:
                self.rhsmcfg.set("server", "proxy_hostname", self.proxy_host)
                self.rhsmcfg.set("server", "proxy_port", self.proxy_port)
                self.rhsmcfg.set("server", "proxy_user", self.proxy_user or "")
                self.rhsmcfg.set("server", "proxy_password", self.proxy_pass or "")
            self.rhsmcfg.save()
开发者ID:jaredjennings,项目名称:subscription-manager,代码行数:29,代码来源:migrate.py


示例9: transfer_http_proxy_settings

    def transfer_http_proxy_settings(self):
        if self.rhncfg['enableProxy']:
            http_proxy = self.rhncfg['httpProxy']
            if http_proxy[:7] == "http://":
                http_proxy = http_proxy[7:]
            try:
                self.proxy_host, self.proxy_port = http_proxy.split(':')
            except ValueError as e:
                log.exception(e)
                system_exit(os.EX_CONFIG, _("Could not read legacy proxy settings.  ") + SEE_LOG_FILE)

            if self.rhncfg['enableProxyAuth']:
                self.proxy_user = self.rhncfg['proxyUser']
                self.proxy_pass = self.rhncfg['proxyPassword']

            log.info("Using proxy %s:%s" % (self.proxy_host, self.proxy_port))
            if self.options.noproxy:
                # If the user doesn't want to use a proxy to connect to their subscription
                # management server, then remove any proxy information that may have crept in.
                self.rhsmcfg['server']['proxy_hostname'] = ''
                self.rhsmcfg['server']['proxy_port'] = ''
                self.rhsmcfg['server']['proxy_user'] = ''
                self.rhsmcfg['server']['proxy_password'] = ''
            else:
                self.rhsmcfg['server']['proxy_hostname'] = self.proxy_host
                self.rhsmcfg['server']['proxy_port'] = self.proxy_port
                self.rhsmcfg['server']['proxy_user'] = self.proxy_user or ''
                self.rhsmcfg['server']['proxy_password'] = self.proxy_pass or ''
            self.rhsmcfg.persist()
开发者ID:Lorquas,项目名称:subscription-manager,代码行数:29,代码来源:migrate.py


示例10: legacy_unentitle

 def legacy_unentitle(self, rpc_session):
     system_id = open(self.rhncfg["systemIdPath"], 'r').read()
     try:
         rpc_session.system.unentitle(system_id)
     except Exception, e:
         log.exception("Could not unentitle system on Satellite 5.", e)
         system_exit(1, _("Could not unentitle system on legacy server.  ") + SEE_LOG_FILE)
开发者ID:stbenjam,项目名称:subscription-manager,代码行数:7,代码来源:migrate.py


示例11: connect_to_rhn

    def connect_to_rhn(self, credentials):
        hostname = self.rhncfg['serverURL'].split('/')[2]
        server_url = 'https://%s/rpc/api' % (hostname)

        try:
            if self.rhncfg['enableProxy']:
                proxy = "%s:%s" % (self.proxy_host, self.proxy_port)
                log.info("Using proxy %s for legacy API methods" % (proxy))
                if self.rhncfg['enableProxyAuth']:
                    proxy = "@".join(["%s:%s" % (self.proxy_user, self.proxy_pass), proxy])
            else:
                proxy = None

            rpc_session = rpclib.Server(server_url, proxy=proxy)

            ca = self.rhncfg["sslCACert"]
            rpc_session.add_trusted_cert(ca)

            if credentials.username and credentials.password:
                session_key = rpc_session.auth.login(credentials.username, credentials.password)
            else:
                session_key = None

            return (rpc_session, session_key)
        except Exception as e:
            log.exception(e)
            system_exit(1, _("Unable to authenticate to legacy server.  ") + SEE_LOG_FILE)
开发者ID:Lorquas,项目名称:subscription-manager,代码行数:27,代码来源:migrate.py


示例12: unregister_system_from_rhn_classic

    def unregister_system_from_rhn_classic(self, sc, sk):
        system_id_path = self.rhncfg["systemIdPath"]
        system_id = self.get_system_id()

        log.info("Deleting system %s from RHN Classic...", system_id)
        try:
            result = sc.system.deleteSystems(sk, system_id)
        except Exception:
            log.error("Could not delete system %s from RHN Classic" % system_id)
            log.error(traceback.format_exc())
            shutil.move(system_id_path, system_id_path + ".save")
            self.disable_yum_rhn_plugin()
            print _(
                "Did not receive a completed unregistration message from RHN Classic for system %s.\n"
                "Please investigate on the Customer Portal at https://access.redhat.com."
            ) % system_id
            return

        if result:
            log.info("System %s deleted.  Removing systemid file and disabling rhnplugin.conf", system_id)
            os.remove(system_id_path)
            self.disable_yum_rhn_plugin()
            print _("System successfully unregistered from RHN Classic.")
        else:
            system_exit(1, _("Unable to unregister system from RHN Classic.  Exiting."))
开发者ID:jaredjennings,项目名称:subscription-manager,代码行数:25,代码来源:migrate.py


示例13: select_service_level

    def select_service_level(self, org, servicelevel):
        not_supported = _("Error: The service-level command is not supported by the server.")
        try:
            levels = self.cp.getServiceLevelList(org)
        except RemoteServerException as e:
            system_exit(-1, not_supported)
        except RestlibException as e:
            if e.code == 404:
                # no need to die, just skip it
                print(not_supported)
                return None
            else:
                # server supports it but something went wrong, die.
                raise e

        # Create the sla tuple before appending the empty string to the list of
        # valid slas.
        slas = [(sla, sla) for sla in levels]
        # Display an actual message for the empty string level.
        slas.append((_("No service level preference"), ""))

        # The empty string is a valid level so append it to the list.
        levels.append("")
        if servicelevel is None or \
            servicelevel.upper() not in (level.upper() for level in levels):
            if servicelevel is not None:
                print(_("\nService level \"%s\" is not available.") % servicelevel)
            menu = Menu(slas, _("Please select a service level agreement for this system."))
            servicelevel = menu.choose()
        return servicelevel
开发者ID:Lorquas,项目名称:subscription-manager,代码行数:30,代码来源:migrate.py


示例14: check_is_org_admin

 def check_is_org_admin(self, sc, sk, username):
     try:
         roles = sc.user.listRoles(sk, username)
     except Exception:
         log.error(traceback.format_exc())
         system_exit(1, _("Problem encountered determining user roles in RHN Classic.  Exiting."))
     if "org_admin" not in roles:
         system_exit(1, _("You must be an org admin to successfully run this script."))
开发者ID:jaredjennings,项目名称:subscription-manager,代码行数:8,代码来源:migrate.py


示例15: check_for_conflicting_channels

 def check_for_conflicting_channels(self, subscribed_channels):
     jboss_channel = False
     for channel in subscribed_channels:
         if channel.startswith("jbappplatform"):
             if jboss_channel:
                 system_exit(1, _("You are subscribed to more than one jbappplatform channel."
                                 "  This script does not support that configuration."))
             jboss_channel = True
开发者ID:Lorquas,项目名称:subscription-manager,代码行数:8,代码来源:migrate.py


示例16: get_subscribed_channels_list

 def get_subscribed_channels_list(self, rpc_session, session_key):
     try:
         channels = getChannels().channels()
     except Exception as e:
         log.exception(e)
         system_exit(os.EX_SOFTWARE, _("Problem encountered getting the list of subscribed channels.  ") + SEE_LOG_FILE)
     if self.options.five_to_six:
         channels = [self.resolve_base_channel(c['label'], rpc_session, session_key) for c in channels]
     return [x['label'] for x in channels]
开发者ID:Lorquas,项目名称:subscription-manager,代码行数:9,代码来源:migrate.py


示例17: resolve_base_channel

 def resolve_base_channel(self, label, rpc_session, session_key):
     try:
         details = rpc_session.channel.software.getDetails(session_key, label)
     except Exception as e:
         log.exception(e)
         system_exit(os.EX_SOFTWARE, _("Problem encountered getting the list of subscribed channels.  ") + SEE_LOG_FILE)
     if details['clone_original']:
         return self.resolve_base_channel(details['clone_original'], rpc_session, session_key)
     return details
开发者ID:Lorquas,项目名称:subscription-manager,代码行数:9,代码来源:migrate.py


示例18: _get_connection_info

 def _get_connection_info(self):
     try:
         if self.options.destination_url is None:
             hostname = self.rhsmcfg.get('server', 'hostname')
             port = self.rhsmcfg.get_int('server', 'port')
             prefix = self.rhsmcfg.get('server', 'prefix')
         else:
             (_user, _password, hostname, port, prefix) = parse_url(self.options.destination_url, default_port=443)
     except ServerUrlParseError, e:
         system_exit(-1, _("Error parsing server URL: %s") % e.msg)
开发者ID:stbenjam,项目名称:subscription-manager,代码行数:10,代码来源:migrate.py


示例19: load_transition_data

 def load_transition_data(self, rpc_session):
     # We need to send up the entire contents of the systemid file which is referred to in
     # Satellite 5 nomenclature as a "certificate" although it is not an X509 certificate.
     system_id = open(self.rhncfg["systemIdPath"], 'r').read()
     try:
         transition_data = rpc_session.system.transitionDataForSystem(system_id)
         self.consumer_id = transition_data['uuid']
     except Exception, e:
         log.exception(e)
         system_exit(1, _("Could not retrieve system migration data from legacy server.  ") + SEE_LOG_FILE)
开发者ID:stbenjam,项目名称:subscription-manager,代码行数:10,代码来源:migrate.py


示例20: _get_connection_info

 def _get_connection_info(self):
     try:
         if self.options.serverurl is None:
             hostname = self.rhsmcfg.get("server", "hostname")
             port = self.rhsmcfg.get_int("server", "port")
             prefix = self.rhsmcfg.get("server", "prefix")
         else:
             (hostname, port, prefix) = parse_server_info(self.options.serverurl)
     except ServerUrlParseError, e:
         system_exit(-1, _("Error parsing server URL: %s") % e.msg)
开发者ID:jaredjennings,项目名称:subscription-manager,代码行数:10,代码来源:migrate.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python ga.GObject类代码示例发布时间:2022-05-27
下一篇:
Python certlib.ConsumerIdentity类代码示例发布时间: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