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


Python utils.parse_server_info函数代码示例

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


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

示例1: apply

    def apply(self):
        server = self.server_entry.get_text()
        try:
            (hostname, port, prefix) = parse_server_info(server)
            CFG.set('server', 'hostname', hostname)
            CFG.set('server', 'port', port)
            CFG.set('server', 'prefix', prefix)

            try:
                if not is_valid_server_info(hostname, port, prefix):
                    show_error_window(_("Unable to reach the server at %s:%s%s") %
                                      (hostname, port, prefix),
                                      self._parent.window)
                    return DONT_CHANGE
            except MissingCaCertException:
                show_error_window(_("CA certificate for subscription service has not been installed."),
                                  self._parent.window)
                return DONT_CHANGE

        except ServerUrlParseError:
            show_error_window(_("Please provide a hostname with optional port and/or prefix: hostname[:port][/prefix]"),
                              self._parent.window)
            return DONT_CHANGE

        log.info("Writing server data to rhsm.conf")
        CFG.save()
        self._backend.update()
        if self.activation_key_checkbox.get_active():
            return ACTIVATION_KEY_PAGE
        else:
            return CREDENTIALS_PAGE
开发者ID:NehaRawat,项目名称:subscription-manager,代码行数:31,代码来源:registergui.py

示例2: test_hostname_with_scheme

 def test_hostname_with_scheme(self):
     # this is the default, so test it here
     local_url = "https://subscription.rhn.redhat.com/subscription"
     (hostname, port, prefix) = parse_server_info(local_url)
     self.assertEquals("subscription.rhn.redhat.com", hostname)
     self.assertEquals(DEFAULT_PORT, port)
     self.assertEquals("/subscription", prefix)
开发者ID:cgwalters,项目名称:subscription-manager,代码行数:7,代码来源:test_utils.py

示例3: test_hostname_prefix_config

    def test_hostname_prefix_config(self):
        self.stubConfig.set("server", "prefix", "/test-prefix")

        local_url = "myhost.example.com:500"
        (hostname, port, prefix) = parse_server_info(local_url, config.Config(self.stubConfig))
        self.assertEqual("myhost.example.com", hostname)
        self.assertEqual("500", port)
        self.assertEqual("/test-prefix", prefix)
开发者ID:Januson,项目名称:subscription-manager,代码行数:8,代码来源:test_utils.py

示例4: test_hostname_port_config

    def test_hostname_port_config(self):
        self.stubConfig.set("server", "port", "600")

        local_url = "myhost.example.com/myapp"
        (hostname, port, prefix) = parse_server_info(local_url, config.Config(self.stubConfig))
        self.assertEqual("myhost.example.com", hostname)
        self.assertEqual("600", port)
        self.assertEqual("/myapp", prefix)
开发者ID:Januson,项目名称:subscription-manager,代码行数:8,代码来源:test_utils.py

示例5: test_short_name

 def test_short_name(self):
     # could argue anything could be a local hostname, and we should
     # use default port and path. You could also argue it should
     # throw an error, especially if it's not a valid hostname
     local_url = "a"
     (hostname, port, prefix) = parse_server_info(local_url)
     self.assertEquals("a", hostname)
     self.assertEquals(DEFAULT_PORT, port)
     self.assertEquals(DEFAULT_PREFIX, prefix)
开发者ID:cgwalters,项目名称:subscription-manager,代码行数:9,代码来源:test_utils.py

示例6: _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

示例7: refresh

    def refresh(self):
        """Update gui widgets to reflect state of self.data.

        This is called whenever a user returns to a Spoke to update the
        info displayed, since the data could have been changed or updated
        by another spoke or by actions that completed in the mean time.

        Here it is used to populate RHSMSpokes registerGui.RegisterInfo self.info,
        since changes there are applied to RegisterWidget self.register_widget
        by RegisterWidget itself.

        The RHSM 'ks' spoke can read values from the kickstart files read by
        initial-setup, and stored in self._addon_data. So this method will
        seed RHSMSpokes gui with any values set there.
        """

        if self._addon_data.serverurl:
            (hostname, port, prefix) = utils.parse_server_info(self._addon_data.serverurl)
            self.info.set_property('hostname', hostname)
            self.info.set_property('port', port)
            self.info.set_property('prefix', prefix)

        if self._addon_data.username:
            self.info.set_property('username',
                                   self._addon_data.username)

        if self._addon_data.password:
            self.info.set_property('password',
                                   self._addon_data.password)

        if self._addon_data.org:
            self.info.set_property('owner_key',
                                   self._addon_data.org)

        if self._addon_data.activationkeys:
            self.info.set_property('activation_keys',
                                   self._addon_data.activationkeys)

        # TODO: support a ordered list of sla preferences?
        if self._addon_data.servicelevel:
            # NOTE: using the first sla in servicelevel only currently
            self.info.set_property('preferred_sla',
                                   self._addon_data.servicelevel[0])

        if self._addon_data.force:
            self.info.set_property('force', True)

        self.register_widget.populate_screens()
开发者ID:Lorquas,项目名称:subscription-manager,代码行数:48,代码来源:rhsm_gui.py

