예제 #1
0
 def test_network_cfg_write_values_no_port(self):
     self.nc = networkConfig.NetworkConfigDialog()
     self.stubConfig = stubs.StubConfig()
     self.nc.cfg = self.stubConfig
     self.nc.enableProxyButton.set_active(True)
     self.nc.proxyEntry.set_text("example.com")
     self.nc.write_values()
예제 #2
0
 def show_proxy_error_dialog(proxy_auth_required=False):
     """
     When proxy server is set in configuration and it is not
     possible to connect to proxy server, then open dialog
     for setting proxy server.
     """
     if proxy_auth_required:
         proxy_user = rhsm_cfg.get("server", "proxy_user")
         proxy_password = rhsm_cfg.get("server", "proxy_password")
         if proxy_user or proxy_password:
             err_msg = _(
                 "Wrong proxy username or password, please check your settings."
             )
         else:
             err_msg = _(
                 "Proxy authentication required, please check your settings."
             )
     else:
         err_msg = _(
             "Proxy connection failed, please check your settings.")
     print_error(err_msg)
     error_dialog = messageWindow.ContinueDialog(
         err_msg, self._get_window())
     error_dialog.connect("response",
                          self._on_proxy_error_dialog_response)
     self.network_config_dialog = networkConfig.NetworkConfigDialog()
     # Sub-man gui will be terminated after saving settings and it is
     # necessary to start it once again.
     self.network_config_dialog.saveButton.connect(
         "clicked", self._exit)
     self.network_config_dialog.cancelButton.connect(
         "clicked", self._exit)
예제 #3
0
 def test_network_config_write_values(self):
     nc = networkConfig.NetworkConfigDialog()
     stubConfig = stubs.StubConfig()
     nc.cfg = stubConfig
     nc.xml.get_widget("enableProxyButton").set_active(True)
     nc.xml.get_widget("proxyEntry").set_text("example.com:10000")
     nc.write_values()
예제 #4
0
 def test_network_cfg_save_change_values(self):
     self.nc = networkConfig.NetworkConfigDialog()
     self.stubConfig = stubs.StubConfig()
     self.nc.cfg = self.stubConfig
     self.nc.enableProxyButton.set_active(True)
     self.nc.proxyEntry.set_text("example.com:10000")
     self.expected = {}
     self.nc.on_save_clicked(self.nc.saveButton)
     self.assertNotEquals(self.expected, self.nc.cfg.store)
 def test_network_cfg_ok_change_values(self):
     self.nc = networkConfig.NetworkConfigDialog()
     self.stubConfig = stubs.StubConfig()
     self.nc.cfg = self.stubConfig
     self.nc.xml.get_widget("enableProxyButton").set_active(True)
     self.nc.xml.get_widget("proxyEntry").set_text("example.com:10000")
     self.expected = {}
     self.nc.on_ok_clicked(self.nc.xml.get_widget("okButton"))
     self.assertNotEquals(self.expected, self.nc.cfg.store)
예제 #6
0
    def __init__(self, parent, backend):

        super(ChooseServerScreen, self).__init__("choose_server.glade", parent,
                                                 backend)

        self.button_label = _("Next")

        callbacks = {
            "on_default_button_clicked": self._on_default_button_clicked,
            "on_proxy_button_clicked": self._on_proxy_button_clicked,
        }
        self.glade.signal_autoconnect(callbacks)

        self.network_config_dialog = networkConfig.NetworkConfigDialog()
예제 #7
0
    def test_network_cfg_write_values_with_auth(self):
        self.nc = networkConfig.NetworkConfigDialog()
        self.stubConfig = stubs.StubConfig()
        self.nc.cfg = self.stubConfig
        self.nc.enableProxyButton.set_active(True)
        self.nc.proxyEntry.set_text("example.com:10000")
        self.nc.enableProxyAuthButton.set_active(True)
        self.nc.proxyUserEntry.set_text("redhatUser")
        self.nc.proxyPasswordEntry.set_text("redhatPass")
        self.nc.write_values()

        actual_user = self.nc.cfg.store['server']['proxy_user']
        actual_password = self.nc.cfg.store['server']['proxy_password']
        self.assertTrue(actual_user == "redhatUser")
        self.assertTrue(actual_password == "redhatPass")
