def run(args): (rep, maxlen) = utils.welcome(PROG_NAME) if args.get('list_deps'): header = utils.center_text("Dependencies", rep, maxlen) print(header) _run_list_deps(args) if args.get('describe_comp'): header = utils.center_text("Descriptions", rep, maxlen) print(header) _run_describe_comps(args) return True
def _run_action(args): defaulted_components = False components = settings.parse_components(args.pop("components")) if not components: defaulted_components = True components = _get_def_components() action = _clean_action(args.pop("action")) if not action: cprint("No valid action specified!", "red") return False rootdir = args.pop("dir") if rootdir is None: cprint("No root directory specified!", "red") return False #ensure os/distro is known (distro, platform) = utils.determine_distro() if distro is None: print("Unsupported platform " + colored(platform, "red") + "!") return False #start it (rep, maxlen) = utils.welcome(_WELCOME_MAP.get(action)) header = utils.center_text("Action Runner", rep, maxlen) print(header) #need to figure out dependencies for components (if any) ignore_deps = args.pop('ignore_deps', False) if not defaulted_components: LOG.info("Activating components [%s]" % (", ".join(sorted(components.keys())))) else: LOG.info("Activating default components [%s]" % (", ".join(sorted(components.keys())))) if not ignore_deps: new_components = settings.resolve_dependencies(components.keys()) component_diff = new_components.difference(components.keys()) if component_diff: LOG.info("Having to activate dependent components: [%s]" % (", ".join(sorted(component_diff)))) for new_component in component_diff: components[new_component] = list() component_skips = _check_roots(action, rootdir, components.keys()) for c in component_skips: components.pop(c) if not components: LOG.error("After checking the various components roots, no components ended up being specified!") return False #get the right component order (by priority) component_order = settings.prioritize_components(components.keys()) if action in _REVERSE_ACTIONS: #reverse them so that we stop in the reverse order #and that we uninstall in the reverse order which seems to make sense component_order.reverse() #add in any that will just be referenced but which will not actually do anything (ie the action will not be applied to these) ref_components = settings.parse_components(args.pop("ref_components")) for c in ref_components.keys(): if c not in components: components[c] = ref_components.get(c) #now do it! LOG.info("Starting action [%s] on %s for distro [%s]" % (action, date.rcf8222date(), distro)) results = _run_components(action, component_order, components, distro, rootdir, args) LOG.info("Finished action [%s] on %s" % (action, date.rcf8222date())) if results: LOG.info('Check [%s] for traces of what happened.' % ", ".join(results)) return True
def _run_action(args): defaulted_components = False components = utils.parse_components(args.pop("components")) if not components: defaulted_components = True components = common.get_default_components() action = _clean_action(args.pop("action")) if not action: print(utils.color_text("No valid action specified!", "red")) return False rootdir = args.pop("dir") if rootdir is None: print(utils.color_text("No root directory specified!", "red")) return False #ensure os/distro is known (distro, platform) = utils.determine_distro() if distro is None: print("Unsupported platform " + utils.color_text(platform, "red") + "!") return False #start it (rep, maxlen) = utils.welcome(_WELCOME_MAP.get(action)) header = utils.center_text("Action Runner", rep, maxlen) print(header) #here on out should be using the logger if not defaulted_components: LOG.info("Activating components [%s]" % (", ".join(sorted(components.keys())))) else: LOG.info("Activating default components [%s]" % (", ".join(sorted(components.keys())))) #need to figure out dependencies for components (if any) ignore_deps = args.pop('ignore_deps', False) component_order = None if not ignore_deps: all_components_deps = common.get_components_deps(action, components) component_diff = set(all_components_deps.keys()).difference(components.keys()) if component_diff: LOG.info("Having to activate dependent components: [%s]" \ % (", ".join(sorted(component_diff)))) for new_component in component_diff: components[new_component] = list() component_order = utils.get_components_order(all_components_deps) else: component_order = components.keys() #reverse them so that we stop in the reverse order #and that we uninstall in the reverse order which seems to make sense if action in _REVERSE_ACTIONS: component_order.reverse() #add in any that will just be referenced but which will not actually do anything (ie the action will not be applied to these) ref_components = utils.parse_components(args.pop("ref_components")) for c in ref_components.keys(): if c not in components: components[c] = ref_components.get(c) #now do it! LOG.info("Starting action [%s] on %s for distro [%s]" % (action, date.rcf8222date(), distro)) _run_components(action, component_order, components, distro, rootdir, args) LOG.info("Finished action [%s] on %s" % (action, date.rcf8222date())) return True