示例8: _on_server_entry_changed

 def _on_server_entry_changed(self, widget):
     """
     Disable the activation key checkbox if the user is registering
     to hosted.
     """
     server = self.server_entry.get_text()
     try:
         (hostname, port, prefix) = parse_server_info(server)
         if re.search('subscription\.rhn\.(.*\.)*redhat\.com', hostname):
             sensitive = False
             self.activation_key_checkbox.set_active(False)
         else:
             sensitive = True
         self.activation_key_checkbox.set_sensitive(sensitive)
     except ServerUrlParseError:
         # This may seem like it should be False, but we don't want
         # the checkbox blinking on and off as the user types a value
         # that is first unparseable and then later parseable.
         self.activation_key_checkbox.set_sensitive(True)
开发者ID:NehaRawat,项目名称:subscription-manager,代码行数:19,代码来源:registergui.py

示例9: _server_selected

    def _server_selected(self):
        if self.rhn_radio.get_active():
            CFG.set('server', 'hostname', config.DEFAULT_HOSTNAME)
            CFG.set('server', 'port', config.DEFAULT_PORT)
            CFG.set('server', 'prefix', config.DEFAULT_PREFIX)
        elif self.offline_radio.get_active():
            # We'll signal the user set offline by setting an empty hostname:
            CFG.set('server', 'hostname', '')
            CFG.set('server', 'port', config.DEFAULT_PORT)
            CFG.set('server', 'prefix', config.DEFAULT_PREFIX)
        elif self.local_radio.get_active():
            local_server = self.local_entry.get_text()
            try:
                (hostname, port, prefix) = parse_server_info(local_server)
                CFG.set('server', 'hostname', hostname)
                CFG.set('server', 'port', port)
                CFG.set('server', 'prefix', prefix)

                try:
                    if not is_valid_server_info(hostname, port, prefix):
                        errorWindow(_("Unable to reach the server at %s:%s%s" %
                            (hostname, port, prefix)))
                        return
                except MissingCaCertException:
                    errorWindow(_("CA certificate for subscription service has not been installed."))
                    return

            except ServerUrlParseError:
                errorWindow(_("Please provide a hostname with optional port and/or prefix: hostname[:port][/prefix]"), self.registerWin)
                return

        log.info("Writing server data to rhsm.conf")
        CFG.save()
        self.backend.update()

        if self.offline_radio.get_active():
            # Because the user selected offline, the whole registration process
            # must end here.
            self._offline_selected()
        else:
            self._show_credentials_page()
开发者ID:bkearney,项目名称:subscription-manager,代码行数:41,代码来源:registergui.py

示例10: test_hostname_nested_prefix

 def test_hostname_nested_prefix(self):
     local_url = "myhost.example.com/myapp/subapp"
     (hostname, port, prefix) = parse_server_info(local_url)
     self.assertEquals("myhost.example.com", hostname)
     self.assertEquals("443", port)
     self.assertEquals("/myapp/subapp", prefix)
开发者ID:cgwalters,项目名称:subscription-manager,代码行数:6,代码来源:test_utils.py

示例11: test_hostname_just_slash

 def test_hostname_just_slash(self):
     local_url = "/"
     (hostname, port, prefix) = parse_server_info(local_url)
     self.assertEquals(DEFAULT_HOSTNAME, hostname)
     self.assertEquals(DEFAULT_PORT, port)
     self.assertEquals("/", prefix)
开发者ID:cgwalters,项目名称:subscription-manager,代码行数:6,代码来源:test_utils.py

示例12: test_hostname_slash_no_prefix

 def test_hostname_slash_no_prefix(self):
     local_url = "http://myhost.example.com/"
     (hostname, port, prefix) = parse_server_info(local_url)
     self.assertEquals("myhost.example.com", hostname)
     self.assertEquals("443", port)
     self.assertEquals("/", prefix)
开发者ID:cgwalters,项目名称:subscription-manager,代码行数:6,代码来源:test_utils.py

示例13: test_hostname_port

 def test_hostname_port(self):
     local_url = "myhost.example.com:500"
     (hostname, port, prefix) = parse_server_info(local_url)
     self.assertEquals("myhost.example.com", hostname)
     self.assertEquals("500", port)
     self.assertEquals(DEFAULT_PREFIX, prefix)
开发者ID:cgwalters,项目名称:subscription-manager,代码行数:6,代码来源:test_utils.py

示例14: test_host_named_http_port_prefix

 def test_host_named_http_port_prefix(self):
     local_url = "https://https:8000/prefix"
     (hostname, port, prefix) = parse_server_info(local_url)
     self.assertEquals("https", hostname)
     self.assertEquals("8000", port)
     self.assertEquals('/prefix', prefix)
开发者ID:cgwalters,项目名称:subscription-manager,代码行数:6,代码来源:test_utils.py

示例15: test_host_named_http

 def test_host_named_http(self):
     local_url = "http://http/prefix"
     (hostname, port, prefix) = parse_server_info(local_url)
     self.assertEquals("http", hostname)
     self.assertEquals(DEFAULT_PORT, port)
     self.assertEquals('/prefix', prefix)
开发者ID:cgwalters,项目名称:subscription-manager,代码行数:6,代码来源:test_utils.py


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