def runImportStepFromProfile(self, profile_id, step_id, run_dependencies=True, purge_old=None): """ See ISetupTool. """ context = self._getImportContext(profile_id, purge_old) self.applyContext(context) info = self.getImportStepMetadata(step_id) if info is None: generic_logger.error( "No such import step: '%s' Maybe you meant one of %s", step_id, str(self.listImportSteps())) raise ValueError('No such import step: %s' % step_id) dependencies = info.get('dependencies', ()) messages = {} steps = [] if run_dependencies: for dependency in dependencies: if dependency not in steps: steps.append(dependency) steps.append(step_id) full_import = (set(steps) == set(self.getSortedImportSteps())) event.notify( BeforeProfileImportEvent(self, profile_id, steps, full_import)) for step in steps: message = self._doRunImportStep(step, context) messages[step] = message or '' message_list = filter(None, [message]) message_list.extend(['%s: %s' % x[1:] for x in context.listNotes()]) messages[step_id] = '\n'.join(message_list) event.notify(ProfileImportedEvent(self, profile_id, steps, full_import)) return {'steps': steps, 'messages': messages}
messages = {} event.notify( BeforeProfileImportEvent(self, profile_id, steps, True)) for step in steps: if blacklisted_steps and step in blacklisted_steps: message = 'step skipped' else: message = self._doRunImportStep(step, context) message_list = filter(None, [message]) message_list.extend( ['%s: %s' % x[1:] for x in context.listNotes()]) messages[step] = '\n'.join(message_list) context.clearNotes() event.notify(ProfileImportedEvent(self, profile_id, steps, True)) results.append({'steps': steps, 'messages': messages}) data = {'steps': [], 'messages': {}} for result in results: for step in result['steps']: if step not in data['steps']: data['steps'].append(step) for (step, msg) in result['messages'].items(): if step in data['messages']: data['messages'][step] += "\n" + msg else: data['messages'][step] = msg data['steps'] = list(data['steps'])