def __init__(self): """ Create a new firstboot Module for the 'register' screen. """ super(moduleClass, self).__init__() dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) GLib.threads_init() dbus.mainloop.glib.threads_init() self.mode = constants.MODE_REGULAR self.title = _("Subscription Management Registration") self.sidebarTitle = _("Subscription Registration") self.priority = 200.1 # NOTE: all of this is copied form former firstboot_base module # and may no longer be needed # set this so subclasses can override behaviour if needed self._is_compat = False reg_info = registergui.RegisterInfo() self.backend = managergui.Backend() self.plugin_manager = inj.require(inj.PLUGIN_MANAGER) self.register_widget = registergui.FirstbootWidget( self.backend, reg_info) self.register_widget.connect("notify::screen-ready", self._on_screen_ready_change) # Will be False if we are on an older RHEL version where # rhn-client-tools already does some things so we don't have to. self.standalone = True distribution = HardwareCollector().get_distribution() log.debug("Distribution: %s" % str(distribution)) try: dist_version = float(distribution[1]) # We run this for Fedora as well, but all we really care about here # is if this is prior to RHEL 7, so this comparison should be safe. if dist_version < 7: self.standalone = False except Exception as e: log.error("Unable to parse a distribution version.") log.exception(e) log.debug("Running standalone firstboot: %s" % self.standalone) self.manual_message = None self._skip_apply_for_page_jump = False self._cached_credentials = None self._registration_finished = False self.interface = None self.finished = False self.proxies_were_enabled_from_gui = None self._apply_result = constants.RESULT_FAILURE self.page_status = constants.RESULT_FAILURE
def __init__(self): """ Create a new firstboot Module for the 'register' screen. """ super(moduleClass, self).__init__() dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) GLib.threads_init() dbus.mainloop.glib.threads_init() self.mode = constants.MODE_REGULAR self.title = _("Subscription Management Registration") self.sidebarTitle = _("Subscription Registration") self.priority = 200.1 # NOTE: all of this is copied form former firstboot_base module # and may no longer be needed # set this so subclasses can override behaviour if needed self._is_compat = False reg_info = registergui.RegisterInfo() self.backend = managergui.Backend() self.plugin_manager = inj.require(inj.PLUGIN_MANAGER) self.register_widget = registergui.FirstbootWidget(self.backend, reg_info) self.register_widget.connect("notify::screen-ready", self._on_screen_ready_change) # Will be False if we are on an older RHEL version where # rhn-client-tools already does some things so we don't have to. self.standalone = True distribution = HardwareCollector().get_distribution() log.debug("Distribution: %s" % str(distribution)) try: dist_version = float(distribution[1]) # We run this for Fedora as well, but all we really care about here # is if this is prior to RHEL 7, so this comparison should be safe. if dist_version < 7: self.standalone = False except Exception as e: log.error("Unable to parse a distribution version.") log.exception(e) log.debug("Running standalone firstboot: %s" % self.standalone) self.manual_message = None self._skip_apply_for_page_jump = False self._cached_credentials = None self._registration_finished = False self.interface = None self.finished = False self.proxies_were_enabled_from_gui = None self._apply_result = constants.RESULT_FAILURE self.page_status = constants.RESULT_FAILURE
def __init__(self, bus_class=None, bus_name=None, object_classes=None, bus_kwargs=None): """ Create a connection to a bus defined by bus_class and bus_kwargs; instantiate objects in object_classes; expose them under bus_name and enter a GLib mainloop. bus_kwargs are generally only necessary if you're using dbus.bus.BusConnection The object_classes argument is a list. The list can contain either a class or a tuple consisting of a class and a dictionary of arguments to send that class's constructor. """ # Configure mainloop for threading. We must do so in GLib and python-dbus. GLib.threads_init() dbus.mainloop.glib.threads_init() self.bus_name = bus_name or constants.BUS_NAME bus_class = bus_class or dbus.SystemBus bus_kwargs = bus_kwargs or {} object_classes = object_classes or [] self.objects = [] try: self.bus = bus_class(**bus_kwargs) except dbus.exceptions.DBusException: log.exception("Could not create bus class") raise self.terminate_loop = False # if 'pyinotify' in sys.modules and inotify_enabled(): log.debug('Using pyinotify %s' % pyinotify.__version__) self._thread = threading.Thread(target=inotify.inotify_worker, args=(self, )) else: self._thread = threading.Thread(target=polling_worker, args=(self, )) self._thread.start() self.connection_name = dbus.service.BusName(self.bus_name, self.bus) self.mainloop = GLib.MainLoop() for item in object_classes: try: clazz, kwargs = item[0], item[1] except TypeError: clazz = item kwargs = {} self.objects.append( clazz(object_path=clazz.default_dbus_path, bus_name=self.connection_name, **kwargs))
def __init__(self, bus_class=None, bus_name=None, object_classes=None, bus_kwargs=None): """ Create a connection to a bus defined by bus_class and bus_kwargs; instantiate objects in object_classes; expose them under bus_name and enter a GLib mainloop. bus_kwargs are generally only necessary if you're using dbus.bus.BusConnection The object_classes argument is a list. The list can contain either a class or a tuple consisting of a class and a dictionary of arguments to send that class's constructor. """ # Configure mainloop for threading. We must do so in GLib and python-dbus. GLib.threads_init() dbus.mainloop.glib.threads_init() self.bus_name = bus_name or constants.BUS_NAME bus_class = bus_class or dbus.SystemBus bus_kwargs = bus_kwargs or {} object_classes = object_classes or [] self.objects = [] try: self.bus = bus_class(**bus_kwargs) except dbus.exceptions.DBusException: log.exception("Could not create bus class") raise self.terminate_loop = False # if 'pyinotify' in sys.modules and inotify_enabled(): log.debug('Using pyinotify %s' % pyinotify.__version__) self._thread = threading.Thread(target=inotify.inotify_worker, args=(self,)) else: self._thread = threading.Thread(target=polling_worker, args=(self,)) self._thread.start() self.connection_name = dbus.service.BusName(self.bus_name, self.bus) self.mainloop = GLib.MainLoop() for item in object_classes: try: clazz, kwargs = item[0], item[1] except TypeError: clazz = item kwargs = {} self.objects.append( clazz(object_path=clazz.default_dbus_path, bus_name=self.connection_name, **kwargs) )
def __init__(self, bus_class=None, bus_name=None, object_classes=None, bus_kwargs=None): """ Create a connection to a bus defined by bus_class and bus_kwargs; instantiate objects in object_classes; expose them under bus_name and enter a GLib mainloop. bus_kwargs are generally only necessary if you're using dbus.bus.BusConnection The object_classes argument is a list. The list can contain either a class or a tuple consisting of a class and a dictionary of arguments to send that class's constructor. """ # Configure mainloop for threading. We must do so in GLib and python-dbus. GLib.threads_init() dbus.mainloop.glib.threads_init() self.bus_name = bus_name or constants.BUS_NAME bus_class = bus_class or dbus.SystemBus bus_kwargs = bus_kwargs or {} object_classes = object_classes or [] self.objects = [] self.object_map = {} try: self.bus = bus_class(**bus_kwargs) except dbus.exceptions.DBusException: log.exception("Could not create bus class") raise self.identity = inj.require(inj.IDENTITY) # gives us consumer path config_cert_dir_path = "/etc/rhsm/rhsm.conf" products_cert_dir_path = conf['rhsm']['productCertDir'] entitlement_cert_dir_path = conf['rhsm']['entitlementCertDir'] syspurpose_cert_dir_path = "/etc/rhsm/syspurpose/syspurpose.json" self.connection_name = dbus.service.BusName(self.bus_name, self.bus) self.mainloop = GLib.MainLoop() for item in object_classes: try: clazz, kwargs = item[0], item[1] except TypeError: clazz = item kwargs = {} clazz_instance = clazz(object_path=clazz.default_dbus_path, bus_name=self.connection_name, **kwargs) self.objects.append(clazz_instance) self.object_map[str(clazz.__name__)] = clazz_instance consumer_dir_list = [] entitlement_dir_list = [] config_dir_list = [] products_dir_list = [] syspurpose_dir_list = [] if "EntitlementDBusObject" in self.object_map: entitlement_dir_list.append(self.object_map["EntitlementDBusObject"].reload) consumer_dir_list.append(self.object_map["EntitlementDBusObject"].reload) products_dir_list.append(self.object_map["EntitlementDBusObject"].reload) syspurpose_dir_list.append(self.object_map["EntitlementDBusObject"].reload) entitlement_dir_list.append(self.object_map["EntitlementDBusObject"].EntitlementChanged) if "ConsumerDBusObject" in self.object_map: consumer_dir_list.append(self.object_map["ConsumerDBusObject"].ConsumerChanged) if "ConfigDBusObject" in self.object_map: config_dir_list.append(self.object_map["ConfigDBusObject"].reload) config_dir_list.append(self.object_map["ConfigDBusObject"].ConfigChanged) if "ProductsDBusObject" in self.object_map: products_dir_list.append(self.object_map["ProductsDBusObject"].InstalledProductsChanged) if "SyspurposeDBusObject" in self.object_map: syspurpose_dir_list.append(self.object_map["SyspurposeDBusObject"].SyspurposeChanged) consumer_dir_watch = DirectoryWatch(self.identity.cert_dir_path, consumer_dir_list) entitlement_dir_watch = DirectoryWatch(entitlement_cert_dir_path, entitlement_dir_list) config_dir_watch = DirectoryWatch(config_cert_dir_path, config_dir_list) products_dir_watch = DirectoryWatch(products_cert_dir_path, products_dir_list) syspurpose_dir_watch = DirectoryWatch(syspurpose_cert_dir_path, syspurpose_dir_list) self.filesystem_watcher = create_filesystem_watcher([ consumer_dir_watch, entitlement_dir_watch, config_dir_watch, products_dir_watch, syspurpose_dir_watch, ]) self._thread = threading.Thread(target=self.filesystem_watcher.loop) self._thread.start()
def __init__(self, bus_class=None, bus_name=None, object_classes=None, bus_kwargs=None): """ Create a connection to a bus defined by bus_class and bus_kwargs; instantiate objects in object_classes; expose them under bus_name and enter a GLib mainloop. bus_kwargs are generally only necessary if you're using dbus.bus.BusConnection The object_classes argument is a list. The list can contain either a class or a tuple consisting of a class and a dictionary of arguments to send that class's constructor. """ # Configure mainloop for threading. We must do so in GLib and python-dbus. GLib.threads_init() dbus.mainloop.glib.threads_init() self.bus_name = bus_name or constants.BUS_NAME bus_class = bus_class or dbus.SystemBus bus_kwargs = bus_kwargs or {} object_classes = object_classes or [] self.objects = [] self.object_map = {} try: self.bus = bus_class(**bus_kwargs) except dbus.exceptions.DBusException: log.exception("Could not create bus class") raise self.identity = inj.require(inj.IDENTITY) # gives us consumer path config_cert_dir_path = "/etc/rhsm/rhsm.conf" products_cert_dir_path = conf['rhsm']['productCertDir'] entitlement_cert_dir_path = conf['rhsm']['entitlementCertDir'] syspurpose_cert_dir_path = "/etc/rhsm/syspurpose/syspurpose.json" self.connection_name = dbus.service.BusName(self.bus_name, self.bus) self.mainloop = GLib.MainLoop() for item in object_classes: try: clazz, kwargs = item[0], item[1] except TypeError: clazz = item kwargs = {} clazz_instance = clazz(object_path=clazz.default_dbus_path, bus_name=self.connection_name, **kwargs) self.objects.append(clazz_instance) self.object_map[str(clazz.__name__)] = clazz_instance consumer_dir_list = [self.identity.reload] entitlement_dir_list = [] config_dir_list = [] products_dir_list = [] syspurpose_dir_list = [] if "EntitlementDBusObject" in self.object_map: entitlement_dir_list.append(self.object_map["EntitlementDBusObject"].reload) consumer_dir_list.append(self.object_map["EntitlementDBusObject"].reload) products_dir_list.append(self.object_map["EntitlementDBusObject"].reload) syspurpose_dir_list.append(self.object_map["EntitlementDBusObject"].reload) entitlement_dir_list.append(self.object_map["EntitlementDBusObject"].EntitlementChanged) if "ConsumerDBusObject" in self.object_map: consumer_dir_list.append(self.object_map["ConsumerDBusObject"].ConsumerChanged) if "ConfigDBusObject" in self.object_map: config_dir_list.append(self.object_map["ConfigDBusObject"].reload) config_dir_list.append(self.object_map["ConfigDBusObject"].ConfigChanged) if "ProductsDBusObject" in self.object_map: products_dir_list.append(self.object_map["ProductsDBusObject"].InstalledProductsChanged) if "SyspurposeDBusObject" in self.object_map: syspurpose_dir_list.append(self.object_map["SyspurposeDBusObject"].SyspurposeChanged) consumer_dir_watch = DirectoryWatch(self.identity.cert_dir_path, consumer_dir_list) entitlement_dir_watch = DirectoryWatch(entitlement_cert_dir_path, entitlement_dir_list) config_dir_watch = DirectoryWatch(config_cert_dir_path, config_dir_list) products_dir_watch = DirectoryWatch(products_cert_dir_path, products_dir_list) syspurpose_dir_watch = DirectoryWatch(syspurpose_cert_dir_path, syspurpose_dir_list) self.filesystem_watcher = create_filesystem_watcher([ consumer_dir_watch, entitlement_dir_watch, config_dir_watch, products_dir_watch, syspurpose_dir_watch, ]) self._thread = threading.Thread(target=self.filesystem_watcher.loop) self._thread.start()