def render_distribution_publish_step(self, progress_report): """ Render the errata export progress. :param progress_report: A dictionary containing the progress report from the export distributor :type progress_report: dict """ data = progress_report[ids.TYPE_ID_DISTRIBUTOR_EXPORT][models.Distribution.TYPE] state = data[constants.PROGRESS_STATE_KEY] if state == constants.STATE_NOT_STARTED: return # Only render this on the first non-not-started state if self.distributions_last_state == constants.STATE_NOT_STARTED: self.prompt.write(_('Exporting distributions...')) if self.distributions_last_state not in constants.COMPLETE_STATES: if state in (constants.STATE_RUNNING, constants.STATE_COMPLETE): self.distributions_last_state = state render_itemized_in_progress_state(self.prompt, data, _('distributions'), self.distributions_bar, state) elif state == constants.STATE_FAILED: self.prompt.write(_('... failed')) self.distributions_last_state = constants.STATE_FAILED
def render_errata_step(self, progress_report): """ Render the errata export progress. :param progress_report: A dictionary containing the progress report from the export distributor :type progress_report: dict """ data = progress_report[ids.TYPE_ID_DISTRIBUTOR_EXPORT][ids.TYPE_ID_ERRATA] state = data[constants.PROGRESS_STATE_KEY] if state == constants.STATE_NOT_STARTED: return # Only render this on the first non-not-started state if self.errata_last_state == constants.STATE_NOT_STARTED: self.prompt.write(_('Exporting errata...')) # Render the progress bar while the state is running and once on state completion if self.errata_last_state not in constants.COMPLETE_STATES: if state in (constants.STATE_RUNNING, constants.STATE_COMPLETE): self.errata_last_state = state render_itemized_in_progress_state(self.prompt, data, _('errata'), self.errata_bar, state) elif state == constants.STATE_FAILED: self.prompt.write(_('... failed')) self.errata_last_state = constants.STATE_FAILED
def render_isos_step(self, progress_report): """ Render the ISO image generation export progress. :param progress_report: A dictionary containing the progress report from the export distributor :type progress_report: dict """ data = progress_report[ids.TYPE_ID_DISTRIBUTOR_EXPORT][constants.PROGRESS_ISOS_KEYWORD] state = data[constants.PROGRESS_STATE_KEY] if state == constants.STATE_NOT_STARTED: return if self.isos_last_state not in constants.COMPLETE_STATES: if state in (constants.STATE_RUNNING, constants.STATE_COMPLETE): self.isos_last_state = state render_itemized_in_progress_state(self.prompt, data, _('ISO images'), self.isos_bar, state) elif state == constants.STATE_FAILED: self.prompt.write(_('... failed')) self.isos_last_state = constants.STATE_FAILED
def render_packages_step(self, progress_report): # Example Data: # "packages": { # "num_success": 21, # "items_left": 0, # "items_total": 21, # "state": "FINISHED", # "error_details": [], # "num_error": 0 # }, data = progress_report['yum_distributor']['packages'] state = data['state'] self.check_for_cancelled_state(state) if state in (constants.STATE_NOT_STARTED, constants.STATE_SKIPPED): return # Only render this on the first non-not-started state if self.packages_last_state == constants.STATE_NOT_STARTED: self.prompt.write(_('Publishing packages...')) # If it's running or finished, the output is still the same. This way, # if the status is viewed after this step, the content download # summary is still available. if state in (constants.STATE_RUNNING, constants.STATE_COMPLETE) and self.packages_last_state not in constants.COMPLETE_STATES: self.packages_last_state = state render_itemized_in_progress_state(self.prompt, data, _('packages'), self.packages_bar, state) elif state == constants.STATE_FAILED and self.packages_last_state not in constants.COMPLETE_STATES: # This state means something went horribly wrong. There won't be # individual package error details which is why they are only # displayed above and not in this case. self.prompt.write(_('... failed')) self.packages_last_state = constants.STATE_FAILED
def render_isos_step(self, progress_report): """ This function handles the rendering of the constants.PROGRESS_ISOS_KEYWORD progress report :param progress_report: The progress report from the group export distributor :type progress_report: dict """ # Grab the iso progress report out of the progress_report dict data = progress_report[ids.EXPORT_GROUP_DISTRIBUTOR_ID][constants.PROGRESS_ISOS_KEYWORD] state = data[constants.PROGRESS_STATE_KEY] if state == constants.STATE_NOT_STARTED: return if self.isos_last_state not in constants.COMPLETE_STATES: if state in (constants.STATE_RUNNING, constants.STATE_COMPLETE): self.isos_last_state = state render_itemized_in_progress_state(self.prompt, data, _('Generating ISO images...'), self.isos_bar, state) elif state == constants.STATE_FAILED: self.prompt.write(_('... failed')) self.isos_last_state = constants.STATE_FAILED
def render_distribution_sync_step(self, progress_report): data = progress_report['yum_importer']['distribution'] state = data['state'] self.check_for_cancelled_state(state) # Render nothing if we haven't begun yet or if this step is skipped if state in (constants.STATE_NOT_STARTED, constants.STATE_SKIPPED): return # Only render this on the first non-not-started state if self.distribution_sync_last_state == constants.STATE_NOT_STARTED: self.prompt.write(_('Downloading distribution files...')) if (state in (constants.STATE_RUNNING, constants.STATE_COMPLETE) and self.distribution_sync_last_state not in constants.COMPLETE_STATES): render_itemized_in_progress_state(self.prompt, data, _('distributions'), self.distribution_sync_bar, state) elif state in constants.STATE_FAILED and \ self.distribution_sync_last_state not in constants.COMPLETE_STATES: self.prompt.render_spacer() self.prompt.render_failure_message(_('Errors encountered during distribution sync:')) # TODO: read this from config # display_error_count = self.context.extension_config.getint('main', # 'num_display_errors') display_error_count = 5 num_errors = min(len(data['error_details']), display_error_count) if num_errors > 0: # Each error is a list of filename and dict of details # Example: # "error_details": [ # [ # "file:///mnt/iso/f18/images/boot.iso", # { # "response_code": 0, # "error_message": "Couldn't open file /mnt/iso/f18/images/boot.iso", # "error_code": 37 # } # ] # ], for i in range(0, num_errors): error = data['error_details'][i] message_data = { 'filename': error[0], 'message': error[1].get('error_message'), 'code': error[1].get('error_code'), } template = 'File: %(filename)s\n' template += 'Error Code: %(code)s\n' template += 'Error Message: %(message)s' message = template % message_data self.prompt.render_failure_message(message) self.prompt.render_spacer() self.distribution_sync_last_state = state
def render_distribution_sync_step(self, progress_report): data = progress_report['yum_importer']['distribution'] state = data['state'] self.check_for_cancelled_state(state) # Render nothing if we haven't begun yet or if this step is skipped if state in (constants.STATE_NOT_STARTED, constants.STATE_SKIPPED): return # Only render this on the first non-not-started state if self.distribution_sync_last_state == constants.STATE_NOT_STARTED: self.prompt.write(_('Downloading distribution files...')) if (state in (constants.STATE_RUNNING, constants.STATE_COMPLETE) and self.distribution_sync_last_state not in constants.COMPLETE_STATES): render_itemized_in_progress_state(self.prompt, data, _('distributions'), self.distribution_sync_bar, state) elif state in constants.STATE_FAILED and \ self.distribution_sync_last_state not in constants.COMPLETE_STATES: self.prompt.render_spacer() self.prompt.render_failure_message( _('Errors encountered during distribution sync:')) # TODO: read this from config # display_error_count = self.context.extension_config.getint('main', # 'num_display_errors') display_error_count = 5 num_errors = min(len(data['error_details']), display_error_count) if num_errors > 0: # Each error is a list of filename and dict of details # Example: # "error_details": [ # [ # "file:///mnt/iso/f18/images/boot.iso", # { # "response_code": 0, # "error_message": "Couldn't open file /mnt/iso/f18/images/boot.iso", # "error_code": 37 # } # ] # ], for i in range(0, num_errors): error = data['error_details'][i] message_data = { 'filename': error[0], 'message': error[1].get('error_message'), 'code': error[1].get('error_code'), } template = 'File: %(filename)s\n' template += 'Error Code: %(code)s\n' template += 'Error Message: %(message)s' message = template % message_data self.prompt.render_failure_message(message) self.prompt.render_spacer() self.distribution_sync_last_state = state