def _get_parser(self): """ Overridden from EitCp """ descriptor = EitCommandDescriptor.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("source", metavar="<source>", help=_("source repository")) parser.add_argument("dest", metavar="<dest>", help=_("destination repository")) parser.add_argument("--conservative", action="store_true", help=_("do not execute implicit package name " "and slot updates"), default=self._conservative) parser.add_argument("--deps", action="store_true", default=False, help=_("include dependencies")) parser.add_argument("--quick", action="store_true", default=not self._ask, help=_("no stupid questions")) parser.add_argument("packages", nargs='*', metavar="<package>", help=_("package dependency")) return parser
def _get_parser(self): """ Overridden from EitCommand """ descriptor = EitCommandDescriptor.obtain_descriptor( EitBranch.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitBranch.NAME)) parser.add_argument("--quick", action="store_true", default=not self._ask, help=_("no stupid questions")) parser.add_argument("branch", nargs='?', metavar="<branch>", help=_("switch to given branch")) parser.add_argument("repo", nargs='?', metavar="<repo>", help=_("repository")) parser.add_argument("--from", metavar="<branch>", help=_("from branch"), dest="frombranch", default=None) parser.add_argument("--no-copy", action="store_true", default=not self._copy, dest="nocopy", help=_("don't copy packages from branch")) return parser
def _get_parser(self): self._real_command = sys.argv[0] descriptor = EitCommandDescriptor.obtain_descriptor( EitPush.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitPush.NAME)) parser.add_argument("repo", nargs='?', default=None, metavar="<repo>", help=_("repository")) parser.add_argument("--conservative", action="store_true", help=_("do not execute implicit package name " "and slot updates"), default=self._conservative) parser.add_argument("--quick", action="store_true", default=False, help=_("no stupid questions")) parser.add_argument("--force", action="store_true", default=False, help=_("force push in case of QA errors")) group = parser.add_mutually_exclusive_group() group.add_argument("--all", action="store_true", default=False, help=_("push all the repositories")) group.add_argument("--as", metavar="<repo>", default=None, help=_("push as fake repository"), dest="asrepo") parser.add_argument("--pretend", action="store_true", default=False, help=_("show what would be done")) return parser
def _get_parser(self): """ Overridden from EitCommand """ descriptor = EitCommandDescriptor.obtain_descriptor( EitRemote.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitRemote.NAME)) subparsers = parser.add_subparsers( title="action", description=_("execute action"), help=_("available actions")) list_parser = subparsers.add_parser("list", help=_("list repositories")) list_parser.set_defaults(func=self._list) add_parser = subparsers.add_parser("add", help=_("add repository")) add_parser.add_argument("repository", metavar="<repository>", help=_("repository id")) add_parser.add_argument("--desc", metavar="<description>", default=None, help=_("repository description")) add_parser.add_argument("uri", metavar="<uri>", nargs="+", help=_("repository uri")) add_parser.set_defaults(func=self._add) return parser
def bashcomp(self, last_arg): """ Overridden from EitCommand """ import sys descriptors = EitCommandDescriptor.obtain() descriptors.sort(key = lambda x: x.get_name()) outcome = [] for descriptor in descriptors: name = descriptor.get_name() if name == EitHelp.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 EitCommand """ descriptor = EitCommandDescriptor.obtain_descriptor( EitNotice.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitNotice.NAME)) subparsers = parser.add_subparsers( title="action", description=_("execute given action"), help=_("available actions")) add_parser = subparsers.add_parser("add", help=_("add notice-board entry")) add_parser.add_argument("repo", nargs='?', default=None, metavar="<repo>", help=_("repository")) add_parser.set_defaults(func=self._add) remove_parser = subparsers.add_parser("remove", help=_("remove notice-board entry")) remove_parser.add_argument("repo", nargs='?', default=None, metavar="<repo>", help=_("repository")) remove_parser.set_defaults(func=self._remove) show_parser = subparsers.add_parser("show", help=_("show notice-board")) show_parser.add_argument("repo", nargs='?', default=None, metavar="<repo>", help=_("repository")) show_parser.set_defaults(func=self._show) return parser
def _get_parser(self): """ Overridden from EitCommand """ descriptor = EitCommandDescriptor.obtain_descriptor( EitTest.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitTest.NAME)) subparsers = parser.add_subparsers( title="test", description=_("run given test"), help=_("available tests")) deps_parser = subparsers.add_parser("deps", help=_("dependencies test")) deps_parser.set_defaults(func=self._deptest) libs_parser = subparsers.add_parser("libs", help=_("libraries test")) libs_parser.add_argument("--dump", action="store_true", default=False, help=_("dump results to file")) libs_parser.set_defaults(func=self._libtest) links_parser = subparsers.add_parser("links", help=_("library linking test (using repository metadata)")) links_parser.add_argument("excllibs", nargs='*', default=None, metavar="<excluded lib>", help=_("excluded soname")) links_parser.set_defaults(func=self._linktest) pkglibs_parser = subparsers.add_parser("pkglibs", help=_("library linking test (using live system)")) pkglibs_parser.add_argument("packages", nargs='+', default=None, metavar="<package>", help=_("package names")) pkglibs_parser.set_defaults(func=self._pkglibs) pkgs_parser = subparsers.add_parser("local", help=_("verify local packages integrity")) pkgs_parser.add_argument("repo", nargs='?', default=None, metavar="<repo>", help=_("repository")) pkgs_parser.add_argument("--quick", action="store_true", default=not self._ask, help=_("no stupid questions")) pkgs_parser.set_defaults(func=self._pkgtest) rempkgs_parser = subparsers.add_parser("remote", help=_("verify remote packages integrity")) rempkgs_parser.add_argument("repo", nargs='?', default=None, metavar="<repo>", help=_("repository")) rempkgs_parser.add_argument("--quick", action="store_true", default=not self._ask, help=_("no stupid questions")) rempkgs_parser.set_defaults(func=self._rem_pkgtest) return parser
def _get_parser(self): """ Overridden from EitCommand """ descriptor = EitCommandDescriptor.obtain_descriptor( EitCheckout.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitCheckout.NAME)) parser.add_argument("repo", metavar="<repo>", help=_("repository")) return parser
def _get_parser(self): """ Overridden from EitCommand """ descriptor = EitCommandDescriptor.obtain_descriptor( EitRepo.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitRepo.NAME)) subparsers = parser.add_subparsers( title="action", description=_("manage repositories"), help=_("available commands")) show_parser = subparsers.add_parser( "show", help=_("show repositories and mirrors status")) show_parser.set_defaults(func=self._show) 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 uri>", required=True, help=_("synchronization URI for both packages and database")) add_parser.add_argument( "--repo-only", nargs='*', default=[], metavar="<database only uri>", help=_("synchronization URI for database only")) add_parser.add_argument( "--pkg-only", nargs='*', default=[], metavar="<packages only uri>", help=_("synchronization URI for packages only")) add_parser.add_argument( "--base", action="store_true", default=None, help=_("set this to make this repository the " "'base' for all the others")) add_parser.set_defaults(func=self._add) remove_parser = subparsers.add_parser("remove", help=_("remove a repository")) remove_parser.add_argument( "id", nargs='+', metavar="<repository>", help=_("repository name")) remove_parser.set_defaults(func=self._remove) return parser
def _get_parser(self): """ Overridden from EitCommit """ descriptor = EitCommandDescriptor.obtain_descriptor( EitRepack.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitRepack.NAME)) parser.add_argument("packages", nargs='+', metavar="<package>", help=_("package names")) parser.add_argument("--in", metavar="<repository>", help=_("repack to given repository"), default=None, dest="into") return parser
def _get_parser(self): descriptor = EitCommandDescriptor.obtain_descriptor( EitDeps.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitDeps.NAME)) parser.add_argument("packages", nargs='+', metavar="<package>", help=_("package name")) parser.add_argument("--in", metavar="<repository>", help=_("inject into given repository"), dest="inrepo", default=None) return parser
def _get_parser(self): descriptor = EitCommandDescriptor.obtain_descriptor( EitFiles.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitFiles.NAME)) parser.add_argument("packages", nargs='+', metavar="<package>", help=_("package names")) parser.add_argument("--quiet", "-q", action="store_true", default=self._quiet, help=_('quiet output, for scripting purposes')) return parser
def _get_parser(self): """ Overridden from EitInit """ descriptor = EitCommandDescriptor.obtain_descriptor( EitInit.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitInit.NAME)) parser.add_argument("repo", nargs=1, default=None, metavar="<repo>", help=_("repository")) parser.add_argument("--quick", action="store_true", default=not self._ask, help=_("no stupid questions")) return parser
def _get_parser(self): descriptor = EitCommandDescriptor.obtain_descriptor(EitDeps.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitDeps.NAME)) parser.add_argument("packages", nargs='+', metavar="<package>", help=_("package name")) parser.add_argument("--in", metavar="<repository>", help=_("inject into given repository"), dest="inrepo", default=None) return parser
def _get_parser(self): descriptor = EitCommandDescriptor.obtain_descriptor(EitFiles.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitFiles.NAME)) parser.add_argument("packages", nargs='+', metavar="<package>", help=_("package names")) parser.add_argument("--quiet", "-q", action="store_true", default=self._quiet, help=_('quiet output, for scripting purposes')) return parser
def _get_parser(self): """ Overridden from EitCommand """ descriptor = EitCommandDescriptor.obtain_descriptor(EitBump.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitBump.NAME)) parser.add_argument("repo", nargs='?', default=None, metavar="<repo>", help=_("repository")) parser.add_argument("--sync", action="store_true", default=self._sync, help=_("sync with remote repository")) return parser
def _get_parser(self): """ Overridden from EitCommand """ descriptor = EitCommandDescriptor.obtain_descriptor( EitSearch.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitSearch.NAME)) parser.add_argument("packages", nargs='+', metavar="<package>", help=_("package name")) parser.add_argument("--in", metavar="<repository>", help=_("search packages in given repository"), dest="inrepo", default=None) parser.add_argument("--quiet", "-q", action="store_true", default=self._quiet, help=_('quiet output, for scripting purposes')) return parser
def _get_parser(self): descriptor = EitCommandDescriptor.obtain_descriptor( EitInject.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitInject.NAME)) parser.add_argument("packages", nargs='+', metavar="<path>", help=_("package paths")) parser.add_argument("--to", metavar="<repository>", help=_("inject into given repository"), default=None) parser.add_argument("--quick", action="store_true", default=not self._ask, help=_("no stupid questions")) parser.add_argument("--reset-revision", action="store_true", default=self._reset_revision, help=_("reset revision to 0 (advanced)")) return parser
def _get_parser(self): """ Overridden from EitCommand """ descriptor = EitCommandDescriptor.obtain_descriptor(EitNotice.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitNotice.NAME)) subparsers = parser.add_subparsers( title="action", description=_("execute given action"), help=_("available actions")) add_parser = subparsers.add_parser("add", help=_("add notice-board entry")) add_parser.add_argument("repo", nargs='?', default=None, metavar="<repo>", help=_("repository")) add_parser.set_defaults(func=self._add) remove_parser = subparsers.add_parser( "remove", help=_("remove notice-board entry")) remove_parser.add_argument("repo", nargs='?', default=None, metavar="<repo>", help=_("repository")) remove_parser.set_defaults(func=self._remove) show_parser = subparsers.add_parser("show", help=_("show notice-board")) show_parser.add_argument("repo", nargs='?', default=None, metavar="<repo>", help=_("repository")) show_parser.set_defaults(func=self._show) return parser
def _get_parser(self): descriptor = EitCommandDescriptor.obtain_descriptor( EitRemove.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitRemove.NAME)) parser.add_argument("packages", nargs='+', metavar="<package>", help=_("package name")) parser.add_argument("--from", metavar="<repository>", help=_("remove from given repository"), dest="fromrepo", default=None) parser.add_argument("--nodeps", action="store_true", help=_("do not include reverse dependencies"), dest="nodeps", default=self._nodeps) parser.add_argument("--quick", action="store_true", default=not self._ask, help=_("no stupid questions")) return parser
def _get_parser(self): """ Overridden from EitCommand """ descriptor = EitCommandDescriptor.obtain_descriptor( EitCleanup.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitCleanup.NAME)) parser.add_argument("repo", nargs='?', default=None, metavar="<repo>", help=_("repository")) parser.add_argument("--quick", action="store_true", default=False, help=_("no stupid questions")) parser.add_argument("--pretend", action="store_true", default=False, help=_("show what would be done")) parser.add_argument('--days', type=int, default=self._days, help=_("expired since how many days")) return parser
def _show_help(self, *args): parser = argparse.ArgumentParser( description=_("Entropy Infrastructure Toolkit"), epilog="http://www.sabayon.org", formatter_class=ColorfulFormatter) descriptors = EitCommandDescriptor.obtain() descriptors.sort(key=lambda x: x.get_name()) group = parser.add_argument_group("command", "available commands") for descriptor in descriptors: 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 EitCommit """ descriptor = EitCommandDescriptor.obtain_descriptor( EitAdd.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitAdd.NAME)) parser.add_argument("packages", nargs='+', metavar="<package>", help=_("package names")) parser.add_argument("--conservative", action="store_true", help=_("do not execute implicit package name " "and slot updates"), default=self._conservative) parser.add_argument("--to", metavar="<repository>", help=_("add to given repository"), default=None) parser.add_argument("--quick", action="store_true", default=not self._ask, help=_("no stupid questions")) return parser
def _show_help(self, *args): parser = argparse.ArgumentParser( description=_("Entropy Infrastructure Toolkit"), epilog="http://www.sabayon.org", formatter_class=ColorfulFormatter) descriptors = EitCommandDescriptor.obtain() descriptors.sort(key = lambda x: x.get_name()) group = parser.add_argument_group("command", "available commands") for descriptor in descriptors: 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 EitCommit """ descriptor = EitCommandDescriptor.obtain_descriptor(EitMerge.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitMerge.NAME)) parser.add_argument("branch", metavar="<branch>", help=_("repository branch")) parser.add_argument("--in", metavar="<repository>", help=_("work inside given repository"), default=None, dest="into") parser.add_argument("--quick", action="store_true", default=not self._ask, help=_("no stupid questions")) return parser
def _get_parser(self): descriptor = EitCommandDescriptor.obtain_descriptor( EitCommit.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitCommit.NAME)) parser.add_argument("repo", nargs='?', default=None, metavar="<repo>", help=_("repository")) parser.add_argument("--conservative", action="store_true", help=_("do not execute implicit package name " "and slot updates"), default=self._conservative) parser.add_argument("--interactive", action="store_true", default=False, help=_("selectively pick changes")) parser.add_argument("--quick", action="store_true", default=not self._ask, help=_("no stupid questions")) return parser
def _get_parser(self): """ Overridden from EitCommand """ descriptor = EitCommandDescriptor.obtain_descriptor(EitReset.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitReset.NAME)) parser.add_argument("repo", nargs='?', default=None, metavar="<repo>", help=_("repository")) parser.add_argument("--quick", action="store_true", default=False, help=_("no stupid questions")) parser.add_argument("--local", action="store_true", default=False, help=_("do not pull the remote repository")) return parser
def _get_parser(self): descriptor = EitCommandDescriptor.obtain_descriptor( EitLock.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], self._name)) parser.add_argument("repo", nargs=1, metavar="<repo>", help=_("repository")) group = parser.add_mutually_exclusive_group() group.add_argument( "--client", action="store_true", default=False, help=_('affect entropy clients only')) group.add_argument( "--status", action="store_true", default=False, help=_('show current status')) parser.add_argument("--quiet", "-q", action="store_true", default=self._quiet, help=_('quiet output, for scripting purposes')) return parser
def _get_parser(self): descriptor = EitCommandDescriptor.obtain_descriptor(EitInject.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitInject.NAME)) parser.add_argument("packages", nargs='+', metavar="<path>", help=_("package paths")) parser.add_argument("--to", metavar="<repository>", help=_("inject into given repository"), default=None) parser.add_argument("--quick", action="store_true", default=not self._ask, help=_("no stupid questions")) parser.add_argument("--reset-revision", action="store_true", default=self._reset_revision, help=_("reset revision to 0 (advanced)")) return parser
pkg_id, pkg_repo = entropy_server.atom_match(package) if pkg_id == -1: exit_st = 1 if not self._quiet: entropy_server.output( "%s: %s" % (purple(_("Not matched")), teal(package)), level="warning", importance=1) continue entropy_repository = entropy_server.open_repository(pkg_repo) files = entropy_repository.retrieveContent(pkg_id, order_by="file") atom = entropy_repository.retrieveAtom(pkg_id) if self._quiet: for path in files: entropy_server.output(path, level="generic") else: for path in files: entropy_server.output(path) entropy_server.output( "[%s] %s: %s %s" % (purple(pkg_repo), darkgreen(atom), bold(str( len(files))), teal(_("files found")))) return exit_st EitCommandDescriptor.register( EitCommandDescriptor(EitFiles, EitFiles.NAME, _('show files owned by packages')))
def man(self): """ Overridden from EitCommand. """ return self._man() def parse(self): """ Overridden from EitCommand """ parser = self._get_parser() try: nsargs = parser.parse_args(self._args) except IOError as err: return parser.print_help, [] return self._call_exclusive, [self._checkout, nsargs.repo] def _checkout(self, entropy_server): """ Actual Entropy Repository checkout function """ repository_id = entropy_server.repository() entropy_server.switch_default_repository(repository_id, save=True) # show interface info entropy_server._show_interface_status() return 0 EitCommandDescriptor.register( EitCommandDescriptor(EitCheckout, EitCheckout.NAME, _('switch from a repository to another')))
def main(): install_exception_handler() descriptors = EitCommandDescriptor.obtain() args_map = {} catch_all = None for descriptor in descriptors: klass = descriptor.get_class() if klass.CATCH_ALL: catch_all = klass args_map[klass.NAME] = klass for alias in klass.ALIASES: args_map[alias] = klass args = sys.argv[1:] # convert args to unicode, to avoid passing # raw string stuff down to entropy layers def _to_unicode(arg): try: return const_convert_to_unicode(arg, enctype=etpConst['conf_encoding']) except UnicodeDecodeError: print_error("invalid argument: %s" % (arg, )) raise SystemExit(1) args = list(map(_to_unicode, args)) is_bashcomp = False if "--bashcomp" in args: is_bashcomp = True args.remove("--bashcomp") # the first eit, because bash does: # argv -> eit --bashcomp eit add # and we need to drop --bashcomp and # argv[2] args.pop(0) cmd = None last_arg = None if args: last_arg = args[-1] cmd = args[0] args = args[1:] cmd_class = args_map.get(cmd) if cmd_class is None: cmd_class = catch_all cmd_obj = cmd_class(args) if is_bashcomp: try: cmd_obj.bashcomp(last_arg) except NotImplementedError: pass raise SystemExit(0) # non-root users not allowed allowed = True if os.getuid() != 0 and \ cmd_class is not catch_all: if not cmd_class.ALLOW_UNPRIVILEGED: cmd_class = catch_all allowed = False func, func_args = cmd_obj.parse() if allowed: exit_st = func(*func_args) raise SystemExit(exit_st) else: print_error(_("superuser access required")) raise SystemExit(1)
return self._call_shared, [self._match, None] def _match(self, entropy_server): """ Actual Eit match code. """ count = 0 for package in self._packages: pkg_id, pkg_repo = entropy_server.atom_match(package) if pkg_id == -1: continue count += 1 print_package_info(pkg_id, entropy_server, entropy_server.open_repository(pkg_repo), installed_search=True, extended=True, quiet=self._quiet) if not count and not self._quiet: entropy_server.output(purple(_("Nothing found")), importance=1, level="warning") return 0 EitCommandDescriptor.register( EitCommandDescriptor(EitMatch, EitMatch.NAME, _('match packages in repositories')))
repo_mirrors = meta['repo_mirrors'] pkg_mirrors = meta['pkg_mirrors'] entropy_server.output( "%s [%s]%s" % ( teal(repository_id), darkgreen(description), default_str, )) for repo_mirror in repo_mirrors: entropy_server.output( " %s: %s" % ( blue(_("repository")), brown(repo_mirror), )) for pkg_mirror in pkg_mirrors: entropy_server.output( " %s: %s" % ( blue(_("packages")), brown(pkg_mirror), )) return 0 EitCommandDescriptor.register( EitCommandDescriptor( EitRemote, EitRemote.NAME, _('manage repositories')) )
def _get_parser(self): """ Overridden from EitCommand """ descriptor = EitCommandDescriptor.obtain_descriptor( EitKey.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitKey.NAME)) subparsers = parser.add_subparsers( title="action", description=_("execute action"), help=_("available actions")) create_parser = subparsers.add_parser("create", help=_("create keypair for repository and packages")) create_parser.add_argument("repo", metavar="<repo>", help=_("repository")) create_parser.set_defaults(func=self._create) delete_parser = subparsers.add_parser("delete", help=_("delete keypair (and signatures) from repository")) delete_parser.add_argument("repo", metavar="<repo>", help=_("repository")) delete_parser.set_defaults(func=self._delete) status_parser = subparsers.add_parser("status", help=_("show keypair status for repository")) status_parser.add_argument("repo", metavar="<repo>", help=_("repository")) status_parser.set_defaults(func=self._status) sign_parser = subparsers.add_parser("sign", help=_("sign packages in repository using current keypair")) sign_parser.add_argument("repo", metavar="<repo>", help=_("repository")) sign_parser.set_defaults(func=self._sign) import_parser = subparsers.add_parser("import", help=_("import keypair, bind to given repository")) import_parser.add_argument("repo", metavar="<repo>", help=_("repository")) import_parser.add_argument("privkey", metavar="<private key>", type=file, help=_("private key path")) import_parser.add_argument("pubkey", metavar="<pub key path>", type=file, help=_("public key path")) import_parser.set_defaults(func=self._import) export_pub_parser = subparsers.add_parser("export-public", help=_("export the repository public key to file")) export_pub_parser.add_argument("repo", metavar="<repo>", help=_("repository")) export_pub_parser.add_argument("key", metavar="<public key>", type=argparse.FileType('w'), help=_("public key path")) export_pub_parser.set_defaults(func=self._export_pub) export_priv_parser = subparsers.add_parser("export-private", help=_("export the repository private key to file")) export_priv_parser.add_argument("repo", metavar="<repo>", help=_("repository")) export_priv_parser.add_argument("key", metavar="<private key>", type=argparse.FileType('w'), help=_("private key path")) export_priv_parser.set_defaults(func=self._export_priv) return parser
with open(store_path, "w") as dest_w: dest_w.write(key_stream) dest_w.flush() except IOError as err: entropy_server.output("%s: %s [%s]" % ( darkgreen( _("Unable to export GPG key for repository")), bold(repo), err, ), level = "error" ) return 1 entropy_server.output("%s: %s [%s]" % ( darkgreen(_("Exported GPG key for repository")), bold(repo), brown(store_path), ), level = "info" ) return 0 EitCommandDescriptor.register( EitCommandDescriptor( EitKey, EitKey.NAME, _('manage repository GPG keys')) )
for result in results: # print info xfile = result result = results[result] for pkg_id in sorted(result, key=key_sorter): if self._quiet: entropy_server.output(repo.retrieveAtom(pkg_id), level="generic") else: print_package_info(pkg_id, entropy_server, repo, installed_search=True, extended=self._verbose, quiet=self._quiet) if not self._quiet: entropy_server.output( "[%s] %s: %s %s" % (purple(repository_id), darkgreen(xfile), bold(str(len(result))), teal(_("packages found")))) return 0 EitCommandDescriptor.register( EitCommandDescriptor(EitOwn, EitOwn.NAME, _('search packages owning paths')))
prog="%s %s" % (sys.argv[0], EitRepack.NAME)) parser.add_argument("packages", nargs='+', metavar="<package>", help=_("package names")) parser.add_argument("--in", metavar="<repository>", help=_("repack to given repository"), default=None, dest="into") return parser def parse(self): """ Overridden from EitCommit """ 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, [] # setup atoms variable before spawning commit self._repackage = nsargs.packages[:] return self._call_exclusive, [self._commit, nsargs.into] EitCommandDescriptor.register( EitCommandDescriptor(EitRepack, EitRepack.NAME, _('rebuild packages in repository')))
entropy_server.output( darkgreen(_("These are the packages that would be removed") + ":"), importance=1, header=brown(" @@ ")) repo_map = {} for pkg_id, repo_id in pkg_matches: repo = entropy_server.open_repository(repo_id) pkgatom = repo.retrieveAtom(pkg_id) entropy_server.output("[%s] %s" % (teal(repo_id), purple(pkgatom)), header=brown(" # ")) obj = repo_map.setdefault(repo_id, []) obj.append(pkg_id) if self._ask: resp = entropy_server.ask_question( _("Would you like to continue ?")) if resp == _("No"): return 0 for repo_id, pkg_ids in repo_map.items(): entropy_server.remove_packages(repo_id, pkg_ids) return 0 EitCommandDescriptor.register( EitCommandDescriptor(EitRemove, EitRemove.NAME, _('remove packages from repository')))
atom = entropy_repository.retrieveAtom(pkg_id) if atom is None: continue if not self._verbose: atom = entropy.dep.dep_getkey(atom) branchinfo = "" sizeinfo = "" if self._verbose: branch = entropy_repository.retrieveBranch(pkg_id) branchinfo = darkgreen("[") + teal(branch) + darkgreen("]") mysize = entropy_repository.retrieveOnDiskSize(pkg_id) mysize = entropy.tools.bytes_into_human(mysize) sizeinfo = brown("[") + purple(mysize) + brown("]") if not self._quiet: entropy_server.output("%s %s %s" % (atom, sizeinfo, branchinfo), header="") else: entropy_server.output(atom, level="generic") if not pkg_ids and not self._quiet: entropy_server.output(darkgreen(_("No packages")), header=brown(" @@ ")) EitCommandDescriptor.register( EitCommandDescriptor(EitList, EitList.NAME, _("show repository content (packages)")))
return 1 if not etp_pkg_files: entropy_server.output( teal(_("no valid package paths")), importance=1, level="error") return 1 # in this case, no split package files are provided repository_id = entropy_server.repository() etp_pkg_files = [([x], True,) for x in etp_pkg_files] package_ids = entropy_server.add_packages_to_repository( repository_id, etp_pkg_files, ask=self._ask, reset_revision=self._reset_revision) if package_ids: # checking dependencies and print issues entropy_server.extended_dependencies_test([repository_id]) entropy_server.commit_repositories() if package_ids: return 0 return 1 EitCommandDescriptor.register( EitCommandDescriptor( EitInject, EitInject.NAME, _('inject package files into repository')) )
SEE_ALSO = "eit-cp(1)" def man(self): """ Overridden from EitCommand. """ return self._man() def parse(self): 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, [] self._source = nsargs.source self._dest = nsargs.dest self._deps = nsargs.deps self._ask = not nsargs.quick self._packages += nsargs.packages self._copy = False self._entropy_class()._inhibit_treeupdates = nsargs.conservative return self._call_exclusive, [self._move_copy, self._source] EitCommandDescriptor.register( EitCommandDescriptor(EitMv, EitMv.NAME, _('move packages from a repository to another')))
nsargs = parser.parse_args(self._args) except IOError: return parser.print_help, [] self._quiet = nsargs.quiet self._packages += nsargs.packages self._complete = nsargs.complete self._repository_id = nsargs.inrepo return self._call_shared, [self._graph, self._repository_id] def _graph(self, entropy_server): """ Actual Eit graph code. """ if self._repository_id is None: repository_ids = entropy_server.repositories() else: repository_ids = [self._repository_id] return graph_packages( self._packages, entropy_server, complete = self._complete, repository_ids = repository_ids, quiet = self._quiet) EitCommandDescriptor.register( EitCommandDescriptor( EitGraph, EitGraph.NAME, _('show dependency graph for packages')) )
"and slot updates"), default=self._conservative) parser.add_argument("--to", metavar="<repository>", help=_("add to given repository"), default=None) parser.add_argument("--quick", action="store_true", default=not self._ask, help=_("no stupid questions")) return parser def parse(self): """ Overridden from EitCommit """ parser = self._get_parser() try: nsargs = parser.parse_args(self._args) except IOError as err: return parser.print_help, [] # setup atoms variable before spawning commit self._ask = not nsargs.quick self._entropy_class()._inhibit_treeupdates = nsargs.conservative self._packages = nsargs.packages[:] return self._call_exclusive, [self._commit, nsargs.to] EitCommandDescriptor.register( EitCommandDescriptor(EitAdd, EitAdd.NAME, _('commit to repository the provided packages')))
entropy_server.output("[%s] %s" % ( purple(repository_id), blue(_("repository not available")), ), level="warning", importance=1) exit_st = 1 continue parser = RepositoryConfigParser() removed = parser.remove(repository_id) if not removed: exit_st = 1 entropy_server.output("[%s] %s" % ( purple(repository_id), blue(_("cannot remove repository")), ), level="warning", importance=1) else: entropy_server.output("[%s] %s" % ( purple(repository_id), blue(_("repository removed succesfully")), )) return exit_st EitCommandDescriptor.register( EitCommandDescriptor(EitRepo, EitRepo.NAME, _("manage repositories")))
parser = self._get_parser() try: nsargs = parser.parse_args(self._args) except IOError: return parser.print_help, [] self._quiet = nsargs.quiet self._packages += nsargs.packages self._complete = nsargs.complete self._repository_id = nsargs.inrepo return self._call_shared, [self._revgraph, self._repository_id] def _revgraph(self, entropy_server): """ Actual Eit revgraph code. """ if self._repository_id is None: repository_ids = entropy_server.repositories() else: repository_ids = [self._repository_id] return revgraph_packages(self._packages, entropy_server, complete=self._complete, repository_ids=repository_ids, quiet=self._quiet) EitCommandDescriptor.register( EitCommandDescriptor(EitRevgraph, EitRevgraph.NAME, _('show reverse dependency graph for packages')))
entropy_server.output(mytxt) entropy_server.output("") mytxt = "[%s] %s" % ( blue("-1"), darkred(_("Exit/Commit")), ) entropy_server.output(mytxt) def fake_callback(s): return s input_params = [ ('id', blue(_('Choose one by typing its identifier')), fake_callback, False)] data = entropy_server.input_box(title, input_params, cancel_button = True) if not isinstance(data, dict): return -1 try: return int(data['id']) except ValueError: return -2 EitCommandDescriptor.register( EitCommandDescriptor( EitNotice, EitNotice.NAME, _('manage repository notice-board')) )
sts = self.__sync_repo(entropy_server, repository_id) if sts == 0: # do not touch locking entropy_server.Mirrors.lock_mirrors(repository_id, False, unlock_locally = (self._as_repository_id is None)) if sts != 0: entropy_server.output(red(_("Aborting !")), importance=1, level="error", header=darkred(" !!! ")) return sts if self._ask: q_rc = entropy_server.ask_question( _("Should I cleanup old packages on mirrors ?")) if q_rc == _("No"): return 0 # fall through done = entropy_server.Mirrors.tidy_mirrors( repository_id, ask = self._ask, pretend = self._pretend) if not done: return 1 return 0 EitCommandDescriptor.register( EitCommandDescriptor( EitPush, EitPush.NAME, _('push repository packages and metadata')) )
importance=1, header=brown(" @@ ")) repo_map = {} for pkg_id, repo_id in pkg_matches: repo = entropy_server.open_repository(repo_id) pkgatom = repo.retrieveAtom(pkg_id) entropy_server.output( "[%s] %s" % (teal(repo_id), purple(pkgatom)), header=brown(" # ")) obj = repo_map.setdefault(repo_id, []) obj.append(pkg_id) if self._ask: resp = entropy_server.ask_question( _("Would you like to continue ?")) if resp == _("No"): return 0 for repo_id, pkg_ids in repo_map.items(): entropy_server.remove_packages(repo_id, pkg_ids) return 0 EitCommandDescriptor.register( EitCommandDescriptor( EitRemove, EitRemove.NAME, _('remove packages from repository')) )
def parse(self): """ Overridden from EitInit """ 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, [] self._ask = not nsargs.quick return self._call_exclusive, [self._init, nsargs.repo[0]] def _init(self, entropy_server): rc = entropy_server.initialize_repository( entropy_server.repository(), ask=self._ask) if rc == 0: entropy_server.output( teal(_("Entropy repository has been initialized")), header=darkgreen(" * "), importance=1) return 0 return 1 EitCommandDescriptor.register( EitCommandDescriptor( EitInit, EitInit.NAME, _('initialize repository (erasing all its content)')) )
def _pkgtest(self, entropy_server): repository_id = self._nsargs.repo if repository_id is None: repository_id = entropy_server.repository() if repository_id not in entropy_server.repositories(): entropy_server.output( "%s: %s" % (purple(_("Invalid repository")), teal(repository_id)), importance=1, level="error") return 1 fine, failed, dl_fine, dl_err = \ entropy_server._verify_local_packages( repository_id, [], ask = not self._nsargs.quick) if failed: return 1 return 0 def _rem_pkgtest(self, entropy_server): repository_id = self._nsargs.repo if repository_id is None: repository_id = entropy_server.repository() entropy_server._verify_remote_packages(repository_id, [], ask=self._ask) return 0 EitCommandDescriptor.register( EitCommandDescriptor(EitTest, EitTest.NAME, _('run QA tests')))
purple(_("Not matched")), teal(package)), level="warning", importance=1) continue entropy_repository = entropy_server.open_repository(pkg_repo) files = entropy_repository.retrieveContent( pkg_id, order_by="file") atom = entropy_repository.retrieveAtom(pkg_id) if self._quiet: for path in files: entropy_server.output(path, level="generic") else: for path in files: entropy_server.output(path) entropy_server.output( "[%s] %s: %s %s" % ( purple(pkg_repo), darkgreen(atom), bold(str(len(files))), teal(_("files found")))) return exit_st EitCommandDescriptor.register( EitCommandDescriptor( EitFiles, EitFiles.NAME, _('show files owned by packages')) )
def _get_parser(self): """ Overridden from EitCommand """ descriptor = EitCommandDescriptor.obtain_descriptor(EitTest.NAME) parser = argparse.ArgumentParser( description=descriptor.get_description(), formatter_class=argparse.RawDescriptionHelpFormatter, prog="%s %s" % (sys.argv[0], EitTest.NAME)) subparsers = parser.add_subparsers(title="test", description=_("run given test"), help=_("available tests")) deps_parser = subparsers.add_parser("deps", help=_("dependencies test")) deps_parser.set_defaults(func=self._deptest) libs_parser = subparsers.add_parser("libs", help=_("libraries test")) libs_parser.add_argument("--dump", action="store_true", default=False, help=_("dump results to file")) libs_parser.set_defaults(func=self._libtest) links_parser = subparsers.add_parser( "links", help=_("library linking test (using repository metadata)")) links_parser.add_argument("excllibs", nargs='*', default=None, metavar="<excluded lib>", help=_("excluded soname")) links_parser.set_defaults(func=self._linktest) pkglibs_parser = subparsers.add_parser( "pkglibs", help=_("library linking test (using live system)")) pkglibs_parser.add_argument("packages", nargs='+', default=None, metavar="<package>", help=_("package names")) pkglibs_parser.set_defaults(func=self._pkglibs) pkgs_parser = subparsers.add_parser( "local", help=_("verify local packages integrity")) pkgs_parser.add_argument("repo", nargs='?', default=None, metavar="<repo>", help=_("repository")) pkgs_parser.add_argument("--quick", action="store_true", default=not self._ask, help=_("no stupid questions")) pkgs_parser.set_defaults(func=self._pkgtest) rempkgs_parser = subparsers.add_parser( "remote", help=_("verify remote packages integrity")) rempkgs_parser.add_argument("repo", nargs='?', default=None, metavar="<repo>", help=_("repository")) rempkgs_parser.add_argument("--quick", action="store_true", default=not self._ask, help=_("no stupid questions")) rempkgs_parser.set_defaults(func=self._rem_pkgtest) return parser
_("Invalid Repository"), self._repository_id), level="error", importance=1) return 1 done = entropy_server.Mirrors.lock_mirrors_for_download( self._repository_id, self._action_lock, quiet = self._quiet) if not done: return 1 return 0 EitCommandDescriptor.register( EitCommandDescriptor( EitLock, EitLock.NAME, _('lock repository')) ) class EitUnlock(EitLock): """ Main Eit unlock command. """ NAME = "unlock" ALIASES = [] ALLOW_UNPRIVILEGED = True def __init__(self, args): EitLock.__init__(self, args)
if not etp_pkg_files: entropy_server.output(teal(_("no valid package paths")), importance=1, level="error") return 1 # in this case, no split package files are provided repository_id = entropy_server.repository() etp_pkg_files = [( [x], True, ) for x in etp_pkg_files] package_ids = entropy_server.add_packages_to_repository( repository_id, etp_pkg_files, ask=self._ask, reset_revision=self._reset_revision) if package_ids: # checking dependencies and print issues entropy_server.extended_dependencies_test([repository_id]) entropy_server.commit_repositories() if package_ids: return 0 return 1 EitCommandDescriptor.register( EitCommandDescriptor(EitInject, EitInject.NAME, _('inject package files into repository')))
default_str = "" if repository_id == default_repo: default_str = " (%s)" % (purple("*"), ) meta = entropy_server.repository_metadata(repository_id) description = meta['description'] repo_mirrors = meta['repo_mirrors'] pkg_mirrors = meta['pkg_mirrors'] entropy_server.output("%s [%s]%s" % ( teal(repository_id), darkgreen(description), default_str, )) for repo_mirror in repo_mirrors: entropy_server.output(" %s: %s" % ( blue(_("repository")), brown(repo_mirror), )) for pkg_mirror in pkg_mirrors: entropy_server.output(" %s: %s" % ( blue(_("packages")), brown(pkg_mirror), )) return 0 EitCommandDescriptor.register( EitCommandDescriptor(EitRemote, EitRemote.NAME, _('manage repositories')))
darkred(mydata['title']), ) entropy_server.output(mytxt) entropy_server.output("") mytxt = "[%s] %s" % ( blue("-1"), darkred(_("Exit/Commit")), ) entropy_server.output(mytxt) def fake_callback(s): return s input_params = [('id', blue(_('Choose one by typing its identifier')), fake_callback, False)] data = entropy_server.input_box(title, input_params, cancel_button=True) if not isinstance(data, dict): return -1 try: return int(data['id']) except ValueError: return -2 EitCommandDescriptor.register( EitCommandDescriptor(EitNotice, EitNotice.NAME, _('manage repository notice-board')))