예제 #8
0
    def __init__(self,
                 backend=None,
                 facts=None,
                 ent_dir=None,
                 prod_dir=None,
                 auto_launch_registration=False):
        super(MainWindow, self).__init__()

        self.backend = backend or Backend()
        self.identity = require(IDENTITY)

        self.facts = facts or Facts(self.backend.entitlement_dir,
                                    self.backend.product_dir)
        # We need to make sure facts are loaded immediately, some GUI operations
        # are done in separate threads, and if facts try to load in another
        # thread the virt guest detection code breaks due to hwprobe's use of
        # signals.
        self.facts.get_facts()

        log.debug("Client Versions: %s " % get_client_versions())
        # Log the server version asynchronously
        ga_GLib.idle_add(self.log_server_version,
                         self.backend.cp_provider.get_consumer_auth_cp())

        settings = self.main_window.get_settings()

        # prevent gtk from trying to save a list of recently used files, which
        # as root, causes gtk warning:
        #  "Attempting to set the permissions of `/root/.local/share/recently-used.xbel'
        # The __name__ use is just for the 'origin' value gtk uses to store
        # where a Gtk.Settings value was set.
        settings.set_long_property('gtk-recent-files-max-age', 0,
                                   "%s:%s" % (__name__, type(self).__name__))

        self.product_dir = prod_dir or self.backend.product_dir
        self.entitlement_dir = ent_dir or self.backend.entitlement_dir

        self.system_facts_dialog = factsgui.SystemFactsDialog(self.facts)

        self.preferences_dialog = PreferencesDialog(self.backend,
                                                    self._get_window())

        self.repos_dialog = RepositoriesDialog(self.backend,
                                               self._get_window())

        self.import_sub_dialog = ImportSubDialog()

        self.network_config_dialog = networkConfig.NetworkConfigDialog()
        self.network_config_dialog.saveButton.connect("clicked",
                                                      self._config_changed)

        self.redeem_dialog = redeem.RedeemDialog(self.backend)

        self.installed_tab_icon = ga_Gtk.Image()
        self.installed_tab_icon.set_from_stock(ga_Gtk.STOCK_YES,
                                               ga_Gtk.IconSize.MENU)

        self.installed_tab = InstalledProductsTab(self.backend,
                                                  self.facts,
                                                  self.installed_tab_icon,
                                                  self,
                                                  ent_dir=self.entitlement_dir,
                                                  prod_dir=self.product_dir)
        self.my_subs_tab = MySubscriptionsTab(self.backend,
                                              self.main_window,
                                              ent_dir=self.entitlement_dir,
                                              prod_dir=self.product_dir)

        self.all_subs_tab = AllSubscriptionsTab(self.backend, self.facts,
                                                self.main_window)

        hbox = ga_Gtk.HBox(spacing=6)
        hbox.pack_start(self.installed_tab_icon, False, False, 0)
        hbox.pack_start(ga_Gtk.Label(self.installed_tab.get_label()), False,
                        False, 0)
        self.notebook.append_page(self.installed_tab.get_content(), hbox)
        hbox.show_all()

        self.notebook.append_page(self.my_subs_tab.get_content(),
                                  ga_Gtk.Label(self.my_subs_tab.get_label()))

        self.connect_signals({
            "on_register_menu_item_activate": self._register_item_clicked,
            "on_unregister_menu_item_activate": self._unregister_item_clicked,
            "on_import_cert_menu_item_activate":
            self._import_cert_item_clicked,
            "on_view_facts_menu_item_activate": self._facts_item_clicked,
            "on_proxy_config_menu_item_activate":
            self._proxy_config_item_clicked,
            "on_redeem_menu_item_activate": self._redeem_item_clicked,
            "on_preferences_menu_item_activate":
            self._preferences_item_clicked,
            "on_repos_menu_item_activate": self._repos_item_clicked,
            "on_about_menu_item_activate": self._about_item_clicked,
            "on_getting_started_menu_item_activate":
            self._getting_started_item_clicked,
            "on_online_docs_menu_item_activate":
            self._online_docs_item_clicked,
            "on_quit_menu_item_activate": ga_Gtk.main_quit,
        })

        # TODO: why is this defined in the init scope?
        # When something causes cert_sorter to upate it's state, refresh the gui
        # The cert directories being updated will cause this (either noticed
        # from a timer, or via cert_sort.force_cert_check).
        def on_cert_sorter_cert_change():
            # Update installed products
            self.installed_tab.update_products()
            self.installed_tab._set_validity_status()
            # Update attached subs
            self.my_subs_tab.update_subscriptions()
            # Update main window
            self.refresh()
            # Reset repos dialog, see bz 1132919
            self.repos_dialog = RepositoriesDialog(self.backend,
                                                   self._get_window())

        self.backend.cs.add_callback(on_cert_sorter_cert_change)

        self.main_window.show_all()

        # Check to see if already registered to old RHN/Spacewalk
        # and show dialog if so
        self._check_rhn_classic()

        # Update everything with compliance data
        self.backend.cs.notify()

        # managergui needs cert_sort.cert_monitor.run_check() to run
        # on a timer to detect cert changes from outside the gui
        # (via rhsmdd for example, or manually provisioned).
        ga_GLib.timeout_add(2000, self._on_cert_check_timer)

        if auto_launch_registration and not self.registered():
            self._register_item_clicked(None)
