def run_dasdfmt(self): """ Though the same function exists in pyanaconda.ui.gui.spokes.lib.dasdfmt, this instance doesn't include any of the UI pieces and should only really be getting called on ks installations with "zerombr". """ # wait for the initial storage thread to complete before taking any new # actions on storage devices threadMgr.wait(constants.THREAD_STORAGE) to_format = ( d for d in getDisks(self.storage.devicetree) if d.type == "dasd" and blockdev.s390.dasd_needs_format(d.busid)) if not to_format: # nothing to do here; bail return hubQ.send_message(self.__class__.__name__, _("Formatting DASDs")) for disk in to_format: try: blockdev.s390.dasd_format(disk.name) except blockdev.S390Error as err: # Log errors if formatting fails, but don't halt the installer log.error(str(err)) continue
def checkSoftwareSelection(self): from pyanaconda.packaging import DependencyError hubQ.send_message(self.__class__.__name__, _("Checking software dependencies...")) try: self.payload.checkSoftwareSelection() except DependencyError as e: self._errorMsgs = "\n".join(sorted(e.message)) hubQ.send_message(self.__class__.__name__, _("Error checking software dependencies")) self._tx_id = None else: self._errorMsgs = None # If we are installing with a kickstart that does not specify packages, # we want the user to enter the Software spoke and confirm the software # selection. We do this be by resetting the transaction id, which # forces the user to visit the spoke and also makes sure any changes # the user does in the spoke are respected. if flags.automatedInstall and not self.data.packages.seen: self._tx_id = None else: self._tx_id = self.payload.txID finally: hubQ.send_ready(self.__class__.__name__, False) hubQ.send_ready("SourceSpoke", False)
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 run_dasdfmt(self): """ Though the same function exists in pyanaconda.ui.gui.spokes.lib.dasdfmt, this instance doesn't include any of the UI pieces and should only really be getting called on ks installations with "zerombr". """ # wait for the initial storage thread to complete before taking any new # actions on storage devices threadMgr.wait(constants.THREAD_STORAGE) to_format = make_unformatted_dasd_list(self.selected_disks) if not to_format: # nothing to do here; bail return hubQ.send_message(self.__class__.__name__, _("Formatting DASDs")) for disk in to_format: try: format_dasd(disk) except DasdFormatError as err: # Log errors if formatting fails, but don't halt the installer log.error(str(err)) continue # now re-initialize storage to pick up the newly formatted disks protectedNames = [d.name for d in self.storage.protectedDevices] storageInitialize(self.storage, self.data, protectedNames) # I really hate doing this, but the way is the way; probably the most # correct way to kajigger the storage spoke into becoming ready self.execute()
def _initialize(self): """Finish the initialization. This method is expected to run only once during the initialization. """ # Wait for storage. hubQ.send_message(self.__class__.__name__, _(constants.PAYLOAD_STATUS_PROBING_STORAGE)) threadMgr.wait(constants.THREAD_STORAGE) # Automatically format DASDs if allowed. disks = self._disk_select_module.GetUsableDisks() DasdFormatting.run_automatically(disks, self._show_dasdfmt_report) hubQ.send_message(self.__class__.__name__, _(constants.PAYLOAD_STATUS_PROBING_STORAGE)) # Update the selected disks. select_default_disks() # Automatically apply the preconfigured partitioning. # Do not set ready in the automated installation before # the execute method is run. if flags.automatedInstall and self._is_preconfigured: self._check_required_passphrase() self.execute() else: self._ready = True hubQ.send_ready(self.__class__.__name__) # Report that the storage spoke has been initialized. self.initialize_done()
def _doExecute(self): self._ready = False hubQ.send_not_ready(self.__class__.__name__) hubQ.send_message(self.__class__.__name__, _("Saving storage configuration...")) try: doKickstartStorage(self.storage, self.data, self.instclass) except (StorageError, BootLoaderError, KickstartValueError) as e: log.error("storage configuration failed: %s", e) StorageChecker.errors = str(e).split("\n") hubQ.send_message(self.__class__.__name__, _("Failed to save storage configuration...")) self.data.bootloader.bootDrive = "" self.data.ignoredisk.drives = [] self.data.ignoredisk.onlyuse = [] self.storage.config.update(self.data) self.storage.reset() self.disks = getDisks(self.storage.devicetree) # now set ksdata back to the user's specified config self._applyDiskSelection(self.selected_disks) else: if self.autopart: # this was already run as part of doAutoPartition. dumb. StorageChecker.errors = [] StorageChecker.warnings = [] self.run() finally: self._ready = True hubQ.send_ready(self.__class__.__name__, True)
def _first_refresh(self): try: self.refresh() return True except MetadataError: hubQ.send_message(self.__class__.__name__, _("No installation source available")) return False
def getRepoMetadata(self): hubQ.send_not_ready("SoftwareSelectionSpoke") hubQ.send_not_ready(self.__class__.__name__) hubQ.send_message(self.__class__.__name__, _(BASEREPO_SETUP_MESSAGE)) # this sleep is lame, but without it the message above doesn't seem # to get processed by the hub in time, and is never shown. # FIXME this should get removed when we figure out how to ensure # that the message takes effect on the hub before we try to mount # a bad NFS server. time.sleep(1) try: self.payload.updateBaseRepo(fallback=False, checkmount=False) except (OSError, PayloadError) as e: log.error("PayloadError: %s" % (e, )) self._error = True hubQ.send_message(self.__class__.__name__, _("Failed to set up installation source")) if not (hasattr(self.data.method, "proxy") and self.data.method.proxy): gtk_call_once( self.set_warning, _("Failed to set up installation source; check the repo url" )) else: gtk_call_once( self.set_warning, _("Failed to set up installation source; check the repo url and proxy settings" )) else: self._error = False hubQ.send_message(self.__class__.__name__, _(METADATA_DOWNLOAD_MESSAGE)) self.payload.gatherRepoMetadata() self.payload.release() if not self.payload.baseRepo: hubQ.send_message(self.__class__.__name__, _(METADATA_ERROR_MESSAGE)) hubQ.send_ready(self.__class__.__name__, False) self._error = True gtk_call_once( self.set_warning, _("Failed to set up installation source; check the repo url" )) else: try: # Grabbing the list of groups could potentially take a long time the # first time (yum does a lot of magic property stuff, some of which # involves side effects like network access) so go ahead and grab # them now. These are properties with side-effects, just accessing # them will trigger yum. e = self.payload.environments g = self.payload.groups except MetadataError: hubQ.send_message("SoftwareSelectionSpoke", _("No installation source available")) else: hubQ.send_ready("SoftwareSelectionSpoke", False) finally: hubQ.send_ready(self.__class__.__name__, False)
def initialize(self): super().initialize() 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._l12_module, self._xkl_wrapper) # make sure the x_layouts list has at least one keyboard layout if not self._l12_module.XLayouts: self._l12_module.SetXLayouts([DEFAULT_KEYBOARD]) self._add_dialog = AddLayoutDialog(self.data) self._add_dialog.initialize() if conf.system.can_configure_keyboard: 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._l12_module) self._switching_dialog.initialize() self._layoutSwitchLabel = self.builder.get_object("layoutSwitchLabel") if not conf.system.can_configure_keyboard: # 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 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 _initialize(self): hubQ.send_message(self.__class__.__name__, _("Probing storage...")) threadMgr.wait(constants.THREAD_STORAGE) hubQ.send_message(self.__class__.__name__, _(METADATA_DOWNLOAD_MESSAGE)) threadMgr.wait(constants.THREAD_PAYLOAD) added = False # If there's no fallback mirror to use, we should just disable that option # in the UI. if not self.payload.mirrorEnabled: self._protocolComboBox.remove(PROTOCOL_MIRROR) # If we've previously set up to use a CD/DVD method, the media has # already been mounted by payload.setup. We can't try to mount it # again. So just use what we already know to create the selector. # Otherwise, check to see if there's anything available. if self.data.method.method == "cdrom": self._cdrom = self.payload.install_device elif not flags.automatedInstall: self._cdrom = opticalInstallMedia(self.storage.devicetree) if self._cdrom: @gtk_action_wait def gtk_action_1(): self._autodetectDeviceLabel.set_text( _("Device: %s") % self._cdrom.name) self._autodetectLabel.set_text( _("Label: %s") % (getattr(self._cdrom.format, "label", "") or "")) gtk_action_1() added = True if self.data.method.method == "harddrive": self._currentIsoFile = self.payload.ISOImage # These UI elements default to not being showable. If optical install # media were found, mark them to be shown. if added: gtk_call_once(self._autodetectBox.set_no_show_all, False) gtk_call_once(self._autodetectButton.set_no_show_all, False) # Add the mirror manager URL in as the default for HTTP and HTTPS. # We'll override this later in the refresh() method, if they've already # provided a URL. # FIXME self._reset_repoStore() self._ready = True hubQ.send_ready(self.__class__.__name__, False)
def decorated(self, *args, **kwargs): ret = func(self, *args, **kwargs) self._unitialized_status = None self._ready = True # pylint: disable-msg=E1101 hubQ.send_ready(self.__class__.__name__, True) hubQ.send_message(self.__class__.__name__, self.status) return ret
def checkStorage(self): threadMgr.wait(constants.THREAD_EXECUTE_STORAGE) hubQ.send_not_ready(self._mainSpokeClass) hubQ.send_message(self._mainSpokeClass, _("Checking storage configuration...")) (StorageChecker.errors, StorageChecker.warnings) = self.storage.sanityCheck() hubQ.send_ready(self._mainSpokeClass, True) for e in StorageChecker.errors: self.log.error(e) for w in StorageChecker.warnings: self.log.warn(w)
def checkStorage(self): threadMgr.wait(constants.THREAD_EXECUTE_STORAGE) hubQ.send_not_ready(self._mainSpokeClass) hubQ.send_message(self._mainSpokeClass, _("Checking storage configuration...")) (StorageChecker.errors, StorageChecker.warnings) = self.storage.sanityCheck() hubQ.send_ready(self._mainSpokeClass, True) for e in StorageChecker.errors: log.error(e) for w in StorageChecker.warnings: log.warn(w)
def initialize(self): NormalSpoke.initialize(self) 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 _initialize(self): hubQ.send_message(self.__class__.__name__, _("Probing storage...")) threadMgr.wait(constants.THREAD_STORAGE) hubQ.send_message(self.__class__.__name__, _(METADATA_DOWNLOAD_MESSAGE)) threadMgr.wait(constants.THREAD_PAYLOAD) added = False # If there's no fallback mirror to use, we should just disable that option # in the UI. if not self.payload.mirrorEnabled: self._protocolComboBox.remove(PROTOCOL_MIRROR) # If we've previously set up to use a CD/DVD method, the media has # already been mounted by payload.setup. We can't try to mount it # again. So just use what we already know to create the selector. # Otherwise, check to see if there's anything available. if self.data.method.method == "cdrom": self._cdrom = self.payload.install_device elif not flags.automatedInstall: self._cdrom = opticalInstallMedia(self.storage.devicetree) if self._cdrom: @gtk_action_wait def gtk_action_1(): self._autodetectDeviceLabel.set_text(_("Device: %s") % self._cdrom.name) self._autodetectLabel.set_text(_("Label: %s") % (getattr(self._cdrom.format, "label", "") or "")) gtk_action_1() added = True if self.data.method.method == "harddrive": self._currentIsoFile = self.payload.ISOImage # These UI elements default to not being showable. If optical install # media were found, mark them to be shown. if added: gtk_call_once(self._autodetectBox.set_no_show_all, False) gtk_call_once(self._autodetectButton.set_no_show_all, False) # Add the mirror manager URL in as the default for HTTP and HTTPS. # We'll override this later in the refresh() method, if they've already # provided a URL. # FIXME self._reset_repoStore() self._ready = True hubQ.send_ready(self.__class__.__name__, False)
def _initialize(self): for day in xrange(1, 32): self.add_to_store(self._daysStore, day) for i in xrange(1, 13): #a bit hacky way, but should return the translated string #TODO: how to handle language change? Clear and populate again? month = datetime.date(2000, i, 1).strftime('%B') self.add_to_store(self._monthsStore, month) self._months_nums[month] = i for year in xrange(1990, 2051): self.add_to_store(self._yearsStore, year) cities = set() xlated_regions = ((region, get_xlated_timezone(region)) for region in self._regions_zones.iterkeys()) for region, xlated in sorted(xlated_regions, cmp=_compare_regions): self.add_to_store_xlated(self._regionsStore, region, xlated) for city in self._regions_zones[region]: cities.add((city, get_xlated_timezone(city))) for city, xlated in sorted(cities, cmp=_compare_cities): self.add_to_store_xlated(self._citiesStore, city, xlated) if self._radioButton24h.get_active(): self._set_amPm_part_sensitive(False) self._update_datetime_timer_id = None if is_valid_timezone(self.data.timezone.timezone): self._set_timezone(self.data.timezone.timezone) elif not flags.flags.automatedInstall: log.warning( "%s is not a valid timezone, falling back to default (%s)", self.data.timezone.timezone, DEFAULT_TZ) self._set_timezone(DEFAULT_TZ) self.data.timezone.timezone = DEFAULT_TZ 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() time_init_thread = threadMgr.get(constants.THREAD_TIME_INIT) if time_init_thread is not None: hubQ.send_message(self.__class__.__name__, _("Restoring hardware time...")) threadMgr.wait(constants.THREAD_TIME_INIT) hubQ.send_ready(self.__class__.__name__, False)
def checkSoftwareSelection(self): hubQ.send_message(self.__class__.__name__, _("Checking software dependencies...")) try: self.payload.check_software_selection() except DependencyError as e: self._error_msgs = str(e) hubQ.send_message(self.__class__.__name__, _("Error checking software dependencies")) self._tx_id = None else: self._error_msgs = None self._tx_id = self.payload.tx_id finally: hubQ.send_ready(self.__class__.__name__, False) hubQ.send_ready("SourceSpoke", False)
def _initialize(self): hubQ.send_message(self.__class__.__name__, _(constants.PAYLOAD_STATUS_PROBING_STORAGE)) threadMgr.wait(constants.THREAD_STORAGE) threadMgr.wait(constants.THREAD_CUSTOM_STORAGE_INIT) self.disks = getDisks(self.storage.devicetree) # if there's only one disk, select it by default if len(self.disks) == 1 and not self.selected_disks: applyDiskSelection(self.storage, self.data, [self.disks[0].name]) self._ready = True hubQ.send_ready(self.__class__.__name__, False)
def checkSoftwareSelection(self): hubQ.send_message(self.__class__.__name__, _("Checking software dependencies...")) try: self.payload.check_software_selection() except DependencyError as e: self._error_msgs = str(e) hubQ.send_message(self.__class__.__name__, _("Error checking software dependencies")) self._tx_id = None else: self._error_msgs = None self._tx_id = self.payload.tx_id finally: hubQ.send_ready(self.__class__.__name__) hubQ.send_ready("SourceSpoke")
def _initialize(self): for day in xrange(1, 32): self.add_to_store(self._daysStore, day) for i in xrange(1, 13): #a bit hacky way, but should return the translated string #TODO: how to handle language change? Clear and populate again? month = datetime.date(2000, i, 1).strftime('%B') self.add_to_store(self._monthsStore, month) self._months_nums[month] = i for year in xrange(1990, 2051): self.add_to_store(self._yearsStore, year) cities = set() xlated_regions = ((region, get_xlated_timezone(region)) for region in self._regions_zones.iterkeys()) for region, xlated in sorted(xlated_regions, cmp=_compare_regions): self.add_to_store_xlated(self._regionsStore, region, xlated) for city in self._regions_zones[region]: cities.add((city, get_xlated_timezone(city))) for city, xlated in sorted(cities, cmp=_compare_cities): self.add_to_store_xlated(self._citiesStore, city, xlated) if self._radioButton24h.get_active(): self._set_amPm_part_sensitive(False) self._update_datetime_timer_id = None if is_valid_timezone(self.data.timezone.timezone): self._set_timezone(self.data.timezone.timezone) elif not flags.flags.automatedInstall: log.warning("%s is not a valid timezone, falling back to default (%s)", self.data.timezone.timezone, DEFAULT_TZ) self._set_timezone(DEFAULT_TZ) self.data.timezone.timezone = DEFAULT_TZ 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() time_init_thread = threadMgr.get(constants.THREAD_TIME_INIT) if time_init_thread is not None: hubQ.send_message(self.__class__.__name__, _("Restoring hardware time...")) threadMgr.wait(constants.THREAD_TIME_INIT) hubQ.send_ready(self.__class__.__name__, False)
def _initialize(self): hubQ.send_message(self.__class__.__name__, _("Probing storage...")) threadMgr.wait(constants.THREAD_STORAGE) threadMgr.wait(constants.THREAD_CUSTOM_STORAGE_INIT) self.disks = getDisks(self.storage.devicetree) # if there's only one disk, select it by default if len(self.disks) == 1 and not self.selected_disks: applyDiskSelection(self.storage, self.data, [self.disks[0].name]) self._ready = True hubQ.send_ready(self.__class__.__name__, False)
def checkSoftwareSelection(self): from pyanaconda.packaging import DependencyError hubQ.send_message(self.__class__.__name__, _("Checking software dependencies...")) try: self.payload.checkSoftwareSelection() except DependencyError as e: self._errorMsgs = "\n".join(sorted(e.message)) hubQ.send_message(self.__class__.__name__, _("Error checking software dependencies")) self._tx_id = None else: self._errorMsgs = None self._tx_id = self.payload.txID finally: hubQ.send_ready(self.__class__.__name__, False) hubQ.send_ready("SourceSpoke", False)
def checkStorage(self): from pyanaconda.storage_utils import storage_checker threadMgr.wait(constants.THREAD_EXECUTE_STORAGE) hubQ.send_not_ready(self._mainSpokeClass) hubQ.send_message(self._mainSpokeClass, _("Checking storage configuration...")) report = storage_checker.check(self.storage) self.errors = report.errors self.warnings = report.warnings hubQ.send_ready(self._mainSpokeClass, True) report.log(self.log)
def getRepoMetadata(self): hubQ.send_not_ready("SoftwareSelectionSpoke") hubQ.send_not_ready(self.__class__.__name__) hubQ.send_message(self.__class__.__name__, _(BASEREPO_SETUP_MESSAGE)) # this sleep is lame, but without it the message above doesn't seem # to get processed by the hub in time, and is never shown. # FIXME this should get removed when we figure out how to ensure # that the message takes effect on the hub before we try to mount # a bad NFS server. time.sleep(1) try: self.payload.updateBaseRepo(fallback=False, checkmount=False) except (OSError, PayloadError) as e: log.error("PayloadError: %s", e) self._error = True hubQ.send_message(self.__class__.__name__, _("Failed to set up installation source")) if not (hasattr(self.data.method, "proxy") and self.data.method.proxy): gtk_call_once(self.set_warning, _("Failed to set up installation source; check the repo url")) else: gtk_call_once(self.set_warning, _("Failed to set up installation source; check the repo url and proxy settings")) else: self._error = False hubQ.send_message(self.__class__.__name__, _(METADATA_DOWNLOAD_MESSAGE)) self.payload.gatherRepoMetadata() self.payload.release() if not self.payload.baseRepo: hubQ.send_message(self.__class__.__name__, _(METADATA_ERROR_MESSAGE)) hubQ.send_ready(self.__class__.__name__, False) self._error = True gtk_call_once(self.set_warning, _("Failed to set up installation source; check the repo url")) else: try: # Grabbing the list of groups could potentially take a long time the # first time (yum does a lot of magic property stuff, some of which # involves side effects like network access) so go ahead and grab # them now. These are properties with side-effects, just accessing # them will trigger yum. # pylint: disable-msg=W0104 self.payload.environments # pylint: disable-msg=W0104 self.payload.groups except MetadataError: hubQ.send_message("SoftwareSelectionSpoke", _("No installation source available")) else: hubQ.send_ready("SoftwareSelectionSpoke", False) finally: hubQ.send_ready(self.__class__.__name__, False)
def _initialize(self): # a bit hacky way, but should return the translated strings for i in range(1, 32): day = datetime.date(2000, 1, i).strftime(self._day_format) self.add_to_store_idx(self._daysStore, i, day) for i in range(1, 13): month = datetime.date(2000, i, 1).strftime(self._month_format) self.add_to_store_idx(self._monthsStore, i, month) for i in range(1990, 2051): year = datetime.date(i, 1, 1).strftime(self._year_format) self.add_to_store_idx(self._yearsStore, i, year) cities = set() xlated_regions = ((region, get_xlated_timezone(region)) for region in self._regions_zones.keys()) for region, xlated in sorted( xlated_regions, key=functools.cmp_to_key(_compare_regions)): self.add_to_store_xlated(self._regionsStore, region, xlated) for city in self._regions_zones[region]: cities.add((city, get_xlated_timezone(city))) for city, xlated in sorted(cities, key=functools.cmp_to_key(_compare_cities)): self.add_to_store_xlated(self._citiesStore, city, xlated) self._update_datetime_timer = None kickstart_timezone = self._timezone_module.proxy.Timezone if is_valid_timezone(kickstart_timezone): self._set_timezone(kickstart_timezone) elif not flags.flags.automatedInstall: log.warning( "%s is not a valid timezone, falling back to default (%s)", kickstart_timezone, DEFAULT_TZ) self._set_timezone(DEFAULT_TZ) self._timezone_module.proxy.SetTimezone(DEFAULT_TZ) time_init_thread = threadMgr.get(constants.THREAD_TIME_INIT) if time_init_thread is not None: hubQ.send_message(self.__class__.__name__, _("Restoring hardware time...")) threadMgr.wait(constants.THREAD_TIME_INIT) hubQ.send_ready(self.__class__.__name__, False) # report that we are done self.initialize_done()
def checkStorage(self): from pyanaconda.storage_utils import sanity_check, SanityError, SanityWarning threadMgr.wait(constants.THREAD_EXECUTE_STORAGE) hubQ.send_not_ready(self._mainSpokeClass) hubQ.send_message(self._mainSpokeClass, _("Checking storage configuration...")) exns = sanity_check(self.storage, min_ram=self._min_ram) errors = [str(exn) for exn in exns if isinstance(exn, SanityError)] warnings = [str(exn) for exn in exns if isinstance(exn, SanityWarning)] (StorageChecker.errors, StorageChecker.warnings) = (errors, warnings) hubQ.send_ready(self._mainSpokeClass, True) for e in StorageChecker.errors: self.log.error(e) for w in StorageChecker.warnings: self.log.warning(w)
def checkStorage(self): from pyanaconda.storage_utils import storage_checker threadMgr.wait(constants.THREAD_EXECUTE_STORAGE) hubQ.send_not_ready(self._mainSpokeClass) hubQ.send_message(self._mainSpokeClass, _("Checking storage configuration...")) report = storage_checker.check(self.storage) # Storage spoke and custom spoke communicate errors via StorageCheckHandler, # so we need to set errors and warnings class attributes here. StorageCheckHandler.errors = report.errors StorageCheckHandler.warnings = report.warnings hubQ.send_ready(self._mainSpokeClass, True) report.log(self.log)
def initialize(self): NormalSpoke.initialize(self) 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") layoutColumn.set_cell_data_func(layoutRenderer, _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 checkStorage(self): threadMgr.wait(constants.THREAD_EXECUTE_STORAGE) hubQ.send_not_ready(self._mainSpokeClass) hubQ.send_message(self._mainSpokeClass, _("Checking storage configuration...")) exns = self.storage.sanityCheck() errors = [exn.message for exn in exns if isinstance(exn, SanityError)] warnings = [ exn.message for exn in exns if isinstance(exn, SanityWarning) ] (StorageChecker.errors, StorageChecker.warnings) = (errors, warnings) hubQ.send_ready(self._mainSpokeClass, True) for e in StorageChecker.errors: log.error(e) for w in StorageChecker.warnings: log.warning(w)
def checkStorage(self): from blivet.errors import SanityError from blivet.errors import SanityWarning threadMgr.wait(constants.THREAD_EXECUTE_STORAGE) hubQ.send_not_ready(self._mainSpokeClass) hubQ.send_message(self._mainSpokeClass, _("Checking storage configuration...")) exns = self.storage.sanityCheck() errors = [exn.message for exn in exns if isinstance(exn, SanityError)] warnings = [exn.message for exn in exns if isinstance(exn, SanityWarning)] (StorageChecker.errors, StorageChecker.warnings) = (errors, warnings) hubQ.send_ready(self._mainSpokeClass, True) for e in StorageChecker.errors: self.log.error(e) for w in StorageChecker.warnings: self.log.warning(w)
def _initialize(self): # a bit hacky way, but should return the translated strings for i in range(1, 32): day = datetime.date(2000, 1, i).strftime(self._day_format) self.add_to_store_idx(self._daysStore, i, day) for i in range(1, 13): month = datetime.date(2000, i, 1).strftime(self._month_format) self.add_to_store_idx(self._monthsStore, i, month) for i in range(1990, 2051): year = datetime.date(i, 1, 1).strftime(self._year_format) self.add_to_store_idx(self._yearsStore, i, year) cities = set() xlated_regions = ((region, get_xlated_timezone(region)) for region in self._regions_zones.keys()) for region, xlated in sorted(xlated_regions, key=functools.cmp_to_key(_compare_regions)): self.add_to_store_xlated(self._regionsStore, region, xlated) for city in self._regions_zones[region]: cities.add((city, get_xlated_timezone(city))) for city, xlated in sorted(cities, key=functools.cmp_to_key(_compare_cities)): self.add_to_store_xlated(self._citiesStore, city, xlated) self._update_datetime_timer = None kickstart_timezone = self._timezone_module.proxy.Timezone if is_valid_timezone(kickstart_timezone): self._set_timezone(kickstart_timezone) elif not flags.flags.automatedInstall: log.warning("%s is not a valid timezone, falling back to default (%s)", kickstart_timezone, DEFAULT_TZ) self._set_timezone(DEFAULT_TZ) self._timezone_module.proxy.SetTimezone(DEFAULT_TZ) time_init_thread = threadMgr.get(constants.THREAD_TIME_INIT) if time_init_thread is not None: hubQ.send_message(self.__class__.__name__, _("Restoring hardware time...")) threadMgr.wait(constants.THREAD_TIME_INIT) hubQ.send_ready(self.__class__.__name__, False) # report that we are done self.initialize_done()
def _doExecute(self): self._ready = False hubQ.send_not_ready(self.__class__.__name__) # on the off-chance dasdfmt is running, we can't proceed further threadMgr.wait(constants.THREAD_DASDFMT) hubQ.send_message(self.__class__.__name__, _("Saving storage configuration...")) try: doKickstartStorage(self.storage, self.data, self.instclass) except (StorageError, KickstartValueError) as e: log.error("storage configuration failed: %s", e) StorageChecker.errors = str(e).split("\n") hubQ.send_message(self.__class__.__name__, _("Failed to save storage configuration...")) self.data.bootloader.bootDrive = "" self.data.ignoredisk.drives = [] self.data.ignoredisk.onlyuse = [] self.storage.config.update(self.data) self.storage.reset() self.disks = getDisks(self.storage.devicetree) # now set ksdata back to the user's specified config applyDiskSelection(self.storage, self.data, self.selected_disks) except BootLoaderError as e: log.error("BootLoader setup failed: %s", e) StorageChecker.errors = str(e).split("\n") hubQ.send_message(self.__class__.__name__, _("Failed to save storage configuration...")) self.data.bootloader.bootDrive = "" else: if self.autopart: self.run() finally: resetCustomStorageData(self.data) self._ready = True hubQ.send_ready(self.__class__.__name__, True)
def _check_software_selection(self): hubQ.send_message(self.__class__.__name__, _("Checking software dependencies...")) self.payload.bump_tx_id() # Run the validation task. from pyanaconda.modules.payloads.payload.dnf.validation import CheckPackagesSelectionTask task = CheckPackagesSelectionTask( dnf_manager=self._dnf_manager, selection=self._selection, ) # Get the validation report. report = task.run() log.debug("The selection has been checked: %s", report) self._errors = list(report.error_messages) self._warnings = list(report.warning_messages) self._tx_id = self.payload.tx_id hubQ.send_ready(self.__class__.__name__) hubQ.send_ready("SourceSpoke")
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 self._policy_data.content_url and self._policy_data.content_type != "scap-security-guide": log.info(f"OSCAP Addon: Actually fetching content from somewhere") thread_name = self.content_bringer.fetch_content( self._handle_error, self._policy_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 run_dasdfmt(self): """ Though the same function exists in pyanaconda.ui.gui.spokes.lib.dasdfmt, this instance doesn't include any of the UI pieces and should only really be getting called on ks installations with "zerombr". """ # wait for the initial storage thread to complete before taking any new # actions on storage devices threadMgr.wait(constants.THREAD_STORAGE) to_format = self.storage.devicetree.make_unformatted_dasd_list(d for d in getDisks(self.storage.devicetree)) if not to_format: # nothing to do here; bail return hubQ.send_message(self.__class__.__name__, _("Formatting DASDs")) for disk in to_format: try: blockdev.s390.dasd_format(disk.name) except blockdev.S390Error as err: # Log errors if formatting fails, but don't halt the installer log.error(str(err)) continue
def _doExecute(self): self._ready = False hubQ.send_not_ready(self.__class__.__name__) # on the off-chance dasdfmt is running, we can't proceed further threadMgr.wait(constants.THREAD_DASDFMT) hubQ.send_message(self.__class__.__name__, _("Saving storage configuration...")) if flags.automatedInstall and self.data.autopart.encrypted and not self.data.autopart.passphrase: self.autopart_missing_passphrase = True StorageChecker.errors = [ _("Passphrase for autopart encryption not specified.") ] self._ready = True hubQ.send_ready(self.__class__.__name__, True) return try: doKickstartStorage(self.storage, self.data, self.instclass) except (StorageError, KickstartParseError) as e: log.error("storage configuration failed: %s", e) StorageChecker.errors = str(e).split("\n") hubQ.send_message(self.__class__.__name__, _("Failed to save storage configuration...")) self.data.bootloader.bootDrive = "" self.data.ignoredisk.drives = [] self.data.ignoredisk.onlyuse = [] self.storage.config.update(self.data) self.storage.reset() self.disks = getDisks(self.storage.devicetree) # now set ksdata back to the user's specified config applyDiskSelection(self.storage, self.data, self.selected_disks) except BootLoaderError as e: log.error("BootLoader setup failed: %s", e) StorageChecker.errors = str(e).split("\n") hubQ.send_message(self.__class__.__name__, _("Failed to save storage configuration...")) self.data.bootloader.bootDrive = "" else: if self.autopart or (flags.automatedInstall and (self.data.autopart.autopart or self.data.partition.seen)): # run() executes StorageChecker.checkStorage in a seperate threat self.run() finally: resetCustomStorageData(self.data) self._ready = True hubQ.send_ready(self.__class__.__name__, True)
def _initialize(self): hubQ.send_message(self.__class__.__name__, _("Downloading package metadata...")) threadMgr.wait(constants.THREAD_PAYLOAD) hubQ.send_message(self.__class__.__name__, _("Downloading group metadata...")) # we have no way to select environments with kickstart right now # so don't try. if flags.automatedInstall and self.data.packages.seen: # We don't want to do a full refresh, just join the metadata thread threadMgr.wait(constants.THREAD_PAYLOAD_MD) else: # Grabbing the list of groups could potentially take a long time # at first (yum does a lot of magic property stuff, some of which # involves side effects like network access. We need to reference # them here, outside of the main thread, to not block the UI. try: # pylint: disable-msg=W0104 self.payload.environments # pylint: disable-msg=W0104 self.payload.groups # Parse the environments and groups into the form we want self._parseEnvironments() except MetadataError: hubQ.send_message(self.__class__.__name__, _("No installation source available")) return # And then having done all that slow downloading, we need to do the first # refresh of the UI here so there's an environment selected by default. # This happens inside the main thread by necessity. We can't do anything # that takes any real amount of time, or it'll block the UI from updating. if not self._first_refresh(): return self.payload.release() hubQ.send_ready(self.__class__.__name__, False) # If packages were provided by an input kickstart file (or some other means), # we should do dependency solving here. self._apply()
def _doExecute(self): self._ready = False hubQ.send_not_ready(self.__class__.__name__) # on the off-chance dasdfmt is running, we can't proceed further threadMgr.wait(constants.THREAD_DASDFMT) hubQ.send_message(self.__class__.__name__, _("Saving storage configuration...")) if flags.automatedInstall and self.data.autopart.encrypted and not self.data.autopart.passphrase: self.autopart_missing_passphrase = True StorageChecker.errors = [_("Passphrase for autopart encryption not specified.")] self._ready = True hubQ.send_ready(self.__class__.__name__, True) return try: doKickstartStorage(self.storage, self.data, self.instclass) except (StorageError, KickstartParseError) as e: log.error("storage configuration failed: %s", e) StorageChecker.errors = str(e).split("\n") hubQ.send_message(self.__class__.__name__, _("Failed to save storage configuration...")) self.data.bootloader.bootDrive = "" self.data.ignoredisk.drives = [] self.data.ignoredisk.onlyuse = [] self.storage.config.update(self.data) self.storage.reset() self.disks = getDisks(self.storage.devicetree) # now set ksdata back to the user's specified config applyDiskSelection(self.storage, self.data, self.selected_disks) except BootLoaderError as e: log.error("BootLoader setup failed: %s", e) StorageChecker.errors = str(e).split("\n") hubQ.send_message(self.__class__.__name__, _("Failed to save storage configuration...")) self.data.bootloader.bootDrive = "" else: if self.autopart or (flags.automatedInstall and (self.data.autopart.autopart or self.data.partition.seen)): # run() executes StorageChecker.checkStorage in a seperate threat self.run() finally: resetCustomStorageData(self.data) self._ready = True hubQ.send_ready(self.__class__.__name__, True)
def _on_register_status_change(self, obj, params): status = obj.get_property('register-status') self._status = status hubQ.send_message(self.__class__.__name__, self._status)
def _show_dasdfmt_report(self, msg): hubQ.send_message(self.__class__.__name__, msg)
def _downloading_package_md(self): hubQ.send_message(self.__class__.__name__, _("Downloading package metadata..."))
def _show_execute_message(self, msg): hubQ.send_message(self.__class__.__name__, msg) log.debug(msg)
def _init_after_data_fetch(self, wait_for): """ Waits for data fetching to be finished, extracts it (if needed), populates the stores and evaluates pre-installation fixes from the content and marks the spoke as ready in the end. :param wait_for: name of the thread to wait for (if any) :type wait_for: str or None """ try: threadMgr.wait(wait_for) except data_fetch.DataFetchError: self._data_fetch_failed() with self._fetch_flag_lock: self._fetching = False return finally: # stop the spinner in any case fire_gtk_action(self._progress_spinner.stop) if self._addon_data.fingerprint: hash_obj = utils.get_hashing_algorithm(self._addon_data.fingerprint) digest = utils.get_file_fingerprint(\ self._addon_data.raw_preinst_content_path, hash_obj) if digest != self._addon_data.fingerprint: msg = _("Integrity check failed") raise content_handling.ContentCheckError(msg) # RPM is an archive at this phase if self._addon_data.content_type in ("archive", "rpm"): # extract the content try: fpaths = common.extract_data(\ self._addon_data.raw_preinst_content_path, common.INSTALLATION_CONTENT_DIR, [self._addon_data.xccdf_path]) except common.ExtractionError as err: self._extraction_failed(err.message) # fetching done with self._fetch_flag_lock: self._fetching = False return # and populate missing fields self._content_handling_cls, files = \ content_handling.explore_content_files(fpaths) files = common.strip_content_dir(files) # pylint: disable-msg=E1103 self._addon_data.xccdf_path = self._addon_data.xccdf_path or files.xccdf self._addon_data.cpe_path = self._addon_data.cpe_path or files.cpe self._addon_data.tailoring_path = (self._addon_data.tailoring_path or files.tailoring) elif self._addon_data.content_type == "datastream": self._content_handling_cls = content_handling.DataStreamHandler elif self._addon_data.content_type == "scap-security-guide": self._content_handling_cls = content_handling.BenchmarkHandler else: raise common.OSCAPaddonError("Unsupported content type") try: self._content_handler = self._content_handling_cls(\ self._addon_data.preinst_content_path, self._addon_data.preinst_tailoring_path) except content_handling.ContentHandlingError: self._invalid_content() # fetching done with self._fetch_flag_lock: self._fetching = False return if self._using_ds: # populate the stores from items from the content self._ds_checklists = self._content_handler.get_data_streams_checklists() for dstream in self._ds_checklists.iterkeys(): self._add_ds_id(dstream) else: # hide the labels and comboboxes for datastream-id and xccdf-id # selection fire_gtk_action(really_hide, self._ids_box) # refresh UI elements self.refresh() # try to switch to the chosen profile (if any) self._switch_profile() # initialize the self._addon_data.rule_data self._addon_data.rule_data = self._rule_data # update the message store with the messages self._update_message_store() # no more being unitialized self._unitialized_status = None self._ready = True # all initialized, we can now let user set parameters self._main_notebook.set_current_page(SET_PARAMS_PAGE) # and use control buttons really_show(self._control_buttons) # pylint: disable-msg=E1101 hubQ.send_ready(self.__class__.__name__, True) hubQ.send_message(self.__class__.__name__, self.status) # fetching done with self._fetch_flag_lock: self._fetching = False
def _downloading_group_md(self): hubQ.send_message(self.__class__.__name__, _("Downloading group metadata..."))
def _payload_error(self): self._error = True hubQ.send_message(self.__class__.__name__, payloadMgr.error)
def _downloading_group_md(self): hubQ.send_message(self.__class__.__name__, _(constants.PAYLOAD_STATUS_GROUP_MD))
def _downloading_package_md(self): # Reset the error state from previous payloads self._error = False hubQ.send_message(self.__class__.__name__, _(constants.PAYLOAD_STATUS_PACKAGE_MD))