def test_exception_handling(): """ Function that can be used for testing exception handling in anaconda. It tries to prepare a worst case scenario designed from bugs seen so far. """ # XXX: this is a huge hack, but probably the only way, how we can get # "unique" stack and thus unique hash and new bugreport def raise_exception(msg, non_ascii): timestamp = str(time.time()).split(".", 1)[0] code = """ def f%s(msg, non_ascii): raise RuntimeError(msg) f%s(msg, non_ascii) """ % ( timestamp, timestamp, ) eval(compile(code, "str_eval", "exec")) # test non-ascii characters dumping non_ascii = u"\u0159" msg = "NOTABUG: testing exception handling" # raise exception from a separate thread from pyanaconda.threads import AnacondaThread threadMgr.add(AnacondaThread(name=THREAD_EXCEPTION_HANDLING_TEST, target=raise_exception, args=(msg, non_ascii)))
def _fetch_data_and_initialize(self): """Fetch data from a specified URL and initialize everything.""" with self._fetch_flag_lock: if self._fetching: # prevent multiple fetches running simultaneously return self._fetching = True thread_name = None if any(self._addon_data.content_url.startswith(net_prefix) for net_prefix in data_fetch.NET_URL_PREFIXES): # need to fetch data over network thread_name = common.wait_and_fetch_net_data( self._addon_data.content_url, self._addon_data.raw_preinst_content_path, self._addon_data.certificates) # pylint: disable-msg=E1101 hubQ.send_message(self.__class__.__name__, _("Fetching content data")) # pylint: disable-msg=E1101 hubQ.send_not_ready(self.__class__.__name__) threadMgr.add(AnacondaThread(name="OSCAPguiWaitForDataFetchThread", target=self._init_after_data_fetch, args=(thread_name,)))
def on_start_clicked(self, *args): # First, update some widgets to not be usable while discovery happens. self._startButton.hide() self._cancelButton.set_sensitive(False) self._okButton.set_sensitive(False) self._conditionNotebook.set_current_page(1) self._set_configure_sensitive(False) self._initiatorEntry.set_sensitive(False) # Now get the node discovery credentials. credentials = discoverMap[self._authNotebook.get_current_page()](self.builder) discoveredLabelText = _("The following nodes were discovered using the iSCSI initiator "\ "<b>%(initiatorName)s</b> using the target IP address "\ "<b>%(targetAddress)s</b>. Please select which nodes you "\ "wish to log into:") % \ {"initiatorName": escape_markup(credentials.initiator), "targetAddress": escape_markup(credentials.targetIP)} discoveredLabel = self.builder.get_object("discoveredLabel") discoveredLabel.set_markup(discoveredLabelText) bind = self._bindCheckbox.get_active() spinner = self.builder.get_object("waitSpinner") spinner.start() threadMgr.add(AnacondaThread(name=constants.THREAD_ISCSI_DISCOVER, target=self._discover, args=(credentials, bind))) GLib.timeout_add(250, self._check_discover)
def wait_and_fetch_net_data(url, out_file, ca_certs=None): """ Function that waits for network connection and starts a thread that fetches data over network. :see: org_fedora_oscap.data_fetch.fetch_data :return: the name of the thread running fetch_data :rtype: str """ # get thread that tries to establish a network connection nm_conn_thread = threadMgr.get(constants.THREAD_WAIT_FOR_CONNECTING_NM) if nm_conn_thread: # NM still connecting, wait for it to finish nm_conn_thread.join() if not nm.nm_is_connected(): raise OSCAPaddonNetworkError("Network connection needed to fetch data.") fetch_data_thread = AnacondaThread(name=THREAD_FETCH_DATA, target=fetch_data, args=(url, out_file, ca_certs), fatal=False) # register and run the thread threadMgr.add(fetch_data_thread) return THREAD_FETCH_DATA
def initialize(self): # Start a thread to wait for the payload and run the first, automatic # dependency check self.initialize_start() super(SoftwareSpoke, self).initialize() threadMgr.add(AnacondaThread(name=THREAD_SOFTWARE_WATCHER, target=self._initialize))
def _apply(self): if not self.environment: return # NOTE: This block is skipped for kickstart where addons and _origAddons will # both be [], preventing it from wiping out the kickstart's package selection addons = self._get_selected_addons() if set(addons) != set(self._origAddons): for group in addons: if group not in self.selectedGroups: self.selectedGroups.append(group) self._selectFlag = False self.payload.data.packages.packageList = [] self.payload.data.packages.groupList = [] self.payload.selectEnvironment(self.environment) for group in self.selectedGroups: self.payload.selectGroup(group) # And then save these values so we can check next time. self._origAddons = addons self._origEnvironment = self.environment hubQ.send_not_ready(self.__class__.__name__) hubQ.send_not_ready("SourceSpoke") threadMgr.add(AnacondaThread(name=constants.THREAD_CHECK_SOFTWARE, target=self.checkSoftwareSelection))
def on_login_clicked(self, *args): # Make the buttons UI while we work. self._okButton.set_sensitive(False) self._cancelButton.set_sensitive(False) self._loginButton.set_sensitive(False) self._loginConditionNotebook.set_current_page(0) self._set_login_sensitive(False) spinner = self.builder.get_object("loginSpinner") spinner.start() spinner.set_visible(True) spinner.show() # Are we reusing the credentials from the discovery step? If so, grab them # out of the UI again here. They should still be there. page = self._loginAuthNotebook.get_current_page() if page == 3: credentials = discoverMap[self._authNotebook.get_current_page()](self.builder) else: credentials = loginMap[page](self.builder) threadMgr.add(AnacondaThread(name=constants.THREAD_ISCSI_LOGIN, target=self._login, args=(credentials,))) GLib.timeout_add(250, self._check_login)
def _refresh_server_working(self, itr): """ Runs a new thread with _set_server_ok_nok(itr) as a taget. """ self._serversStore.set_value(itr, SERVER_WORKING, constants.NTP_SERVER_QUERY) threadMgr.add(AnacondaThread(prefix=constants.THREAD_NTP_SERVER_CHECK, target=self._set_server_ok_nok, args=(itr, self._epoch)))
def initialize(self): from pyanaconda.ui.gui.utils import setViewportBackground NormalSpoke.initialize(self) # Wouldn't it be nice if glade knew how to do this? label = self.builder.get_object("summary_button").get_children()[0] markup = "<span foreground='blue'><u>%s</u></span>" % label.get_text() label.set_use_markup(True) label.set_markup(markup) specializedButton = self.builder.get_object("addSpecializedButton") # It's uh... uh... it's down there somewhere, let me take another look. label = specializedButton.get_children()[0].get_children()[0].get_children()[1] markup = "<span size='large'><b>%s</b></span>" % label.get_text() label.set_use_markup(True) label.set_markup(markup) specializedButton.show_all() self.local_disks_box = self.builder.get_object("local_disks_box") self.specialized_disks_box = self.builder.get_object("specialized_disks_box") threadMgr.add(AnacondaThread(name=constants.THREAD_STORAGE_WATCHER, target=self._initialize))
def __init__(self, *args, **kwargs): StorageChecker.__init__(self) NormalSpoke.__init__(self, *args, **kwargs) self.applyOnSkip = True self._ready = False self.autoPartType = None self.encrypted = False self.passphrase = "" self.selected_disks = self.data.ignoredisk.onlyuse[:] # This list contains all possible disks that can be included in the install. # All types of advanced disks should be set up for us ahead of time, so # there should be no need to modify this list. self.disks = [] if not flags.automatedInstall: # default to using autopart for interactive installs self.data.autopart.autopart = True self.autopart = self.data.autopart.autopart self.autoPartType = None self.clearPartType = CLEARPART_TYPE_NONE if self.data.zerombr.zerombr and arch.isS390(): # run dasdfmt on any unformatted DASDs automatically threadMgr.add(AnacondaThread(name=constants.THREAD_DASDFMT, target=self.run_dasdfmt)) self._previous_autopart = False self._last_clicked_overview = None self._cur_clicked_overview = None self._grabObjects()
def _apply(self): env = self._get_selected_environment() # Check if a kickstart install still looks like a kickstart install # If an environment is selected and either the environment or the # addon list does not match the ksdata, the packages were # selected interactively. if env and self._kickstarted: if env != self.data.packages.environment or \ set(self.selectedGroups) != set(self.data.packages.groupList): self._kickstarted = False # Not a kickstart with packages, setup the environment and groups if env and not self._kickstarted: addons = self._get_selected_addons() for group in addons: if group not in self.selectedGroups: self.selectedGroups.append(group) self._selectFlag = False self.payload.data.packages.packageList = [] self.payload.data.packages.groupList = [] self.payload.selectEnvironment(env) self.environment = env for group in self.selectedGroups: self.payload.selectGroup(group) # And then save these values so we can check next time. self._origAddons = addons self._origEnvironment = self.environment hubQ.send_not_ready(self.__class__.__name__) hubQ.send_not_ready("SourceSpoke") threadMgr.add(AnacondaThread(name=constants.THREAD_CHECK_SOFTWARE, target=self.checkSoftwareSelection))
def on_start_clicked(self, *args): # First, update some widgets to not be usable while discovery happens. self._startButton.hide() self._cancelButton.set_sensitive(False) self._okButton.set_sensitive(False) self._conditionNotebook.set_current_page(1) self._set_configure_sensitive(False) self._initiatorEntry.set_sensitive(False) # Now get the node discovery credentials. credentials = discoverMap[self._authNotebook.get_current_page()](self.builder) discoveredLabel = self.builder.get_object("discoveredLabel") discoveredLabel.set_markup(discoveredLabel.get_label() % {"initiatorName": credentials.initiator, "targetAddress": credentials.targetIP}) bind = self._bindCheckbox.get_active() spinner = self.builder.get_object("waitSpinner") spinner.start() threadMgr.add(AnacondaThread(name=constants.THREAD_ISCSI_DISCOVER, target=self._discover, args=(credentials, bind))) GLib.timeout_add(250, self._check_discover)
def _apply(self): """ Private apply. """ self.environment = self._get_environment(self._selection) self.addons = self._addons_selection if self.environment is not None else set() changed = False # Not a kickstart with packages, setup the selected environment and addons if not self._kickstarted: # Changed the environment or addons, clear and setup if not self._origEnv \ or self._origEnv != self.environment \ or set(self._origAddons) != set(self.addons): self.payload.data.packages.packageList = [] self.data.packages.groupList = [] self.payload.selectEnvironment(self.environment) environment_id = self._get_environment_id(self.environment) available_addons = self._get_available_addons(environment_id) for addon_id in available_addons: if addon_id in self.addons: self.payload.selectGroup(addon_id) changed = True self._origEnv = self.environment self._origAddons = set(self.addons) # Check the software selection if changed or self._kickstarted: threadMgr.add(AnacondaThread(name=THREAD_CHECK_SOFTWARE, target=self.checkSoftwareSelection))
def _apply(self): env = self._get_selected_environment() if not env: return addons = self._get_selected_addons() for group in addons: if group not in self.selectedGroups: self.selectedGroups.append(group) self._selectFlag = False self.payload.data.packages.groupList = [] self.payload.selectEnvironment(env) self.environment = env for group in self.selectedGroups: self.payload.selectGroup(group) # And then save these values so we can check next time. self._origAddons = addons self._origEnvironment = self.environment hubQ.send_not_ready(self.__class__.__name__) hubQ.send_not_ready("SourceSpoke") threadMgr.add(AnacondaThread(name=constants.THREAD_CHECK_SOFTWARE, target=self.checkSoftwareSelection))
def execute(self): # Spawn storage execution as a separate thread so there's no big delay # going back from this spoke to the hub while StorageChecker.run runs. # Yes, this means there's a thread spawning another thread. Sorry. threadMgr.add(AnacondaThread(name=constants.THREAD_EXECUTE_STORAGE, target=self._doExecute)) # Register iSCSI to kickstart data iscsi_devices = [] # Find all selected disks and add all iscsi disks to iscsi_devices list for d in [d for d in getDisks(self.storage.devicetree) if d.name in self.selected_disks]: # Get parents of a multipath devices if isinstance(d, MultipathDevice): for parent_dev in d.parents: if isinstance(parent_dev, iScsiDiskDevice) and not parent_dev.ibft: iscsi_devices.append(parent_dev) # Add no-ibft iScsiDiskDevice. IBFT disks are added automatically so there is # no need to have them in KS. elif isinstance(d, iScsiDiskDevice) and not d.ibft: iscsi_devices.append(d) if iscsi_devices: self.data.iscsiname.iscsiname = self.storage.iscsi.initiator # Remove the old iscsi data information and generate new one self.data.iscsi.iscsi = [] for device in iscsi_devices: iscsi_data = self._create_iscsi_data(device) for saved_iscsi in self.data.iscsi.iscsi: if (iscsi_data.ipaddr == saved_iscsi.ipaddr and iscsi_data.target == saved_iscsi.target and iscsi_data.port == saved_iscsi.port): break else: self.data.iscsi.iscsi.append(iscsi_data)
def restartThread(self, storage, ksdata, payload, instClass, fallback=False, checkmount=True): """Start or restart the payload thread. This method starts a new thread to restart the payload thread, so this method's return is not blocked by waiting on the previous payload thread. If there is already a payload thread restart pending, this method has no effect. :param blivet.Blivet storage: The blivet storage instance :param kickstart.AnacondaKSHandler ksdata: The kickstart data instance :param packaging.Payload payload: The payload instance :param installclass.BaseInstallClass instClass: The install class instance :param bool fallback: Whether to fall back to the default repo in case of error :param bool checkmount: Whether to check for valid mounted media """ log.debug("Restarting payload thread") # If a restart thread is already running, don't start a new one if threadMgr.get(THREAD_PAYLOAD_RESTART): return # Launch a new thread so that this method can return immediately threadMgr.add(AnacondaThread(name=THREAD_PAYLOAD_RESTART, target=self._restartThread, args=(storage, ksdata, payload, instClass, fallback, checkmount)))
def initialize(self): NormalTUISpoke.initialize(self) threadMgr.add(AnacondaThread(name=THREAD_STORAGE_WATCHER, target=self._initialize)) self.selected_disks = self.data.ignoredisk.onlyuse[:]
def install(self): """ Install the payload. """ self.pct_lock = Lock() self.pct = 0 threadMgr.add(AnacondaThread(name=THREAD_LIVE_PROGRESS, target=self.progress)) cmd = "rsync" # preserve: permissions, owners, groups, ACL's, xattrs, times, # symlinks, hardlinks # go recursively, include devices and special files, don't cross # file system boundaries args = ["-pogAXtlHrDx", "--exclude", "/dev/", "--exclude", "/proc/", "--exclude", "/sys/", "--exclude", "/run/", "--exclude", "/boot/*rescue*", "--exclude", "/etc/machine-id", INSTALL_TREE+"/", ROOT_PATH] try: rc = iutil.execWithRedirect(cmd, args) except (OSError, RuntimeError) as e: msg = None err = str(e) log.error(err) else: err = None msg = "%s exited with code %d" % (cmd, rc) log.info(msg) if err or rc == 12: exn = PayloadInstallError(err or msg) if errorHandler.cb(exn) == ERROR_RAISE: raise exn # Wait for progress thread to finish with self.pct_lock: self.pct = 100 threadMgr.wait(THREAD_LIVE_PROGRESS)
def _restartThread(self, storage, ksdata, payload, instClass, fallback, checkmount): # Wait for the old thread to finish threadMgr.wait(THREAD_PAYLOAD) # Start a new payload thread threadMgr.add(AnacondaThread(name=THREAD_PAYLOAD, target=self._runThread, args=(storage, ksdata, payload, instClass, fallback, checkmount)))
def _apply(self): """ Private apply. """ # self._selection can be None during kickstart installation if self._selection is not None and 0 <= self._selection < len(self.payload.environments): self.environment = self.payload.environments[self._selection] else: self.environment = None return changed = False # Not a kickstart with packages, setup the selected environment if not self._kickstarted: if not self._origEnv: # nothing selected before, select the environment self.payload.selectEnvironment(self.environment) changed = True elif self._origEnv != self.environment: # environment changed, clear the list of packages and select the new # one self.payload.data.packages.groupList = [] self.payload.selectEnvironment(self.environment) changed = True self._origEnv = self.environment # Check the software selection if changed: threadMgr.add(AnacondaThread(name=THREAD_CHECK_SOFTWARE, target=self.checkSoftwareSelection))
def refresh(self, args=None): from pyanaconda.install import doInstall, doConfiguration from pyanaconda.threads import threadMgr, AnacondaThread # We print this here because we don't really use the window object print(_(self.title)) threadMgr.add(AnacondaThread(name=THREAD_INSTALL, target=doInstall, args=(self.storage, self.payload, self.data, self.instclass))) # This will run until we're all done with the install thread. self._update_progress() threadMgr.add(AnacondaThread(name=THREAD_CONFIGURATION, target=doConfiguration, args=(self.storage, self.payload, self.data, self.instclass))) # This will run until we're all done with the configuration thread. self._update_progress() iutil.ipmi_report(IPMI_FINISHED) # kickstart install, continue automatically if reboot or shutdown selected if flags.automatedInstall and self.data.reboot.action in [KS_REBOOT, KS_SHUTDOWN]: # Just pretend like we got input, and our input doesn't care # what it gets, it just quits. self.input(None, None) return True
def initialize(self): EditTUISpoke.initialize(self) self.initialize_start() threadMgr.add(AnacondaThread(name=THREAD_SOURCE_WATCHER, target=self._initialize)) payloadMgr.addListener(payloadMgr.STATE_ERROR, self._payload_error)
def _refresh_server_working(self, itr): """ Runs a new thread with _set_server_ok_nok(itr) as a taget. """ self._serversStore.set_value(itr, 1, SERVER_QUERY) threadMgr.add(AnacondaThread(prefix="AnaNTPserver", target=self._set_server_ok_nok, args=(itr, self._epoch)))
def initialize(self): NormalSpoke.initialize(self) self.local_disks_box = self.builder.get_object("local_disks_box") self.specialized_disks_box = self.builder.get_object("specialized_disks_box") threadMgr.add(AnacondaThread(name=constants.THREAD_STORAGE_WATCHER, target=self._initialize))
def apply(self): """ Execute the selections made. """ # If askmethod was provided on the command line, entering the source # spoke wipes that out. if flags.askmethod: flags.askmethod = False threadMgr.add(AnacondaThread(name=THREAD_PAYLOAD_MD, target=self.getRepoMetadata))
def background_XklWrapper_initialize(): """ Create the XklWrapper singleton instance in a separate thread to save time when it's really needed. """ threadMgr.add(AnacondaThread(name=THREAD_XKL_WRAPPER_INIT, target=XklWrapper.get_instance))
def apply(self): # If askmethod was provided on the command line, entering the source # spoke wipes that out. if flags.askmethod: flags.askmethod = False threadMgr.add(AnacondaThread(name=constants.THREAD_PAYLOAD_MD, target=self.getRepoMetadata)) self.clear_info()
def initialize(self): NormalSpoke.initialize(self) self.initialize_start() # set X keyboard defaults # - this needs to be done early in spoke initialization so that # the spoke status does not show outdated keyboard selection keyboard.set_x_keyboard_defaults(self.data, self._xkl_wrapper) # make sure the x_layouts list has at least one keyboard layout if not self.data.keyboard.x_layouts: self.data.keyboard.x_layouts.append(DEFAULT_KEYBOARD) self._add_dialog = AddLayoutDialog(self.data) self._add_dialog.initialize() if flags.can_touch_runtime_system("hide runtime keyboard configuration " "warning", touch_live=True): self.builder.get_object("warningBox").hide() # We want to store layouts' names but show layouts as # 'language (description)'. layoutColumn = self.builder.get_object("layoutColumn") layoutRenderer = self.builder.get_object("layoutRenderer") override_cell_property(layoutColumn, layoutRenderer, "text", _show_layout, self._xkl_wrapper) self._store = self.builder.get_object("addedLayoutStore") self._add_data_layouts() self._selection = self.builder.get_object("layoutSelection") self._switching_dialog = ConfigureSwitchingDialog(self.data) self._switching_dialog.initialize() self._layoutSwitchLabel = self.builder.get_object("layoutSwitchLabel") if not flags.can_touch_runtime_system("test X layouts", touch_live=True): # Disable area for testing layouts as we cannot make # it work without modifying runtime system widgets = [self.builder.get_object("testingLabel"), self.builder.get_object("testingWindow"), self.builder.get_object("layoutSwitchLabel")] # Use testingLabel's text to explain why this part is not # sensitive. widgets[0].set_text(_("Testing layouts configuration not " "available.")) for widget in widgets: widget.set_sensitive(False) hubQ.send_not_ready(self.__class__.__name__) hubQ.send_message(self.__class__.__name__, _("Getting list of layouts...")) threadMgr.add(AnacondaThread(name=THREAD_KEYBOARD_INIT, target=self._wait_ready))
def _refresh_server_working(self, itr): """ Runs a new thread with _set_server_ok_nok(itr) as a taget. """ self._serversStore.set_value(itr, 1, SERVER_QUERY) new_thread_name = "AnaNTPserver%d" % self._threads_counter threadMgr.add(AnacondaThread(name=new_thread_name, target=self._set_server_ok_nok, args=(itr, self._epoch))) self._threads_counter += 1
def _check_ntp_servers_async(self, servers): """Asynchronously check if given NTP servers appear to be working. :param list servers: list of servers to check """ for server in servers: threadMgr.add(AnacondaThread(prefix=constants.THREAD_NTP_SERVER_CHECK, target=self._check_ntp_server, args=(server,)))
def execute(self): # Spawn storage execution as a separate thread so there's no big delay # going back from this spoke to the hub while StorageChecker.run runs. # Yes, this means there's a thread spawning another thread. Sorry. threadMgr.add(AnacondaThread(name=constants.THREAD_EXECUTE_STORAGE, target=self._doExecute))
def run_dasdfmt(self, to_format=None): """ This generates the list of DASDs requiring dasdfmt and runs dasdfmt against them. to_format is an optional list of DASDs to format. This shouldn't be passed if run_dasdfmt is called during a ks installation, and if called during a manual installation, a list of DASDs needs to be passed. """ if not to_format: # go ahead and initialize this to_format = [] # if the storage thread is running, wait on it to complete before taking # any further actions on devices; most likely to occur if user has # zerombr in their ks file threadMgr.wait(THREAD_STORAGE) if flags.automatedInstall: # automated install case unformatted = [] ldl = [] if self.data.zerombr.zerombr: # unformatted DASDs unformatted += make_unformatted_dasd_list( [d.name for d in getDisks(self.storage.devicetree)]) if self.data.clearpart.cdl: # LDL DASDs ldl += [ d.name for d in self.storage.devicetree.dasd if is_ldl_dasd(d.name) ] # combine into one nice list to_format = list(set(unformatted + ldl)) else: # manual install; ask to verify they want to run dasdfmt # prepare our msg strings; copied directly from dasdfmt.glade summary = _( "The following unformatted or LDL DASDs have been " "detected on your system. You can choose to format them " "now with dasdfmt or cancel to leave them unformatted. " "Unformatted DASDs cannot be used during installation.\n\n") warntext = _( "Warning: All storage changes made using the installer will be lost when you choose to format.\n\nProceed to run dasdfmt?\n" ) displaytext = summary + "\n".join( "/dev/" + d for d in to_format) + "\n" + warntext # now show actual prompt; note -- in cmdline mode, auto-answer for # this is 'no', so unformatted and ldl DASDs will remain so unless # zerombr or cdl are added to the ks file question_window = YesNoDialog(self._app, displaytext) self._app.switch_screen_modal(question_window) if not question_window.answer: # no? well fine then, back to the storage spoke with you; return None for disk in to_format: try: print(_("Formatting /dev/%s. This may take a moment.") % disk) format_dasd(disk) except DasdFormatError as err: # Log errors if formatting fails, but don't halt the installer log.error("dasdfmt /dev/%s failed: %s", disk, err) continue # need to make devicetree aware of disk changes self.storage.devicetree.populate() if not flags.automatedInstall: # reinit storage threadMgr.add( AnacondaThread( name=THREAD_STORAGE, target=storageInitialize, args=(self.storage, self.data, self.storage.devicetree.protectedDevNames))) # update the summary screen with the changes self._initialize()
def initialize(self): EditTUISpoke.initialize(self) threadMgr.add(AnacondaThread(name=THREAD_SOURCE_WATCHER, target=self._initialize)) payloadMgr.addListener(payloadMgr.STATE_ERROR, self._payload_error)
def initialize(self): NormalSpoke.initialize(self) self._daysStore = self.builder.get_object("days") self._monthsStore = self.builder.get_object("months") self._yearsStore = self.builder.get_object("years") self._regionsStore = self.builder.get_object("regions") self._citiesStore = self.builder.get_object("cities") self._tzmap = self.builder.get_object("tzmap") self._dateBox = self.builder.get_object("dateBox") # we need to know it the new value is the same as previous or not self._old_region = None self._old_city = None self._regionCombo = self.builder.get_object("regionCombobox") self._cityCombo = self.builder.get_object("cityCombobox") self._daysFilter = self.builder.get_object("daysFilter") self._daysFilter.set_visible_func(self.existing_date, None) self._citiesFilter = self.builder.get_object("citiesFilter") self._citiesFilter.set_visible_func(self.city_in_region, None) self._hoursLabel = self.builder.get_object("hoursLabel") self._minutesLabel = self.builder.get_object("minutesLabel") self._amPmUp = self.builder.get_object("amPmUpButton") self._amPmDown = self.builder.get_object("amPmDownButton") self._amPmLabel = self.builder.get_object("amPmLabel") self._radioButton24h = self.builder.get_object("timeFormatRB") self._amPmRevealer = self.builder.get_object("amPmRevealer") # create widgets for displaying/configuring date day_box, self._dayCombo, day_label = _new_date_field_box( self._daysFilter) self._dayCombo.connect("changed", self.on_day_changed) month_box, self._monthCombo, month_label = _new_date_field_box( self._monthsStore) self._monthCombo.connect("changed", self.on_month_changed) year_box, self._yearCombo, year_label = _new_date_field_box( self._yearsStore) self._yearCombo.connect("changed", self.on_year_changed) # get the right order for date widgets and respective formats and put # widgets in place widgets, formats = resolve_date_format(year_box, month_box, day_box) for widget in widgets: self._dateBox.pack_start(widget, False, False, 0) self._day_format, suffix = formats[widgets.index(day_box)] day_label.set_text(suffix) self._month_format, suffix = formats[widgets.index(month_box)] month_label.set_text(suffix) self._year_format, suffix = formats[widgets.index(year_box)] year_label.set_text(suffix) self._ntpSwitch = self.builder.get_object("networkTimeSwitch") self._regions_zones = get_all_regions_and_timezones() # Set the initial sensitivity of the AM/PM toggle based on the time-type selected self._radioButton24h.emit("toggled") if not flags.can_touch_runtime_system("modify system time and date"): self._set_date_time_setting_sensitive(False) self._config_dialog = NTPconfigDialog(self.data) self._config_dialog.initialize() threadMgr.add( AnacondaThread(name=constants.THREAD_DATE_TIME, target=self._initialize))
def initialize(self): EditTUISpoke.initialize(self) threadMgr.add(AnacondaThread(name=THREAD_SOURCE_WATCHER, target=self._initialize))
def initialize(self): NormalSpoke.initialize(self) threadMgr.add( AnacondaThread(name=constants.THREAD_SOFTWARE_WATCHER, target=self._initialize))
def initialize(self): # Start a thread to wait for the payload and run the first, automatic # dependency check super(SoftwareSpoke, self).initialize() threadMgr.add(AnacondaThread(name=THREAD_SOFTWARE_WATCHER, target=self._initialize))
localization.setup_locale_environment(locale_option, opts.display_mode != "g") # Now that LANG is set, do something with it localization.setup_locale(os.environ["LANG"], ksdata.lang, opts.display_mode != "g") import blivet blivet.enable_installer_mode() # Initialize the network now, in case the display needs it from pyanaconda.network import networkInitialize, wait_for_connecting_NM_thread networkInitialize(ksdata) threadMgr.add( AnacondaThread(name=constants.THREAD_WAIT_FOR_CONNECTING_NM, target=wait_for_connecting_NM_thread, args=(ksdata, ))) # now start the interface setupDisplay(anaconda, opts, addon_paths) if anaconda.gui_startup_failed: # we need to reinitialize the locale if GUI startup failed, # as we might now be in text mode, which might not be able to display # the characters from our current locale log.warning( "reinitializing locale due to failed attempt to start the GUI") localization.setup_locale(os.environ["LANG"], ksdata.lang, anaconda.displayMode != "g") # we now know in which mode we are going to run so store the information from pykickstart.constants import DISPLAY_MODE_GRAPHICAL, DISPLAY_MODE_CMDLINE, DISPLAY_MODE_TEXT
def initialize(self): NormalSpoke.initialize(self) # set X keyboard defaults # - this needs to be done early in spoke initialization so that # the spoke status does not show outdated keyboard selection keyboard.set_x_keyboard_defaults(self.data, self._xkl_wrapper) # make sure the x_layouts list has at least one keyboard layout if not self.data.keyboard.x_layouts: self.data.keyboard.x_layouts.append(DEFAULT_KEYBOARD) self._add_dialog = AddLayoutDialog(self.data) self._add_dialog.initialize() if flags.can_touch_runtime_system( "hide runtime keyboard configuration " "warning", touch_live=True): self.builder.get_object("warningBox").hide() # We want to store layouts' names but show layouts as # 'language (description)'. layoutColumn = self.builder.get_object("layoutColumn") layoutRenderer = self.builder.get_object("layoutRenderer") override_cell_property(layoutColumn, layoutRenderer, "text", _show_layout, self._xkl_wrapper) self._store = self.builder.get_object("addedLayoutStore") self._add_data_layouts() self._selection = self.builder.get_object("layoutSelection") self._switching_dialog = ConfigureSwitchingDialog(self.data) self._switching_dialog.initialize() self._layoutSwitchLabel = self.builder.get_object("layoutSwitchLabel") if not flags.can_touch_runtime_system("test X layouts", touch_live=True): # Disable area for testing layouts as we cannot make # it work without modifying runtime system widgets = [ self.builder.get_object("testingLabel"), self.builder.get_object("testingWindow"), self.builder.get_object("layoutSwitchLabel") ] # Use testingLabel's text to explain why this part is not # sensitive. widgets[0].set_text( _("Testing layouts configuration not " "available.")) for widget in widgets: widget.set_sensitive(False) hubQ.send_not_ready(self.__class__.__name__) hubQ.send_message(self.__class__.__name__, _("Getting list of layouts...")) threadMgr.add( AnacondaThread(name=THREAD_KEYBOARD_INIT, target=self._wait_ready))
def gtk_batch_map(action, items, args=(), pre_func=None, batch_size=1): """ Function that maps an action on items in a way that makes the action run in the main thread, but without blocking the main thread for a noticeable time. If a pre-processing function is given it is mapped on the items first before the action happens in the main thread. .. DANGER:: MUST NOT BE CALLED NOR WAITED FOR FROM THE MAIN THREAD. :param action: any action that has to be done on the items in the main thread :type action: (action_item, \\*args) -> None :param items: an iterable of items that the action should be mapped on :type items: iterable :param args: additional arguments passed to the action function :type args: tuple :param pre_func: a function that is mapped on the items before they are passed to the action function :type pre_func: item -> action_item :param batch_size: how many items should be processed in one run in the main loop :raise AssertionError: if called from the main thread :return: None """ assert (not threadMgr.in_main_thread()) def preprocess(queue_instance): if pre_func: for item in items: queue_instance.put(pre_func(item)) else: for item in items: queue_instance.put(item) queue_instance.put(TERMINATOR) def process_one_batch(arguments): (queue_instance, action, done_event) = arguments tstamp_start = time.time() tstamp = time.time() # process as many batches as user shouldn't notice while tstamp - tstamp_start < NOTICEABLE_FREEZE: for _i in range(batch_size): try: action_item = queue_instance.get_nowait() if action_item is TERMINATOR: # all items processed, tell we are finished and return done_event.set() return False else: # run action on the item action(action_item, *args) except queue.Empty: # empty queue_instance, reschedule to run later return True tstamp = time.time() # out of time but something left, reschedule to run again later return True item_queue_instance = queue.Queue() done_event = threading.Event() # we don't want to log the whole list, type and address is enough log.debug("Starting applying %s on %s", action, object.__repr__(items)) # start a thread putting preprocessed items into the queue_instance threadMgr.add( AnacondaThread(prefix="AnaGtkBatchPre", target=preprocess, args=(item_queue_instance, ))) GLib.idle_add(process_one_batch, (item_queue_instance, action, done_event)) done_event.wait() log.debug("Finished applying %s on %s", action, object.__repr__(items))
def run(self): threadMgr.add(AnacondaThread(name=constants.THREAD_CHECK_STORAGE, target=self.checkStorage))