예제 #9
0
 def setUp(self):
     SubManFixture.setUp(self)
     self.nc = networkConfig.NetworkConfigDialog()
     self.stubConfig = stubs.StubConfig()
예제 #10
0
 def test_network_cfg_write_fail(self):
     self.nc = networkConfig.NetworkConfigDialog()
     self.stubConfig = stubs.StubConfig()
     self.stubConfig.raise_io = True
     self.nc.cfg = self.stubConfig
     self.nc.write_values()
예제 #11
0
    def __init__(self, backend=None,
                 ent_dir=None, prod_dir=None,
                 auto_launch_registration=False):
        super(MainWindow, self).__init__()

        if not self.test_proxy_connection():
            print_error(_("Proxy connection failed, please check your settings."))
            error_dialog = messageWindow.ContinueDialog(_("Proxy connection failed, please check your settings."),
                                                        self._get_window())
            error_dialog.connect("response", self._on_proxy_error_dialog_response)
            self.network_config_dialog = networkConfig.NetworkConfigDialog()
            self.network_config_dialog.saveButton.connect("clicked", self._exit)
            self.network_config_dialog.cancelButton.connect("clicked", self._exit)
            return
        self.backend = backend or Backend()
        self.identity = require(IDENTITY)

        log.debug("Client Versions: %s " % get_client_versions())
        # Log the server version asynchronously
        ga_GLib.idle_add(self.log_server_version, self.backend.cp_provider.get_consumer_auth_cp())

        settings = self.main_window.get_settings()

        # prevent gtk from trying to save a list of recently used files, which
        # as root, causes gtk warning:
        #  "Attempting to set the permissions of `/root/.local/share/recently-used.xbel'
        # The __name__ use is just for the 'origin' value gtk uses to store
        # where a Gtk.Settings value was set.
        settings.set_long_property('gtk-recent-files-max-age', 0,
                                   "%s:%s" % (__name__, type(self).__name__))

        ga_Gtk.Window.set_default_icon_name("subscription-manager")

        self.product_dir = prod_dir or self.backend.product_dir
        self.entitlement_dir = ent_dir or self.backend.entitlement_dir

        self.system_facts_dialog = factsgui.SystemFactsDialog(update_callback=self._handle_facts_updated)

        self.preferences_dialog = PreferencesDialog(self.backend,
                                                    self._get_window())

        self.repos_dialog = RepositoriesDialog(self.backend, self._get_window())

        self.import_sub_dialog = ImportSubDialog()

        self.network_config_dialog = networkConfig.NetworkConfigDialog()
        self.network_config_dialog.saveButton.connect("clicked", self._config_changed)

        self.redeem_dialog = redeem.RedeemDialog(self.backend)

        self.installed_tab_icon = ga_Gtk.Image()
        self.installed_tab_icon.set_from_stock(ga_Gtk.STOCK_YES,
                ga_Gtk.IconSize.MENU)

        self.installed_tab = InstalledProductsTab(self.backend,
                                                  self.installed_tab_icon,
                                                  self,
                                                  ent_dir=self.entitlement_dir,
                                                  prod_dir=self.product_dir)

        self.my_subs_tab = MySubscriptionsTab(self.backend,
                                              self.main_window,
                                              ent_dir=self.entitlement_dir,
                                              prod_dir=self.product_dir)

        self.all_subs_tab = AllSubscriptionsTab(self.backend,
                                                self.main_window)

        hbox = ga_Gtk.HBox(spacing=6)
        hbox.pack_start(self.installed_tab_icon, False, False, 0)
        hbox.pack_start(ga_Gtk.Label(self.installed_tab.get_label()), False, False, 0)
        self.notebook.append_page(self.installed_tab.get_content(), hbox)
        hbox.show_all()

        self.notebook.append_page(self.my_subs_tab.get_content(),
                                  ga_Gtk.Label(self.my_subs_tab.get_label()))

        self.connect_signals({
            "on_register_menu_item_activate": self._register_item_clicked,
            "on_unregister_menu_item_activate": self._unregister_item_clicked,
            "on_import_cert_menu_item_activate": self._import_cert_item_clicked,
            "on_view_facts_menu_item_activate": self._facts_item_clicked,
            "on_proxy_config_menu_item_activate": self._proxy_config_item_clicked,
            "on_redeem_menu_item_activate": self._redeem_item_clicked,
            "on_preferences_menu_item_activate": self._preferences_item_clicked,
            "on_repos_menu_item_activate": self._repos_item_clicked,
            "on_about_menu_item_activate": self._about_item_clicked,
            "on_getting_started_menu_item_activate": self._getting_started_item_clicked,
            "on_online_docs_menu_item_activate": self._online_docs_item_clicked,
            "on_quit_menu_item_activate": ga_Gtk.main_quit,
        })

        # various state tracking for async operations
        self._show_overrides = False
        self._can_redeem = False

        self.backend.cs.add_callback(self.on_cert_sorter_cert_change)

        self.main_window.show_all()

        # Check to see if already registered to old RHN/Spacewalk
        # and show dialog if so
        self._check_rhn_classic()

        # Update everything with compliance data
        self.backend.cs.notify()

        # managergui needs cert_sort.cert_monitor.run_check() to run
        # on a timer to detect cert changes from outside the gui
        # (via rhsmdd for example, or manually provisioned).
        cert_monitor_thread = threading.Thread(target=self._cert_check_timer, name="CertMonitorThread")
        cert_monitor_thread.daemon = True
        cert_monitor_thread.start()

        if auto_launch_registration and not self.registered():
            self._register_item_clicked(None)
