本文整理汇总了Python中solo.commands.descriptor.SoloCommandDescriptor.register方法的典型用法代码示例。如果您正苦于以下问题:Python SoloCommandDescriptor.register方法的具体用法?Python SoloCommandDescriptor.register怎么用?Python SoloCommandDescriptor.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类solo.commands.descriptor.SoloCommandDescriptor
的用法示例。
在下文中一共展示了SoloCommandDescriptor.register方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _cleanup
# 需要导入模块: from solo.commands.descriptor import SoloCommandDescriptor [as 别名]
# 或者: from solo.commands.descriptor.SoloCommandDescriptor import register [as 别名]
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"))
)
示例2: teal
# 需要导入模块: from solo.commands.descriptor import SoloCommandDescriptor [as 别名]
# 或者: from solo.commands.descriptor.SoloCommandDescriptor import register [as 别名]
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"))
)
示例3: blue
# 需要导入模块: from solo.commands.descriptor import SoloCommandDescriptor [as 别名]
# 或者: from solo.commands.descriptor.SoloCommandDescriptor import register [as 别名]
continue
key_slot = inst_repo.retrieveKeySlotAggregated(
inst_package_id)
package_id, repository_id = entropy_client.atom_match(key_slot)
if package_id != -1:
valid_matches.add((package_id, repository_id))
if not valid_matches:
entropy_client.output(
"%s." % (
blue(_("All the available updates "
"have been already installed")),),
header=darkred(" @@ "))
return 0
exit_st, _show_cfgupd = self._install_action(
entropy_client, True, True,
pretend, ask, False, quiet, False,
False, False, fetch, False, False,
False, 1, [], package_matches=list(valid_matches))
return exit_st
SoloCommandDescriptor.register(
SoloCommandDescriptor(
SoloSecurity,
SoloSecurity.NAME,
_("system security tools"))
)
示例4: blue
# 需要导入模块: from solo.commands.descriptor import SoloCommandDescriptor [as 别名]
# 或者: from solo.commands.descriptor.SoloCommandDescriptor import register [as 别名]
exit_st = pkg.start()
if exit_st != 0:
if ugc_thread is not None:
ugc_thread.join()
return 1, True
finally:
if pkg is not None:
pkg.finalize()
finally:
if notif_acquired:
notification_lock.release()
if ugc_thread is not None:
ugc_thread.join()
entropy_client.output(
"%s." % (
blue(_("Installation complete")),),
header=darkred(" @@ "))
return 0, True
SoloCommandDescriptor.register(
SoloCommandDescriptor(
SoloInstall,
SoloInstall.NAME,
_("install or update packages or package files"))
)
示例5: _
# 需要导入模块: from solo.commands.descriptor import SoloCommandDescriptor [as 别名]
# 或者: from solo.commands.descriptor.SoloCommandDescriptor import register [as 别名]
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"))
)
示例6: not
# 需要导入模块: from solo.commands.descriptor import SoloCommandDescriptor [as 别名]
# 或者: from solo.commands.descriptor.SoloCommandDescriptor import register [as 别名]
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,
True)
if exit_st == 0:
self._signal_ugc(entropy_client, down_data)
return exit_st
SoloCommandDescriptor.register(
SoloCommandDescriptor(
SoloDownload,
SoloDownload.NAME,
_("download packages, essentially"))
)
示例7: set
# 需要导入模块: from solo.commands.descriptor import SoloCommandDescriptor [as 别名]
# 或者: from solo.commands.descriptor.SoloCommandDescriptor import register [as 别名]
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"))
)
示例8: blue
# 需要导入模块: from solo.commands.descriptor import SoloCommandDescriptor [as 别名]
# 或者: from solo.commands.descriptor.SoloCommandDescriptor import register [as 别名]
else:
mytxt = "%s %s %s" % (
blue(_("Installing available packages in")),
darkred(_("10 seconds")),
blue("..."),
)
entropy_client.output(mytxt, header=darkred(" @@ "))
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"))
)
示例9: list
# 需要导入模块: from solo.commands.descriptor import SoloCommandDescriptor [as 别名]
# 或者: from solo.commands.descriptor.SoloCommandDescriptor import register [as 别名]
return True
# filter: --by-user not provided -> if package has been installed
# by user, exclude from list.
if not self._byuser:
data = list(filter(_user_filter, data))
if self._sortbysize:
data.sort(key = lambda x: x[0])
if self._quiet:
entropy_client.output(
'\n'.join([x[2] for x in data]),
level="generic")
else:
for disk_size, idpackage, atom in data:
disk_size = entropy.tools.bytes_into_human(disk_size)
entropy_client.output(
"# %s%s%s %s" % (
blue("["), brown(disk_size),
blue("]"), darkgreen(atom),))
return 0
SoloCommandDescriptor.register(
SoloCommandDescriptor(
SoloUnused,
SoloUnused.NAME,
_("look for unused packages (pay attention)"))
)
示例10: _updates
# 需要导入模块: from solo.commands.descriptor import SoloCommandDescriptor [as 别名]
# 或者: from solo.commands.descriptor.SoloCommandDescriptor import register [as 别名]
def _updates(self, entropy_client):
"""
Solo Query Updates command.
"""
quiet = self._nsargs.quiet
verbose = self._nsargs.verbose
if not quiet:
entropy_client.output(brown(_("Available Updates")), header=darkred(" @@ "))
outcome = entropy_client.calculate_updates(quiet=True)
update, remove = outcome["update"], outcome["remove"]
fine, critical_f = outcome["fine"], outcome["critical_found"]
if quiet:
entropy_client.output("%d" % (len(update),), level="generic")
return 0
toc = []
toc.append((darkgreen(_("Packages to update:")), bold(const_convert_to_unicode(len(update)))))
toc.append((darkred(_("Packages to remove:")), bold(const_convert_to_unicode(len(remove)))))
if verbose:
toc.append((blue(_("Packages already up-to-date:")), bold(const_convert_to_unicode(len(fine)))))
toc.append((purple(_("Critical updates found:")), teal(const_convert_to_unicode(str(critical_f)))))
print_table(entropy_client, toc)
return 0
SoloCommandDescriptor.register(SoloCommandDescriptor(SoloQuery, SoloQuery.NAME, _("repository query tools")))
示例11: _
# 需要导入模块: from solo.commands.descriptor import SoloCommandDescriptor [as 别名]
# 或者: from solo.commands.descriptor.SoloCommandDescriptor import register [as 别名]
" %s" % (_("Would you like to install them ?"),)
)
if exit_st == _("No"):
return 1
else:
mytxt = "%s %s %s" % (
blue(_("Installing available packages in")),
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"))
)
示例12: SoloCommandDescriptor
# 需要导入模块: from solo.commands.descriptor import SoloCommandDescriptor [as 别名]
# 或者: from solo.commands.descriptor.SoloCommandDescriptor import register [as 别名]
# 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"))
)
示例13: _show_notice_board_summary
# 需要导入模块: from solo.commands.descriptor import SoloCommandDescriptor [as 别名]
# 或者: from solo.commands.descriptor.SoloCommandDescriptor import register [as 别名]
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"))
)
示例14: EntropyCacher
# 需要导入模块: from solo.commands.descriptor import SoloCommandDescriptor [as 别名]
# 或者: from solo.commands.descriptor.SoloCommandDescriptor import register [as 别名]
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"))
)
示例15: _get_message
# 需要导入模块: from solo.commands.descriptor import SoloCommandDescriptor [as 别名]
# 或者: from solo.commands.descriptor.SoloCommandDescriptor import register [as 别名]
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"))
)