本文整理汇总了Python中solo.commands.descriptor.SoloCommandDescriptor类的典型用法代码示例。如果您正苦于以下问题:Python SoloCommandDescriptor类的具体用法?Python SoloCommandDescriptor怎么用?Python SoloCommandDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SoloCommandDescriptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _get_parser
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
开发者ID:B-Rich,项目名称:entropy,代码行数:31,代码来源:preservedlibs.py
示例2: _get_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
开发者ID:B-Rich,项目名称:entropy,代码行数:32,代码来源:search.py
示例3: _get_parser
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
开发者ID:B-Rich,项目名称:entropy,代码行数:31,代码来源:cache.py
示例4: _get_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
开发者ID:dMaggot,项目名称:entropy,代码行数:25,代码来源:conf.py
示例5: _get_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("--by-user", action="store_true",
default=self._byuser,
help=_("include packages installed by user"))
_commands.append("--by-user")
self._commands = _commands
return parser
开发者ID:Heather,项目名称:entropy,代码行数:30,代码来源:unused.py
示例6: _show_help
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.argentlinux.io",
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
开发者ID:StefanCristian,项目名称:entropy,代码行数:34,代码来源:help.py
示例7: bashcomp
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()
开发者ID:StefanCristian,项目名称:entropy,代码行数:26,代码来源:help.py
示例8: _get_parser
def _get_parser(self):
"""
Overridden from SoloCommand.
"""
descriptor = SoloCommandDescriptor.obtain_descriptor(
SoloStatus.NAME)
parser = argparse.ArgumentParser(
description=descriptor.get_description(),
formatter_class=argparse.RawDescriptionHelpFormatter,
prog="%s %s" % (sys.argv[0], SoloStatus.NAME))
return parser
开发者ID:B-Rich,项目名称:entropy,代码行数:12,代码来源:status.py
示例9: _get_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
开发者ID:Heather,项目名称:entropy,代码行数:15,代码来源:notice.py
示例10: _get_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
开发者ID:dMaggot,项目名称:entropy,代码行数:15,代码来源:hop.py
示例11: _get_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
开发者ID:B-Rich,项目名称:entropy,代码行数:18,代码来源:update.py
示例12: _get_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
开发者ID:dMaggot,项目名称:entropy,代码行数:43,代码来源:libtest.py
示例13: _get_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
开发者ID:dMaggot,项目名称:entropy,代码行数:41,代码来源:config.py
示例14: _get_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
开发者ID:geaaru,项目名称:entropy,代码行数:22,代码来源:deptest.py
示例15: _get_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
开发者ID:dMaggot,项目名称:entropy,代码行数:24,代码来源:mask.py
示例16: SoloUnmask
class SoloUnmask(SoloMaskUnmask):
"""
Main Solo Mask command.
"""
NAME = "unmask"
ALIASES = []
INTRODUCTION = """\
Unmask packages so that installation and update will be allowed.
"""
SEE_ALSO = "equo-mask(1)"
def __init__(self, args):
SoloMaskUnmask.__init__(self, args, SoloUnmask.NAME)
SoloCommandDescriptor.register(
SoloCommandDescriptor(
SoloMask,
SoloMask.NAME,
_("mask one or more packages"))
)
SoloCommandDescriptor.register(
SoloCommandDescriptor(
SoloUnmask,
SoloUnmask.NAME,
_("unmask one or more packages"))
)
开发者ID:dMaggot,项目名称:entropy,代码行数:30,代码来源:mask.py
示例17: darkred
level="error", importance=1
)
return 1
if not voted:
entropy_client.output(
"[%s] %s: %s" % (
darkred(pkgkey),
blue(_("UGC error")),
_("already voted"),
),
level="error", importance=1
)
return 1
else:
entropy_client.output("[%s] %s" % (
purple(pkgkey),
blue(_("vote added, thank you!")),
)
)
self._vote_get(entropy_client)
return 0
SoloCommandDescriptor.register(
SoloCommandDescriptor(
SoloUgc,
SoloUgc.NAME,
_("manage User Generated Content"))
)
开发者ID:B-Rich,项目名称:entropy,代码行数:30,代码来源:ugc.py
示例18: _get_parser
def _get_parser(self):
"""
Overridden from SoloCommand.
"""
_commands = {}
descriptor = SoloCommandDescriptor.obtain_descriptor(
SoloSecurity.NAME)
parser = argparse.ArgumentParser(
description=descriptor.get_description(),
formatter_class=argparse.RawDescriptionHelpFormatter,
prog="%s %s" % (sys.argv[0], SoloSecurity.NAME))
self._setup_verbose_quiet_parser(parser)
subparsers = parser.add_subparsers(
title="action", description=_("system security tools"),
help=_("available commands"))
oscheck_parser = subparsers.add_parser(
"oscheck",
help=_("verify installed files using stored checksums"))
self._setup_verbose_quiet_parser(oscheck_parser)
oscheck_parser.add_argument(
"--mtime", action="store_true", default=False,
help=_("consider mtime instead of SHA256 "
"(false positives ahead)"))
oscheck_parser.add_argument(
"--assimilate", action="store_true", default=False,
help=_("update hashes and mtime (useful after "
"editing config files)"))
oscheck_parser.add_argument(
"--reinstall", action="store_true", default=False,
help=_("reinstall faulty packages"))
mg_group = oscheck_parser.add_mutually_exclusive_group()
mg_group.add_argument(
"--ask", "-a", action="store_true", default=False,
help=_("ask before making any changes"))
mg_group.add_argument(
"--pretend", "-p", action="store_true", default=False,
help=_("show what would be done"))
oscheck_parser.add_argument(
"--fetch", action="store_true", default=False,
help=_("just download packages"))
oscheck_parser.set_defaults(func=self._oscheck)
_commands["oscheck"] = {
"--mtime": {},
"--assimilate": {},
"--reinstall": {},
"--pretend": {},
"-p": {},
"--ask": {},
"-a": {},
"--fetch": {},
}
update_parser = subparsers.add_parser(
"update",
help=_("download the latest Security Advisories"))
self._setup_verbose_quiet_parser(update_parser)
update_parser.add_argument(
"--force", action="store_true", default=False,
help=_("force download"))
update_parser.set_defaults(func=self._update)
_commands["update"] = {
"--force": {},
}
list_parser = subparsers.add_parser(
"list",
help=_("list all the available Security Advisories"))
self._setup_verbose_quiet_parser(list_parser)
mg_group = list_parser.add_mutually_exclusive_group()
mg_group.add_argument(
"--affected", action="store_true", default=False,
help=_("list only affected"))
mg_group.add_argument(
"--unaffected", action="store_true", default=False,
help=_("list only unaffected"))
list_parser.set_defaults(func=self._list)
_commands["list"] = {
"--affected": {},
"--unaffected": {},
}
info_parser = subparsers.add_parser(
"info",
help=_("show information about provided "
"advisories identifiers"))
self._setup_verbose_quiet_parser(info_parser)
info_parser.add_argument(
"ids", nargs='+',
metavar="<id>", help=_("advisory indentifier"))
info_parser.set_defaults(func=self._info)
_commands["info"] = {}
#.........这里部分代码省略.........
开发者ID:B-Rich,项目名称:entropy,代码行数:101,代码来源:security.py
示例19: main
def main():
is_color = "--color" in sys.argv
if is_color:
sys.argv.remove("--color")
if not is_color and not is_stdout_a_tty():
nocolor()
warn_version_mismatch()
install_exception_handler()
descriptors = SoloCommandDescriptor.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 -> equo --bashcomp equo repo
# and we need to drop --bashcomp and
# argv[2]
if args:
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)
yell_class = args_map.get("yell")
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 and \
not cmd_class.ALLOW_UNPRIVILEGED and \
"--help" not in args:
cmd_class = catch_all
allowed = False
if allowed:
if not cmd_class.ALLOW_UNPRIVILEGED:
if entropy.tools.islive():
warn_live_system()
func, func_args = cmd_obj.parse()
exit_st = func(*func_args)
if exit_st == -10:
# syntax error, yell at user
func, func_args = yell_class(args).parse()
func(*func_args)
raise SystemExit(10)
else:
yell_class.reset()
raise SystemExit(exit_st)
else:
# execute this anyway so that commands are
# incomplete or invalid, the command error
# message will take precedence.
_func, _func_args = cmd_obj.parse()
print_error(_("superuser access required"))
raise SystemExit(1)
开发者ID:geaaru,项目名称:entropy,代码行数:100,代码来源:main.py
示例20: _get_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
开发者ID:dMaggot,项目名称:entropy,代码行数:78,代码来源:remove.py
注:本文中的solo.commands.descriptor.SoloCommandDescriptor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论