예제 #12
0
 def test_network_config_write_fail(self):
     nc = networkConfig.NetworkConfigDialog()
     stubConfig = stubs.StubConfig()
     stubConfig.raise_io = True
     nc.cfg = stubConfig
     nc.write_values()
예제 #13
0
    def __init__(self,
                 backend=None,
                 facts=None,
                 ent_dir=None,
                 prod_dir=None,
                 auto_launch_registration=False):
        super(MainWindow, self).__init__('mainwindow.glade')

        self.backend = backend or Backend()
        self.identity = require(IDENTITY)

        self.facts = facts or Facts(self.backend.entitlement_dir,
                                    self.backend.product_dir)
        # We need to make sure facts are loaded immediately, some GUI operations
        # are done in separate threads, and if facts try to load in another
        # thread the virt guest detection code breaks due to hwprobe's use of
        # signals.
        self.facts.get_facts()

        log.debug("Client Versions: %s " % get_client_versions())
        log.debug("Server Versions: %s " % get_server_versions(
            self.backend.cp_provider.get_consumer_auth_cp()))

        self.product_dir = prod_dir or self.backend.product_dir
        self.entitlement_dir = ent_dir or self.backend.entitlement_dir

        self.system_facts_dialog = factsgui.SystemFactsDialog(
            self.backend, self.facts)

        self.registration_dialog = registergui.RegisterScreen(
            self.backend, self.facts, self._get_window())

        self.preferences_dialog = PreferencesDialog(self.backend,
                                                    self._get_window())

        self.import_sub_dialog = ImportSubDialog()

        self.network_config_dialog = networkConfig.NetworkConfigDialog()
        self.network_config_dialog.xml.get_widget("closeButton").connect(
            "clicked", self._config_changed)

        self.redeem_dialog = redeem.RedeemDialog(self.backend)

        self.installed_tab_icon = gtk.Image()
        self.installed_tab_icon.set_from_stock(gtk.STOCK_YES,
                                               gtk.ICON_SIZE_MENU)

        self.installed_tab = InstalledProductsTab(self.backend,
                                                  self.facts,
                                                  self.installed_tab_icon,
                                                  self,
                                                  ent_dir=self.entitlement_dir,
                                                  prod_dir=self.product_dir)
        self.my_subs_tab = MySubscriptionsTab(self.backend,
                                              self.main_window,
                                              ent_dir=self.entitlement_dir,
                                              prod_dir=self.product_dir)

        self.all_subs_tab = AllSubscriptionsTab(self.backend, self.facts,
                                                self.main_window)

        hbox = gtk.HBox(spacing=6)
        hbox.pack_start(self.installed_tab_icon, False, False)
        hbox.pack_start(gtk.Label(self.installed_tab.get_label()), False,
                        False)
        self.notebook.append_page(self.installed_tab.get_content(), hbox)
        hbox.show_all()

        self.notebook.append_page(self.my_subs_tab.get_content(),
                                  gtk.Label(self.my_subs_tab.get_label()))

        self.glade.signal_autoconnect({
            "on_register_menu_item_activate":
            self._register_item_clicked,
            "on_unregister_menu_item_activate":
            self._unregister_item_clicked,
            "on_import_cert_menu_item_activate":
            self._import_cert_item_clicked,
            "on_view_facts_menu_item_activate":
            self._facts_item_clicked,
            "on_proxy_config_menu_item_activate":
            self._proxy_config_item_clicked,
            "on_redeem_menu_item_activate":
            self._redeem_item_clicked,
            "on_preferences_menu_item_activate":
            self._preferences_item_clicked,
            "on_about_menu_item_activate":
            self._about_item_clicked,
            "on_getting_started_menu_item_activate":
            self._getting_started_item_clicked,
            "on_online_docs_menu_item_activate":
            self._online_docs_item_clicked,
            "on_quit_menu_item_activate":
            gtk.main_quit,
        })

        def on_cert_change():
            # Update installed products
            self.installed_tab.update_products()
            self.installed_tab._set_validity_status()
            # Update attached subs
            self.my_subs_tab.update_subscriptions()
            # Update main window
            self.refresh()

        self.backend.cs.add_callback(on_cert_change)

        self.main_window.show_all()

        # Check to see if already registered to old RHN/Spacewalk
        # and show dialog if so
        self._check_rhn_classic()

        # Update everything with compliance data
        self.backend.cs.notify()

        if auto_launch_registration and not self.registered():
            self._register_item_clicked(None)
