def _get_parser(self): """ Overridden from SoloCommand. """ descriptor = SoloCommandDescriptor.obtain_descriptor(SoloDeptest.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloDeptest.NAME)) parser.add_argument("--ask", "-a", action="store_true", default=self._ask, help=_("ask before making any changes")) parser.add_argument("--quiet", "-q", action="store_true", default=self._quiet, help=_("show less details (useful for scripting)")) parser.add_argument("--pretend", "-p", action="store_true", default=self._pretend, help=_("just show what would be done")) return parser
def _show_help(self, *args): # equo help <foo> <bar> if len(self._args) > 1: # syntax error return -10 parser = argparse.ArgumentParser( description=_("Entropy Command Line Client, Equo"), epilog="http://www.sabayon.org", formatter_class=ColorfulFormatter) # filtered out in solo.main. Will never get here parser.add_argument( "--color", action="store_true", default=None, help=_("force colored output")) descriptors = SoloCommandDescriptor.obtain() descriptors.sort(key = lambda x: x.get_name()) group = parser.add_argument_group("command", "available commands") for descriptor in descriptors: if descriptor.get_class().HIDDEN: continue aliases = descriptor.get_class().ALIASES aliases_str = ", ".join([teal(x) for x in aliases]) if aliases_str: aliases_str = " [%s]" % (aliases_str,) name = "%s%s" % (purple(descriptor.get_name()), aliases_str) desc = descriptor.get_description() group.add_argument(name, help=darkgreen(desc), action="store_true") parser.print_help() if not self._args: return 1 return 0
def _get_parser(self): """ Overridden from SoloCommand. """ _commands = {} descriptor = SoloCommandDescriptor.obtain_descriptor( SoloPreservedLibs.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloPreservedLibs.NAME)) subparsers = parser.add_subparsers( title="action", description=_("manage preserved libraries"), help=_("available commands")) list_parser = subparsers.add_parser( "list", help=_("list the currently preserved libraries")) list_parser.set_defaults(func=self._list) self._setup_verbose_quiet_parser(list_parser) _commands["list"] = {} gc_parser = subparsers.add_parser( "gc", help=_("show libraries that could be garbage collected")) gc_parser.set_defaults(func=self._gc) _commands["gc"] = {} self._commands = _commands return parser
def _get_parser(self): """ Overridden from SoloCommand. """ _commands = [] descriptor = SoloCommandDescriptor.obtain_descriptor( SoloUnused.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloUnused.NAME)) parser.add_argument("--quiet", "-q", action="store_true", default=self._quiet, help=_("show less details (useful for scripting)")) _commands.append("--quiet") _commands.append("-q") parser.add_argument("--sortbysize", action="store_true", default=self._sortbysize, help=_("sort packages by size")) _commands.append("--sortbysize") parser.add_argument("--spm-wanted", action="store_true", default=self._spm_wanted, help=_("consider packages installed with" \ " a Source Package Manager to be wanted")) _commands.append("--spm-wanted") self._commands = _commands return parser
def _show_help(self, *args): # equo help <foo> <bar> if len(self._args) > 1: # syntax error return -10 parser = argparse.ArgumentParser( description=_("Entropy Command Line Client, Equo"), epilog="http://www.sabayon.org", formatter_class=ColorfulFormatter) # filtered out in solo.main. Will never get here parser.add_argument("--color", action="store_true", default=None, help=_("force colored output")) descriptors = SoloCommandDescriptor.obtain() descriptors.sort(key=lambda x: x.get_name()) group = parser.add_argument_group("command", "available commands") for descriptor in descriptors: if descriptor.get_class().HIDDEN: continue aliases = descriptor.get_class().ALIASES aliases_str = ", ".join([teal(x) for x in aliases]) if aliases_str: aliases_str = " [%s]" % (aliases_str, ) name = "%s%s" % (purple(descriptor.get_name()), aliases_str) desc = descriptor.get_description() group.add_argument(name, help=darkgreen(desc), action="store_true") parser.print_help() if not self._args: return 1 return 0
def _get_parser(self): """ Overridden from SoloCommand. """ _commands = [] descriptor = SoloCommandDescriptor.obtain_descriptor( SoloCache.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloCache.NAME)) subparsers = parser.add_subparsers( title="action", description=_("manage cache"), help=_("available commands")) clean_parser = subparsers.add_parser( "clean", help=_("clean Entropy Library Cache")) clean_parser.add_argument( "--verbose", "-v", action="store_true", default=False, help=_("show more details")) clean_parser.add_argument( "--quiet", "-q", action="store_true", default=False, help=_("print results in a scriptable way")) clean_parser.set_defaults(func=self._clean) _commands.append("clean") self._commands = _commands return parser
def _get_parser(self): """ Overridden from SoloCommand. """ _commands = [] descriptor = SoloCommandDescriptor.obtain_descriptor( SoloConf.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloConf.NAME)) subparsers = parser.add_subparsers( title="action", description=_("manage configuration file updates"), help=_("available commands")) update_parser = subparsers.add_parser( "update", help=_("update configuration files")) update_parser.set_defaults(func=self._update) _commands.append("update") self._commands = _commands return parser
def bashcomp(self, last_arg): """ Overridden from SoloCommand """ import sys descriptors = SoloCommandDescriptor.obtain() descriptors.sort(key=lambda x: x.get_name()) outcome = [] for descriptor in descriptors: name = descriptor.get_name() if name == SoloHelp.NAME: # do not add self continue outcome.append(name) aliases = descriptor.get_class().ALIASES outcome.extend(aliases) def _startswith(string): if last_arg is not None: return string.startswith(last_arg) return True outcome = sorted(filter(_startswith, outcome)) sys.stdout.write(" ".join(outcome) + "\n") sys.stdout.flush()
def bashcomp(self, last_arg): """ Overridden from SoloCommand """ import sys descriptors = SoloCommandDescriptor.obtain() descriptors.sort(key = lambda x: x.get_name()) outcome = [] for descriptor in descriptors: name = descriptor.get_name() if name == SoloHelp.NAME: # do not add self continue outcome.append(name) aliases = descriptor.get_class().ALIASES outcome.extend(aliases) def _startswith(string): if last_arg is not None: return string.startswith(last_arg) return True outcome = sorted(filter(_startswith, outcome)) sys.stdout.write(" ".join(outcome) + "\n") sys.stdout.flush()
def _get_parser(self): """ Overridden from SoloCommand. """ _commands = [] descriptor = SoloCommandDescriptor.obtain_descriptor(SoloUnused.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloUnused.NAME)) parser.add_argument("--quiet", "-q", action="store_true", default=self._quiet, help=_("show less details (useful for scripting)")) _commands.append("--quiet") _commands.append("-q") parser.add_argument("--sortbysize", action="store_true", default=self._sortbysize, help=_("sort packages by size")) _commands.append("--sortbysize") parser.add_argument("--spm-wanted", action="store_true", default=self._spm_wanted, help=_("consider packages installed with" \ " a Source Package Manager to be wanted")) _commands.append("--spm-wanted") self._commands = _commands return parser
def _get_parser(self): """ Overridden from SoloCommand. """ descriptor = SoloCommandDescriptor.obtain_descriptor( SoloSearch.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloSearch.NAME)) parser.add_argument("string", nargs='+', metavar="<string>", help=_("search keyword")) parser.add_argument("--quiet", "-q", action="store_true", default=self._quiet, help=_('quiet output, for scripting purposes')) parser.add_argument("--verbose", "-v", action="store_true", default=self._verbose, help=_('verbose output')) group = parser.add_mutually_exclusive_group() group.add_argument("--installed", action="store_true", default=self._installed, help=_('search among installed packages only')) group.add_argument("--available", action="store_true", default=self._available, help=_('search among available packages only')) return parser
def _get_parser(self): """ Overridden from SoloCommand. """ descriptor = SoloCommandDescriptor.obtain_descriptor(SoloCleanup.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloCleanup.NAME)) return parser
def _get_parser(self): """ Overridden from SoloCommand. """ descriptor = SoloCommandDescriptor.obtain_descriptor( SoloCleanup.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloCleanup.NAME)) return parser
def _get_parser(self): """ Overridden from SoloCommand. """ descriptor = SoloCommandDescriptor.obtain_descriptor(SoloLibtest.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloLibtest.NAME)) _commands = [] parser.add_argument("--ask", "-a", action="store_true", default=False, help=_("ask before making any changes")) _commands.append("--ask") _commands.append("-a") parser.add_argument("--quiet", "-q", action="store_true", default=False, help=_("show less details " "(useful for scripting)")) _commands.append("--quiet") _commands.append("-q") parser.add_argument("--pretend", "-p", action="store_true", default=False, help=_("just show what would be done")) _commands.append("--pretend") _commands.append("-p") parser.add_argument("--listfiles", action="store_true", default=False, help=_("print broken files to stdout")) _commands.append("--listfiles") parser.add_argument("--dump", action="store_true", default=False, help=_("dump results to files")) _commands.append("--dump") self._commands = _commands return parser
def _get_parser(self): """ Overridden from SoloCommand. """ descriptor = SoloCommandDescriptor.obtain_descriptor( SoloHop.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloHop.NAME)) parser.add_argument( "branch", metavar="<branch>", help=_("branch")) return parser
def _get_parser(self): """ Overridden from SoloCommand. """ descriptor = SoloCommandDescriptor.obtain_descriptor(SoloNotice.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloNotice.NAME)) parser.add_argument("repo", nargs='+', metavar="<repo>", help=_("repository")) return parser
def _get_parser(self): """ Overridden from SoloCommand. """ descriptor = SoloCommandDescriptor.obtain_descriptor( SoloUpdate.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloUpdate.NAME)) parser.add_argument("repo", nargs='*', default=None, metavar="<repo>", help=_("repository")) parser.add_argument("--force", action="store_true", default=self._force, help=_("force update")) return parser
def _get_parser(self): """ Overridden from SoloCommand. """ descriptor = SoloCommandDescriptor.obtain_descriptor( SoloLibtest.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloLibtest.NAME)) _commands = [] parser.add_argument("--ask", "-a", action="store_true", default=False, help=_("ask before making any changes")) _commands.append("--ask") _commands.append("-a") parser.add_argument("--quiet", "-q", action="store_true", default=False, help=_("show less details " "(useful for scripting)")) _commands.append("--quiet") _commands.append("-q") parser.add_argument("--pretend", "-p", action="store_true", default=False, help=_("just show what would be done")) _commands.append("--pretend") _commands.append("-p") parser.add_argument("--listfiles", action="store_true", default=False, help=_("print broken files to stdout")) _commands.append("--listfiles") parser.add_argument("--dump", action="store_true", default=False, help=_("dump results to files")) _commands.append("--dump") self._commands = _commands return parser
def _get_parser(self): """ Overridden from SoloCommand. """ _commands = {} descriptor = SoloCommandDescriptor.obtain_descriptor( SoloConfig.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloConfig.NAME)) parser.set_defaults(func=self._config) parser.add_argument( "packages", nargs='+', metavar="<package>", help=_("package name")) mg_group = parser.add_mutually_exclusive_group() mg_group.add_argument( "--ask", "-a", action="store_true", default=False, help=_("ask before making any changes")) _commands["--ask"] = {} _commands["-a"] = {} mg_group.add_argument( "--pretend", "-p", action="store_true", default=False, help=_("show what would be done")) _commands["--pretend"] = {} _commands["-p"] = {} parser.add_argument( "--verbose", "-v", action="store_true", default=False, help=_("verbose output")) _commands["--verbose"] = {} _commands["-v"] = {} self._commands = _commands return parser
def _get_parser(self): """ Overridden from SoloCommand. """ descriptor = SoloCommandDescriptor.obtain_descriptor(SoloUpdate.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloUpdate.NAME)) parser.add_argument("repo", nargs='*', default=None, metavar="<repo>", help=_("repository")) parser.add_argument("--force", action="store_true", default=self._force, help=_("force update")) return parser
def _get_parser(self): """ Overridden from SoloCommand. """ descriptor = SoloCommandDescriptor.obtain_descriptor( SoloDeptest.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloDeptest.NAME)) parser.add_argument("--ask", "-a", action="store_true", default=self._ask, help=_("ask before making any changes")) parser.add_argument("--quiet", "-q", action="store_true", default=self._quiet, help=_("show less details (useful for scripting)")) parser.add_argument("--pretend", "-p", action="store_true", default=self._pretend, help=_("just show what would be done")) return parser
def _get_parser(self): """ Overridden from SoloCommand. """ descriptor = SoloCommandDescriptor.obtain_descriptor(SoloSearch.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloSearch.NAME)) parser.add_argument("string", nargs='+', metavar="<string>", help=_("search keyword")) parser.add_argument("--quiet", "-q", action="store_true", default=self._quiet, help=_('quiet output, for scripting purposes')) parser.add_argument("--verbose", "-v", action="store_true", default=self._verbose, help=_('verbose output')) group = parser.add_mutually_exclusive_group() group.add_argument("--installed", action="store_true", default=self._installed, help=_('search among installed packages only')) group.add_argument("--available", action="store_true", default=self._available, help=_('search among available packages only')) return parser
def _get_parser(self): """ Overridden from SoloCommand. """ _commands = [] descriptor = SoloCommandDescriptor.obtain_descriptor(SoloConf.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloConf.NAME)) subparsers = parser.add_subparsers( title="action", description=_("manage configuration file updates"), help=_("available commands")) update_parser = subparsers.add_parser( "update", help=_("update configuration files")) update_parser.set_defaults(func=self._update) _commands.append("update") self._commands = _commands return parser
def _get_parser(self): """ Overridden from SoloCommand. """ descriptor = SoloCommandDescriptor.obtain_descriptor( self.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], self.NAME)) parser.add_argument("packages", nargs='+', metavar="<package>", help=_("package name")) group = parser.add_mutually_exclusive_group() group.add_argument("--ask", "-a", action="store_true", default=self._ask, help=_('ask before making any changes')) group.add_argument("--pretend", "-p", action="store_true", default=self._pretend, help=_('only show what would be done')) return parser
return 1 run_queue, removal_queue = self._generate_install_queue( entropy_client, packages, deps, False, deep, relaxed, onlydeps, bdeps, recursive) if (run_queue is None) or (removal_queue is None): return 1 elif not (run_queue or removal_queue): entropy_client.output("%s." % (blue(_("Nothing to do")), ), level="warning", header=darkgreen(" @@ ")) return 0 if pretend: entropy_client.output("%s." % (blue(_("All done")), )) return 0 down_data = {} exit_st = self._download_packages(entropy_client, run_queue, down_data, multifetch) if exit_st == 0: self._signal_ugc(entropy_client, down_data) return exit_st SoloCommandDescriptor.register( SoloCommandDescriptor(SoloDownload, SoloDownload.NAME, _("download packages, essentially")))
matches_found, brown(ngettext("entry", "entries", matches_found)), ))) print_table(entropy_client, toc) if not matches_found: return 1 return 0 def _search(self, entropy_client, inst_repo, string): """ Solo Search string command. """ results = self._search_string(entropy_client, inst_repo, string) for pkg_id, pkg_repo in results: repo = entropy_client.open_repository(pkg_repo) print_package_info(pkg_id, entropy_client, repo, extended=self._verbose, installed_search=repo is inst_repo, quiet=self._quiet) return results SoloCommandDescriptor.register( SoloCommandDescriptor(SoloSearch, SoloSearch.NAME, _("search packages in repositories")))
def _get_parser(self): """ Overridden from SoloCommand. """ _commands = {} descriptor = SoloCommandDescriptor.obtain_descriptor( SoloDownload.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloDownload.NAME)) parser.set_defaults(func=self._download) parser.add_argument( "packages", nargs='+', metavar="<package>", help=_("package name")) mg_group = parser.add_mutually_exclusive_group() mg_group.add_argument( "--ask", "-a", action="store_true", default=False, help=_("ask before making any changes")) _commands["--ask"] = {} _commands["-a"] = {} mg_group.add_argument( "--pretend", "-p", action="store_true", default=False, help=_("show what would be done")) _commands["--pretend"] = {} _commands["-p"] = {} parser.add_argument( "--verbose", "-v", action="store_true", default=False, help=_("verbose output")) _commands["--verbose"] = {} _commands["-v"] = {} parser.add_argument( "--quiet", action="store_true", default=False, help=_("quiet output")) _commands["--quiet"] = {} parser.add_argument( "--nodeps", action="store_true", default=False, help=_("exclude package dependencies")) _commands["--nodeps"] = {} parser.add_argument( "--onlydeps", "-o", action="store_true", default=False, help=_("only include dependencies of selected packages")) _commands["--onlydeps"] = {} _commands["-o"] = {} parser.add_argument( "--norecursive", action="store_true", default=False, help=_("do not calculate dependencies recursively")) _commands["--norecursive"] = {} parser.add_argument( "--deep", action="store_true", default=False, help=_("include dependencies no longer needed")) _commands["--deep"] = {} parser.add_argument( "--relaxed", action="store_true", default=False, help=_("calculate dependencies relaxing constraints")) _commands["--relaxed"] = {} parser.add_argument( "--bdeps", action="store_true", default=False, help=_("include build-time dependencies")) _commands["--bdeps"] = {} parser.add_argument( "--multifetch", type=int, default=1, choices=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], help=_("download multiple packages in parallel (max 10)")) _commands["--multifetch"] = {} self._commands = _commands return parser
back=True) file_name = os.path.basename(_file) package_path = os.path.join( savedir, file_name + ".db") ext_rc = entropy.tools.dump_entropy_metadata( _file, package_path) if not ext_rc: entropy_client.output( "%s: %s" % ( teal(_("error during metadata extraction")), purple(_file)), header=darkred(" @@ "), level="error", importance=1) return 1 entropy_client.output( "%s: %s" % ( teal(_("metadata file generated")), purple(package_path)), header=darkred(" @@ ")) return 0 SoloCommandDescriptor.register( SoloCommandDescriptor( SoloPkg, SoloPkg.NAME, _("execute advanced tasks on packages")) )
return 1, False removal_queue += [x for x in package_ids if x not in removal_queue] self._show_removal_info(entropy_client, removal_queue) self._prompt_final_removal( entropy_client, inst_repo, removal_queue) if pretend: return 0, False if ask: question = " %s" % ( _("Would you like to proceed ?"),) rc = entropy_client.ask_question(question) if rc == _("No"): return 1, False exit_st = self._execute_action( entropy_client, inst_repo, removal_queue, remove_config_files) return exit_st, True SoloCommandDescriptor.register( SoloCommandDescriptor( SoloRemove, SoloRemove.NAME, _("remove packages from system")) )
cacher = EntropyCacher() try: cacher.save(SoloYell._CACHE_KEY, 0) except IOError: pass def _show_yell(self, *args): yell_id = SoloYell.read() max_id = max(list(SoloYell._MESSAGES.keys())) yell_message = SoloYell._MESSAGES.get( yell_id, max_id) # do not use entropy_client here # it is slow and might interfere with # other Client inits. text = TextInterface() text.output( yell_message, importance=1, level="warning") new_yell_id = yell_id + 1 if new_yell_id <= max_id: SoloYell.write(new_yell_id) return 1 SoloCommandDescriptor.register( SoloCommandDescriptor( SoloYell, SoloYell.NAME, _("yell at user")) )
def _get_message(self): """ Reimplemented from SoloFunny. """ t = """ _________________________ < Hail to the king, baby! > ------------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\\ ||----w | || || """ return t SoloCommandDescriptor.register( SoloCommandDescriptor( SoloMoo, SoloMoo.NAME, _("moo at user")) ) SoloCommandDescriptor.register( SoloCommandDescriptor( SoloLxnay, SoloLxnay.NAME, _("bow to lxnay")) )
outcome += ["--verbose", "-v", "--quiet", "-q"] return self._bashcomp(sys.stdout, last_arg, outcome) @sharedlock # clear_cache uses inst_repo def _clean(self, entropy_client, _inst_repo): """ Solo Cache Clean command. """ entropy_client.output( blue(_("Cleaning Entropy cache, please wait ...")), level = "info", header = brown(" @@ "), back = True ) entropy_client.clear_cache() entropy_client.output( darkgreen(_("Entropy cache cleaned.")), level = "info", header = brown(" @@ ") ) return 0 SoloCommandDescriptor.register( SoloCommandDescriptor( SoloCache, SoloCache.NAME, _("manage Entropy Library Cache")) )
for package in packages: if package not in package_ids: # Package was not found. continue for pkg_id in package_ids[package]: pkg_atom = inst_repo.retrieveAtom(pkg_id) current_source = inst_repo.getInstalledPackageSource(pkg_id) current_source_txt = reverse_install_sources.get( current_source, other_source) if current_source == source: txt = "%s: %s" % (brown(pkg_atom), _("no change")) entropy_client.output(txt, header=blue(" @@ ")) else: txt = "%s: %s => %s" % (brown(pkg_atom), current_source_txt, source_txt) entropy_client.output(txt, header=red(" !! ")) if not pretend: inst_repo.setInstalledPackageSource(pkg_id, source) return 0 SoloCommandDescriptor.register( SoloCommandDescriptor(SoloMark, SoloMark.NAME, _("set properties on installed packages")))
time.sleep(10) # avoid saving deps as installed by user matched_for_installation = self._match_packages_for_installation( entropy_client, False, sorted(found_deps)) if not matched_for_installation: return 1 exit_st, _show_cfgupd = self._install_action( entropy_client, True, True, self._pretend, self._ask, False, self._quiet, False, False, False, False, False, False, False, 1, [], package_matches=matched_for_installation) return exit_st SoloCommandDescriptor.register( SoloCommandDescriptor(SoloDeptest, SoloDeptest.NAME, _("look for unsatisfied dependencies")))
def _get_parser(self): """ Overridden from SoloCommand. """ _commands = {} descriptor = SoloCommandDescriptor.obtain_descriptor(SoloDownload.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloDownload.NAME)) parser.set_defaults(func=self._download) parser.add_argument("packages", nargs='+', metavar="<package>", help=_("package name")) mg_group = parser.add_mutually_exclusive_group() mg_group.add_argument("--ask", "-a", action="store_true", default=False, help=_("ask before making any changes")) _commands["--ask"] = {} _commands["-a"] = {} mg_group.add_argument("--pretend", "-p", action="store_true", default=False, help=_("show what would be done")) _commands["--pretend"] = {} _commands["-p"] = {} parser.add_argument("--verbose", "-v", action="store_true", default=False, help=_("verbose output")) _commands["--verbose"] = {} _commands["-v"] = {} parser.add_argument("--quiet", action="store_true", default=False, help=_("quiet output")) _commands["--quiet"] = {} parser.add_argument("--nodeps", action="store_true", default=False, help=_("exclude package dependencies")) _commands["--nodeps"] = {} parser.add_argument( "--onlydeps", "-o", action="store_true", default=False, help=_("only include dependencies of selected packages")) _commands["--onlydeps"] = {} _commands["-o"] = {} parser.add_argument( "--norecursive", action="store_true", default=False, help=_("do not calculate dependencies recursively")) _commands["--norecursive"] = {} parser.add_argument("--deep", action="store_true", default=False, help=_("include dependencies no longer needed")) _commands["--deep"] = {} parser.add_argument( "--relaxed", action="store_true", default=False, help=_("calculate dependencies relaxing constraints")) _commands["--relaxed"] = {} parser.add_argument("--bdeps", action="store_true", default=False, help=_("include build-time dependencies")) _commands["--bdeps"] = {} parser.add_argument( "--multifetch", type=int, default=1, choices=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], help=_("download multiple packages in parallel (max 10)")) _commands["--multifetch"] = {} self._commands = _commands return parser
def _get_parser(self): """ Overridden from SoloCommand. """ _commands = {} descriptor = SoloCommandDescriptor.obtain_descriptor( SoloRemove.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloRemove.NAME)) parser.set_defaults(func=self._remove) parser.add_argument( "packages", nargs='+', metavar="<package>", help=_("package name")) mg_group = parser.add_mutually_exclusive_group() mg_group.add_argument( "--ask", "-a", action="store_true", default=False, help=_("ask before making any changes")) _commands["--ask"] = {} _commands["-a"] = {} mg_group.add_argument( "--pretend", "-p", action="store_true", default=False, help=_("show what would be done")) _commands["--pretend"] = {} _commands["-p"] = {} parser.add_argument( "--verbose", "-v", action="store_true", default=False, help=_("verbose output")) _commands["--verbose"] = {} _commands["-v"] = {} parser.add_argument( "--nodeps", action="store_true", default=False, help=_("exclude package dependencies")) _commands["--nodeps"] = {} parser.add_argument( "--norecursive", action="store_true", default=False, help=_("do not calculate dependencies recursively")) _commands["--norecursive"] = {} parser.add_argument( "--deep", action="store_true", default=False, help=_("include dependencies no longer needed")) _commands["--deep"] = {} parser.add_argument( "--empty", action="store_true", default=False, help=_("when used with --deep, include virtual packages")) _commands["--empty"] = {} parser.add_argument( "--configfiles", action="store_true", default=False, help=_("remove package configuration files no longer needed")) _commands["--configfiles"] = {} parser.add_argument( "--force-system", action="store_true", default=False, help=_("force system packages removal (dangerous!)")) _commands["--force-system"] = {} self._commands = _commands return parser
darkred(_("10 seconds")), blue("..."), ) entropy_client.output(mytxt, header=darkred(" @@ ")) time.sleep(10) exit_st, _show_cfgupd = self._install_action( entropy_client, True, True, pretend, ask, False, quiet, False, False, False, False, False, False, False, 1, [], package_matches=package_matches) return exit_st SoloCommandDescriptor.register( SoloCommandDescriptor(SoloLibtest, SoloLibtest.NAME, _("look for missing libraries")))
def _show_notice_board_summary(self, entropy_client, repository): """ Show NoticeBoard information to user after repository update. """ mytxt = "%s %s: %s" % ( darkgreen(" @@ "), brown(_("Notice board")), bold(repository), ) entropy_client.output(mytxt) mydict = self._check_notice_board_availability(entropy_client, repository) if not mydict: return for key in sorted(mydict.keys()): mydata = mydict.get(key) mytxt = " [%s] [%s] %s: %s" % ( blue(str(key)), brown(mydata['pubDate']), _("Title"), darkred(mydata['title']), ) entropy_client.output(mytxt) SoloCommandDescriptor.register( SoloCommandDescriptor(SoloUpdate, SoloUpdate.NAME, _("update repositories")))
Parse command. """ parser = self._get_parser() try: nsargs = parser.parse_args(self._args) except IOError as err: sys.stderr.write("%s\n" % (err, )) return parser.print_help, [] return self._call_exclusive, [self._cleanup] def _cleanup(self, entropy_client): """ Solo Cleanup command. """ dirs = [etpConst['logdir'], etpConst['entropyunpackdir']] for rel in etpConst['packagesrelativepaths']: # backward compatibility, packages are moved to packages/ dir, # including nonfree, restricted etc. dirs.append(os.path.join(etpConst['entropyworkdir'], rel)) # new location dirs.append(os.path.join(etpConst['entropypackagesworkdir'], rel)) cleanup(entropy_client, dirs) return 0 SoloCommandDescriptor.register( SoloCommandDescriptor( SoloCleanup, SoloCleanup.NAME, _("remove downloaded packages and clean temp. directories")))
def _get_parser(self): """ Overridden from SoloCommand. """ _commands = {} descriptor = SoloCommandDescriptor.obtain_descriptor( SoloPkg.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloPkg.NAME)) subparsers = parser.add_subparsers( title="action", description=_("execute advanced tasks on packages"), help=_("available commands")) def _argparse_easygoing_valid_entropy_path(string): if os.path.isfile(string) and os.path.exists(string): return string # see bug 3873, requires raw string msg = "%s: %s" % ( _("not a valid Entropy package file"), string) msg = const_convert_to_rawstring( msg, from_enctype="utf-8") raise argparse.ArgumentTypeError(msg) quickpkg_parser = subparsers.add_parser( "quickpkg", help=_("generate packages from " "the installed system")) quickpkg_parser.add_argument( "packages", nargs='+', metavar="<package>", help=_("installed package name")) quickpkg_parser.add_argument( "--savedir", metavar="<path>", type=self._argparse_is_valid_directory, default=self._savedir, help=_("destination directory " "where to save generated packages")) quickpkg_parser.set_defaults(func=self._quickpkg) _commands["quickpkg"] = {} inflate_parser = subparsers.add_parser( "inflate", help=_("transform SPM package files " "into Entropy ones")) inflate_parser.add_argument( "files", nargs='+', metavar="<file>", type=_argparse_easygoing_valid_entropy_path, help=_("SPM package file path")) inflate_parser.add_argument( "--savedir", metavar="<path>", type=self._argparse_is_valid_directory, default=self._savedir, help=_("destination directory " "where to save generated packages")) inflate_parser.set_defaults(func=self._inflate) _commands["inflate"] = {} deflate_parser = subparsers.add_parser( "deflate", help=_("transform Entropy package files " "into SPM ones")) deflate_parser.add_argument( "files", nargs='+', metavar="<file>", type=self._argparse_is_valid_entropy_package, help=_("Entropy package file path")) deflate_parser.add_argument( "--savedir", metavar="<path>", type=self._argparse_is_valid_directory, default=self._savedir, help=_("destination directory " "where to save generated packages")) deflate_parser.set_defaults(func=self._deflate) _commands["deflate"] = {} extract_parser = subparsers.add_parser( "extract", help=_("extract Entropy metadata " "from Entropy packages")) extract_parser.add_argument( "files", nargs='+', metavar="<file>", type=_argparse_easygoing_valid_entropy_path, help=_("Entropy package file path")) extract_parser.add_argument( "--savedir", metavar="<path>", type=self._argparse_is_valid_directory, default=self._savedir, help=_("destination directory " "where to save generated packages")) extract_parser.set_defaults(func=self._extract) _commands["extract"] = {} self._commands = _commands return parser
pkg = action_factory.get( action_factory.CONFIG_ACTION, (package_id, inst_repo.repository_id())) xterm_header = "equo (%s) :: %d of %d ::" % ( _("configure"), count, len(package_ids)) pkg.set_xterm_header(xterm_header) entropy_client.output( darkgreen(atom), count=(count, len(package_ids)), header=darkred(" ::: ") + ">>> ") exit_st = pkg.start() if exit_st not in (0, 3): return 1, True finally: if pkg is not None: pkg.finalize() return 0, True SoloCommandDescriptor.register( SoloCommandDescriptor( SoloConfig, SoloConfig.NAME, _("configure installed packages")) )
def _get_parser(self): """ Overridden from SoloCommand. """ _commands = [] descriptor = SoloCommandDescriptor.obtain_descriptor( SoloRepo.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloRepo.NAME)) subparsers = parser.add_subparsers( title="action", description=_("manage repositories"), help=_("available commands")) enable_parser = subparsers.add_parser("enable", help=_("enable repositories")) enable_parser.add_argument("repo", nargs='+', metavar="<repo>", help=_("repository name")) enable_parser.set_defaults(func=self._enable) _commands.append("enable") disable_parser = subparsers.add_parser("disable", help=_("disable repositories")) disable_parser.add_argument("repo", nargs='+', metavar="<repo>", help=_("repository name")) disable_parser.set_defaults(func=self._disable) _commands.append("disable") add_parser = subparsers.add_parser("add", help=_("add a repository")) add_parser.add_argument("id", metavar="<repository>", help=_("repository name")) add_parser.add_argument("--desc", metavar="<description>", required=True, help=_("repository description")) add_parser.add_argument("--repo", nargs='+', metavar="<repo url>", required=True, help=_("repository database URL")) add_parser.add_argument("--pkg", nargs='+', metavar="<pkg url>", required=True, help=_("repository packages URL")) add_parser.add_argument("--cformat", default=etpConst['etpdatabasefileformat'], metavar="<compression format>", help=_("repository compression format")) add_parser.set_defaults(func=self._add) _commands.append("add") remove_parser = subparsers.add_parser("remove", help=_("remove a repository")) remove_parser.add_argument("repo", nargs='+', metavar="<repo>", help=_("repository name")) remove_parser.set_defaults(func=self._remove) _commands.append("remove") rename_parser = subparsers.add_parser("rename", help=_("rename a repository")) rename_parser.add_argument("from_repo", metavar="<from>", help=_("from repository")) rename_parser.add_argument("to_repo", metavar="<to>", help=_("to repository")) rename_parser.set_defaults(func=self._rename) _commands.append("rename") list_parser = subparsers.add_parser("list", help=_("list active repositories")) list_parser.set_defaults(func=self._list) list_parser.add_argument( "--quiet", "-q", action="store_true", default=False, help=_('quiet output, for scripting purposes')) _commands.append("list") mirrorsort_parser = subparsers.add_parser("mirrorsort", help=_("reorder mirrors basing on response time")) mirrorsort_parser.add_argument("repo", nargs='+', metavar="<repo>", help=_("repository name")) mirrorsort_parser.add_argument( "--simulate", action="store_true", default=False, help=_("simulate execution")) mirrorsort_parser.set_defaults(func=self._mirrorsort) _commands.append("mirrorsort") merge_parser = subparsers.add_parser("merge", help=_("merge content of source repository to destination")) merge_parser.add_argument("source", metavar="<source>", help=_("source repository")) merge_parser.add_argument("dest", metavar="<destination>", help=_("destination repository")) merge_parser.add_argument( "--conflicts", action="store_true", default=False, help=_("also remove dependency conflicts during merge")) merge_parser.set_defaults(func=self._merge) _commands.append("merge") self._commands = _commands return parser
onlydeps, bdeps, recursive) if (run_queue is None) or (removal_queue is None): return 1 elif not (run_queue or removal_queue): entropy_client.output( "%s." % (blue(_("Nothing to do")),), level="warning", header=darkgreen(" @@ ")) return 0 if pretend: entropy_client.output( "%s." % (blue(_("All done")),)) return 0 down_data = {} exit_st = self._download_packages( entropy_client, run_queue, down_data, multifetch) if exit_st == 0: self._signal_ugc(entropy_client, down_data) return exit_st SoloCommandDescriptor.register( SoloCommandDescriptor( SoloDownload, SoloDownload.NAME, _("download packages, essentially")) )
def _get_parser(self): """ Overridden from SoloCommand. """ _commands = {} descriptor = SoloCommandDescriptor.obtain_descriptor(SoloRescue.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloRescue.NAME)) subparsers = parser.add_subparsers( title="action", description=_("execute advanced tasks on packages"), help=_("available commands")) def _add_ask_to_parser(p, _cmd_dict): p.add_argument("--ask", "-a", action="store_true", default=False, help=_("ask before making any changes")) _cmd_dict["--ask"] = {} _cmd_dict["-a"] = {} def _add_pretend_to_parser(p, _cmd_dict): p.add_argument("--pretend", "-p", action="store_true", default=False, help=_("show what would be done")) _cmd_dict["--pretend"] = {} _cmd_dict["-p"] = {} check_parser = subparsers.add_parser("check", help=_("check installed packages " "repository for errors")) check_parser.set_defaults(func=self._check) _commands["check"] = {} vacuum_parser = subparsers.add_parser( "vacuum", help=_("compact the installed packages repository")) vacuum_parser.set_defaults(func=self._vacuum) _commands["vacuum"] = {} generate_parser = subparsers.add_parser( "generate", help=_("re-generate the installed packages repository" " using the Source Package Manager")) generate_parser.set_defaults(func=self._generate) generate_parser.add_argument( "--force-non-interactive", action="store_true", default=False, help=("Do not ask for confirmation (caution: resets" " packages database).")) _commands["generate"] = {} spmuids_parser = subparsers.add_parser( "spmuids", help=_("re-generate SPM<->Entropy package UIDs mapping")) spmuids_parser.set_defaults(func=self._spmuids) _commands["spmuids"] = {} spmsync_parser = subparsers.add_parser( "spmsync", help=_("update Entropy installed packages repository " "merging Source Package Manager changes")) _cmd_dict = {} _commands["spmsync"] = _cmd_dict mg_group = spmsync_parser.add_mutually_exclusive_group() _add_ask_to_parser(mg_group, _cmd_dict) _add_pretend_to_parser(mg_group, _cmd_dict) spmsync_parser.set_defaults(func=self._spmsync) backup_parser = subparsers.add_parser( "backup", help=_("create a backup of the installed packages repository")) backup_parser.set_defaults(func=self._backup) _commands["backup"] = {} restore_parser = subparsers.add_parser( "restore", help=_("restore a backup of the installed " "packages repository")) restore_parser.set_defaults(func=self._restore) _commands["restore"] = {} self._commands = _commands return parser
paths_map, scandata) if _continue: continue break elif action == 4: comeback, _continue = self._interactive_merge( idx, entropy_client, root, source, dest, paths_map, scandata) if _continue: continue break elif action == 5: # show diff again diff = self._showdiff( entropy_client, dest_path, source_path) continue if comeback: return True return False SoloCommandDescriptor.register( SoloCommandDescriptor( SoloConf, SoloConf.NAME, _("manage package file updates")) )
pkg = action_factory.get( action_factory.SOURCE_ACTION, match, opts=metaopts) xterm_header = "equo (%s) :: %d of %d ::" % ( _("sources download"), count, total) pkg.set_xterm_header(xterm_header) entropy_client.output( darkgreen(atom), count=(count, total), header=darkred(" ::: ") + ">>> ") exit_st = pkg.start() if exit_st != 0: return 1 finally: if pkg is not None: pkg.finalize() return 0 SoloCommandDescriptor.register( SoloCommandDescriptor( SoloSource, SoloSource.NAME, _("download packages source code")) )
# filtered out in solo.main. Will never get here parser.add_argument( "--color", action="store_true", default=None, help=_("force colored output")) descriptors = SoloCommandDescriptor.obtain() descriptors.sort(key = lambda x: x.get_name()) group = parser.add_argument_group("command", "available commands") for descriptor in descriptors: if descriptor.get_class().HIDDEN: continue aliases = descriptor.get_class().ALIASES aliases_str = ", ".join([teal(x) for x in aliases]) if aliases_str: aliases_str = " [%s]" % (aliases_str,) name = "%s%s" % (purple(descriptor.get_name()), aliases_str) desc = descriptor.get_description() group.add_argument(name, help=darkgreen(desc), action="store_true") parser.print_help() if not self._args: return 1 return 0 SoloCommandDescriptor.register( SoloCommandDescriptor( SoloHelp, SoloHelp.NAME, _("this help")) )
self._get_dep_ids(inst_repo)) not_needed = all_ids - wanted_ids def _sort_key(x): sort_index = 1 if self._sortbysize else 0 return x[sort_index] not_needed_pkgs_data = sorted( [(inst_repo.retrieveAtom(x), inst_repo.retrieveOnDiskSize(x)) for x in not_needed], key=_sort_key) if self._quiet: entropy_client.output( '\n'.join([x[0] for x in not_needed_pkgs_data]), level="generic") else: for atom, disk_size in not_needed_pkgs_data: disk_size = entropy.tools.bytes_into_human(disk_size) entropy_client.output( "# %s%s%s %s" % ( blue("["), brown(disk_size), blue("]"), darkgreen(atom),)) SoloCommandDescriptor.register( SoloCommandDescriptor( SoloUnused, SoloUnused.NAME, _("show unused packages (pay attention)")) )
spm_wanted_map = {} for pkg in self._wanted_packages: stripped = entropy.dep.dep_getkey(pkg) obj = spm_wanted_map.setdefault(stripped, set()) obj.add(pkg) return spm_wanted_map def is_user_selected(self, pkg): """ Determines whether a package is selected by user in SPM "world" file. """ spm_package_key = entropy.dep.dep_getkey(pkg) spm_wanted_candidates = self._map.get(spm_package_key, set()) # Avoid calling spm.match_installed_package() which can be # a little slow. Now the list is reduced. spm_wanted_matches = (self._spm_match_installed(x) for x in spm_wanted_candidates if x is not None) return pkg in spm_wanted_matches def _spm_match_installed(self, pkg): try: return self._spm.match_installed_package(pkg) except KeyError: return None SoloCommandDescriptor.register( SoloCommandDescriptor(SoloRescue, SoloRescue.NAME, _("tools to rescue the running system")))
continue conflict_cache.add(conflict) matches, rc = dest_db.atomMatch(conflict, multiMatch = True) target_pkg_ids |= matches for target_pkg_id in target_pkg_ids: dest_db.removePackage(target_pkg_id) dest_pkg_id = dest_db.addPackage(pkg_meta, formatted_content = True) dest_db.commit() entropy_client.output( "[%s] %s" % ( teal(source), blue(_("done merging packages")),)) dest_db.commit() dest_db.close() # close all repos again entropy_client.close_repositories() return 0 SoloCommandDescriptor.register( SoloCommandDescriptor( SoloRepo, SoloRepo.NAME, _("manage repositories")) )
def _get_parser(self): """ Overridden from SoloCommand. """ _commands = {} descriptor = SoloCommandDescriptor.obtain_descriptor(SoloMark.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], SoloMark.NAME)) subparsers = parser.add_subparsers( title="action", description=_("specify property to mark on a package"), help=_("available commands")) def _add_standard_arguments(p, _cmd_dict): p.add_argument("packages", nargs='+', metavar="<package>", help=_("package name")) p.add_argument("--pretend", "-p", action="store_true", default=False, help=_("show what would be done")) _cmd_dict["--pretend"] = {} _cmd_dict["-p"] = {} p.add_argument( "--ignore-missing", action="store_true", default=False, help=_("ignore packages that are not installed on system")) _cmd_dict["--ignore-missing"] = {} # It behaves differently than --multimatch from match.py, # thus a different name. p.add_argument( "--multiple-versions", action="store_true", default=False, help=_("allow matching multiple versions of a package")) _cmd_dict["--multiple-versions"] = {} auto_parser = subparsers.add_parser( "auto", help=_("mark package as installed to satisfy a dependency")) _cmd_dict = {} _add_standard_arguments(auto_parser, _cmd_dict) auto_parser.set_defaults(func=self._auto) _commands["auto"] = _cmd_dict manual_parser = subparsers.add_parser( "manual", help=_("mark package as installed by user")) _cmd_dict = {} _add_standard_arguments(manual_parser, _cmd_dict) manual_parser.set_defaults(func=self._manual) _commands["manual"] = _cmd_dict self._commands = _commands return parser
mytxt = "[%s] [%s] %s: %s" % ( blue(str(key)), brown(mydict['pubDate']), _("Title"), darkred(mydict['title']), ) entropy_client.output(mytxt) mytxt = "%s:\n\n%s\n" % ( darkgreen(_("Content")), mydict['description'], ) entropy_client.output(mytxt) mytxt = "%s: %s" % ( darkgreen(_("Link")), blue(mydict['link']), ) entropy_client.output(mytxt) def fake_callback(s): return True input_params = [('idx', _("Press Enter to continue"), fake_callback, False)] entropy_client.input_box('', input_params, cancel_button=True) SoloCommandDescriptor.register( SoloCommandDescriptor(SoloNotice, SoloNotice.NAME, _("repository notice board reader")))