예제 #14
0
    def __init__(self, backend, consumer, facts=None, callbacks=None):
        """
        Callbacks will be executed when registration status changes.
        """
        self.backend = backend
        self.consumer = consumer
        self.facts = facts
        self.callbacks = callbacks

        self. async = AsyncBackend(self.backend)

        dic = {
            "on_register_cancel_button_clicked": self.cancel,
            "on_register_button_clicked": self.on_register_button_clicked,
            "on_proxy_config_button_clicked":
            self._on_proxy_config_button_clicked,
            "on_import_certs_button_clicked":
            self._on_import_certs_button_clicked,
            "on_rhn_radio_toggled": self._server_radio_toggled,
            "on_local_radio_toggled": self._server_radio_toggled,
            "on_offline_radio_toggled": self._server_radio_toggled,
        }

        registration_xml.signal_autoconnect(dic)
        self.registerWin = registration_xml.get_widget("register_dialog")
        self.registerWin.connect("hide", self.cancel)
        self.registerWin.connect("delete_event", self.delete_event)
        self.initializeConsumerName()

        self.uname = registration_xml.get_widget("account_login")
        self.passwd = registration_xml.get_widget("account_password")
        self.consumer_name = registration_xml.get_widget("consumer_name")
        self.skip_auto_bind = registration_xml.get_widget("skip_auto_bind")

        self.register_notebook = \
                registration_xml.get_widget("register_notebook")
        self.register_progressbar = \
                registration_xml.get_widget("register_progressbar")
        self.register_details_label = \
                registration_xml.get_widget("register_details_label")

        self.owner_treeview = registration_xml.get_widget("owner_treeview")
        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_("Organization"), renderer, text=1)
        self.owner_treeview.set_property("headers-visible", False)
        self.owner_treeview.append_column(column)

        self.environment_treeview = registration_xml.get_widget(
            "environment_treeview")
        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_("Environment"), renderer, text=1)
        self.environment_treeview.set_property("headers-visible", False)
        self.environment_treeview.append_column(column)

        self.cancel_button = registration_xml.get_widget("cancel_button")
        self.register_button = registration_xml.get_widget("register_button")

        register_tip_label = registration_xml.get_widget("registrationTip")
        register_tip_label.set_label("<small>%s</small>" % \
                get_branding().GUI_FORGOT_LOGIN_TIP)

        register_header_label = \
                registration_xml.get_widget("registrationHeader")
        register_header_label.set_label("<b>%s</b>" % \
                get_branding().GUI_REGISTRATION_HEADER)

        self.rhn_radio = registration_xml.get_widget("rhn_radio")
        self.local_radio = registration_xml.get_widget("local_radio")
        self.offline_radio = registration_xml.get_widget("offline_radio")

        self.local_entry = registration_xml.get_widget("local_entry")
        self.import_certs_button = registration_xml.get_widget(
            "import_certs_button")

        self.proxy_label = registration_xml.get_widget("proxy_label")
        self.proxy_config_button = registration_xml.get_widget(
            "proxy_config_button")

        self.network_config_dialog = networkConfig.NetworkConfigDialog()
        self.import_certs_dialog = ImportSubDialog()
예제 #15
0
    def __init__(self,
                 backend=None,
                 ent_dir=None,
                 prod_dir=None,
                 auto_launch_registration=False):
        super(MainWindow, self).__init__()

        rhsm_cfg = config.initConfig()
        proxy_server = rhsm_cfg.get("server", "proxy_hostname")
        proxy_port = int(
            rhsm_cfg.get("server", "proxy_port") or config.DEFAULT_PROXY_PORT)

        def show_proxy_error_dialog(proxy_auth_required=False):
            """
            When proxy server is set in configuration and it is not
            possible to connect to proxy server, then open dialog
            for setting proxy server.
            """
            if proxy_auth_required:
                proxy_user = rhsm_cfg.get("server", "proxy_user")
                proxy_password = rhsm_cfg.get("server", "proxy_password")
                if proxy_user or proxy_password:
                    err_msg = _(
                        "Wrong proxy username or password, please check your settings."
                    )
                else:
                    err_msg = _(
                        "Proxy authentication required, please check your settings."
                    )
            else:
                err_msg = _(
                    "Proxy connection failed, please check your settings.")
            print_error(err_msg)
            error_dialog = messageWindow.ContinueDialog(
                err_msg, self._get_window())
            error_dialog.connect("response",
                                 self._on_proxy_error_dialog_response)
            self.network_config_dialog = networkConfig.NetworkConfigDialog()
            # Sub-man gui will be terminated after saving settings and it is
            # necessary to start it once again.
            self.network_config_dialog.saveButton.connect(
                "clicked", self._exit)
            self.network_config_dialog.cancelButton.connect(
                "clicked", self._exit)

        self.backend = backend or Backend()
        cp = self.backend.cp_provider.get_consumer_auth_cp()

        if proxy_server:
            if not utils.test_proxy_reachability(proxy_server, proxy_port):
                show_proxy_error_dialog()
                return

            try:
                # Try to send to the simplest Rest API call to Candlepin server.
                # This result will be used for getting version of Candlepin server.
                # See self.log_server_version.
                cp.supports_resource("status")
            except socket.error as err:
                # See https://tools.ietf.org/html/rfc7235#section-4.3
                if "407 Proxy Authentication Required" in err.message:
                    show_proxy_error_dialog(proxy_auth_required=True)
                    return

        self.identity = require(IDENTITY)
        log.debug("Client Versions: %s " % get_client_versions())
        ga_GLib.idle_add(self.log_server_version, cp)

        settings = self.main_window.get_settings()

        # prevent gtk from trying to save a list of recently used files, which
        # as root, causes gtk warning:
        #  "Attempting to set the permissions of `/root/.local/share/recently-used.xbel'
        # The __name__ use is just for the 'origin' value gtk uses to store
        # where a Gtk.Settings value was set.
        settings.set_long_property('gtk-recent-files-max-age', 0,
                                   "%s:%s" % (__name__, type(self).__name__))

        ga_Gtk.Window.set_default_icon_name("subscription-manager")

        self.product_dir = prod_dir or self.backend.product_dir
        self.entitlement_dir = ent_dir or self.backend.entitlement_dir

        self.system_facts_dialog = factsgui.SystemFactsDialog(
            update_callback=self._handle_facts_updated)

        self.preferences_dialog = PreferencesDialog(self.backend,
                                                    self._get_window())

        self.repos_dialog = RepositoriesDialog(self.backend,
                                               self._get_window())

        self.import_sub_dialog = ImportSubDialog()

        self.network_config_dialog = networkConfig.NetworkConfigDialog()
        self.network_config_dialog.saveButton.connect("clicked",
                                                      self._config_changed)

        self.redeem_dialog = redeem.RedeemDialog(self.backend)

        self.installed_tab_icon = ga_Gtk.Image()
        self.installed_tab_icon.set_from_stock(ga_Gtk.STOCK_YES,
                                               ga_Gtk.IconSize.MENU)

        self.installed_tab = InstalledProductsTab(self.backend,
                                                  self.installed_tab_icon,
                                                  self,
                                                  ent_dir=self.entitlement_dir,
                                                  prod_dir=self.product_dir)

        self.my_subs_tab = MySubscriptionsTab(self.backend,
                                              self.main_window,
                                              ent_dir=self.entitlement_dir,
                                              prod_dir=self.product_dir)

        self.all_subs_tab = AllSubscriptionsTab(self.backend, self.main_window)

        hbox = ga_Gtk.HBox(spacing=6)
        hbox.pack_start(self.installed_tab_icon, False, False, 0)
        hbox.pack_start(ga_Gtk.Label(self.installed_tab.get_label()), False,
                        False, 0)
        self.notebook.append_page(self.installed_tab.get_content(), hbox)
        hbox.show_all()

        self.notebook.append_page(self.my_subs_tab.get_content(),
                                  ga_Gtk.Label(self.my_subs_tab.get_label()))

        self.connect_signals({
            "on_register_menu_item_activate": self._register_item_clicked,
            "on_unregister_menu_item_activate": self._unregister_item_clicked,
            "on_import_cert_menu_item_activate":
            self._import_cert_item_clicked,
            "on_view_facts_menu_item_activate": self._facts_item_clicked,
            "on_proxy_config_menu_item_activate":
            self._proxy_config_item_clicked,
            "on_redeem_menu_item_activate": self._redeem_item_clicked,
            "on_preferences_menu_item_activate":
            self._preferences_item_clicked,
            "on_repos_menu_item_activate": self._repos_item_clicked,
            "on_about_menu_item_activate": self._about_item_clicked,
            "on_getting_started_menu_item_activate":
            self._getting_started_item_clicked,
            "on_online_docs_menu_item_activate":
            self._online_docs_item_clicked,
            "on_quit_menu_item_activate": ga_Gtk.main_quit,
        })

        # various state tracking for async operations
        self._show_overrides = False
        self._can_redeem = False

        self.backend.cs.add_callback(self.on_cert_sorter_cert_change)

        self.main_window.show_all()

        # Check to see if already registered to old RHN/Spacewalk
        # and show dialog if so
        self._check_rhn_classic()

        # Update everything with compliance data
        self.backend.cs.notify()

        # managergui needs cert_sort.cert_monitor.run_check() to run
        # on a timer to detect cert changes from outside the gui
        # (via rhsmdd for example, or manually provisioned).
        cert_monitor_thread = threading.Thread(target=self._cert_check_timer,
                                               name="CertMonitorThread")
        cert_monitor_thread.daemon = True
        cert_monitor_thread.start()

        if auto_launch_registration and not self.registered():
            self._register_item_clicked(None)

        enabled_yum_plugins = YumPluginManager.enable_pkg_plugins()
        if len(enabled_yum_plugins) > 0:
            messageWindow.InfoDialog(
                YumPluginManager.warning_message(enabled_yum_plugins),
                self._get_window(),
                _("Warning - subscription-manager plugins were automatically enabled"
                  ))
예제 #16
0
    def __init__(self,
                 backend=None,
                 consumer=None,
                 facts=None,
                 ent_dir=None,
                 prod_dir=None,
                 auto_launch_registration=False):
        super(MainWindow, self).__init__('mainwindow.glade')

        self.backend = backend or Backend()
        self.consumer = consumer or Consumer()
        self.facts = facts or Facts(self.backend.entitlement_dir,
                                    self.backend.product_dir)

        log.debug("Client Versions: %s " % get_client_versions())
        log.debug("Server Versions: %s " %
                  get_server_versions(self.backend.uep))

        self.product_dir = prod_dir or self.backend.product_dir
        self.entitlement_dir = ent_dir or self.backend.entitlement_dir

        self.system_facts_dialog = factsgui.SystemFactsDialog(
            self.backend, self.consumer, self.facts)

        self.registration_dialog = registergui.RegisterScreen(
            self.backend,
            self.consumer,
            self.facts,
            callbacks=[self.registration_changed])

        self.preferences_dialog = PreferencesDialog(self.backend,
                                                    self.consumer,
                                                    self._get_window())

        self.import_sub_dialog = ImportSubDialog()

        self.network_config_dialog = networkConfig.NetworkConfigDialog()
        self.network_config_dialog.xml.get_widget("closeButton").connect(
            "clicked", self._config_changed)

        self.redeem_dialog = redeem.RedeemDialog(self.backend, self.consumer)

        self.installed_tab_icon = gtk.Image()
        self.installed_tab_icon.set_from_stock(gtk.STOCK_YES,
                                               gtk.ICON_SIZE_MENU)

        self.installed_tab = InstalledProductsTab(self.backend,
                                                  self.consumer,
                                                  self.facts,
                                                  self.installed_tab_icon,
                                                  self,
                                                  ent_dir=self.entitlement_dir,
                                                  prod_dir=self.product_dir)
        self.my_subs_tab = MySubscriptionsTab(self.backend,
                                              self.consumer,
                                              self.facts,
                                              self.main_window,
                                              ent_dir=self.entitlement_dir,
                                              prod_dir=self.product_dir)

        self.all_subs_tab = AllSubscriptionsTab(self.backend, self.consumer,
                                                self.facts, self.main_window)

        hbox = gtk.HBox(spacing=6)
        hbox.pack_start(self.installed_tab_icon, False, False)
        hbox.pack_start(gtk.Label(self.installed_tab.get_label()), False,
                        False)
        self.notebook.append_page(self.installed_tab.get_content(), hbox)
        hbox.show_all()

        self.notebook.append_page(self.my_subs_tab.get_content(),
                                  gtk.Label(self.my_subs_tab.get_label()))

        self.glade.signal_autoconnect({
            "on_register_menu_item_activate":
            self._register_item_clicked,
            "on_unregister_menu_item_activate":
            self._unregister_item_clicked,
            "on_import_cert_menu_item_activate":
            self._import_cert_item_clicked,
            "on_view_facts_menu_item_activate":
            self._facts_item_clicked,
            "on_proxy_config_menu_item_activate":
            self._proxy_config_item_clicked,
            "on_redeem_menu_item_activate":
            self._redeem_item_clicked,
            "on_preferences_menu_item_activate":
            self._preferences_item_clicked,
            "on_about_menu_item_activate":
            self._about_item_clicked,
            "on_getting_started_menu_item_activate":
            self._getting_started_item_clicked,
            "on_online_docs_menu_item_activate":
            self._online_docs_item_clicked,
            "on_quit_menu_item_activate":
            gtk.main_quit,
        })

        def on_identity_change(filemonitor):
            self.consumer.reload()
            self.refresh()

        self.backend.monitor_identity(on_identity_change)

        self.main_window.show_all()
        self.refresh()

        # Check to see if already registered to old RHN/Spacewalk
        # and show dialog if so
        self._check_rhn_classic()

        if auto_launch_registration and not self.registered():
            self._register_item_clicked(None)