本文整理汇总了Python中portage.writemsg函数的典型用法代码示例。如果您正苦于以下问题:Python writemsg函数的具体用法?Python writemsg怎么用?Python writemsg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了writemsg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testWakeupFdSigchld
def testWakeupFdSigchld(self):
"""
This is expected to trigger a bunch of messages like the following
unless the fix for bug 655656 works as intended:
Exception ignored when trying to write to the signal wakeup fd:
BlockingIOError: [Errno 11] Resource temporarily unavailable
"""
script = """
import os
import signal
import sys
import portage
# In order to avoid potential interference with API consumers, wakeup
# fd handling is enabled only when portage._interal_caller is True.
portage._internal_caller = True
from portage.util.futures import asyncio
loop = asyncio._wrap_loop()
# Cause the loop to register a child watcher.
proc = loop.run_until_complete(asyncio.create_subprocess_exec('sleep', '0', loop=loop))
loop.run_until_complete(proc.wait())
for i in range(8192):
os.kill(os.getpid(), signal.SIGCHLD)
# Verify that the child watcher still works correctly
# (this will hang if it doesn't).
proc = loop.run_until_complete(asyncio.create_subprocess_exec('sleep', '0', loop=loop))
loop.run_until_complete(proc.wait())
loop.close()
sys.stdout.write('success')
sys.exit(os.EX_OK)
"""
pythonpath = os.environ.get('PYTHONPATH', '').strip().split(':')
if not pythonpath or pythonpath[0] != PORTAGE_PYM_PATH:
pythonpath = [PORTAGE_PYM_PATH] + pythonpath
pythonpath = ':'.join(filter(None, pythonpath))
proc = subprocess.Popen(
[portage._python_interpreter, '-c', script],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
env=dict(os.environ, PYTHONPATH=pythonpath))
out, err = proc.communicate()
try:
self.assertEqual(out[:100], b'success')
except Exception:
portage.writemsg(''.join('{}\n'.format(line)
for line in out.decode(errors='replace').splitlines()[:50]),
noiselevel=-1)
raise
self.assertEqual(proc.wait(), os.EX_OK)
示例2: _wait
def _wait(self):
AsyncScheduler._wait(self)
portdb = self._portdb
dead_nodes = {}
self._termination_check()
if self._terminated_tasks:
portdb.flush_cache()
self.returncode = self._cancelled_returncode
return self.returncode
if self._global_cleanse:
for mytree in portdb.porttrees:
try:
dead_nodes[mytree] = set(portdb.auxdb[mytree])
except CacheError as e:
portage.writemsg("Error listing cache entries for " + \
"'%s': %s, continuing...\n" % (mytree, e),
noiselevel=-1)
del e
dead_nodes = None
break
else:
cp_set = self._cp_set
cpv_getkey = portage.cpv_getkey
for mytree in portdb.porttrees:
try:
dead_nodes[mytree] = set(cpv for cpv in \
portdb.auxdb[mytree] \
if cpv_getkey(cpv) in cp_set)
except CacheError as e:
portage.writemsg("Error listing cache entries for " + \
"'%s': %s, continuing...\n" % (mytree, e),
noiselevel=-1)
del e
dead_nodes = None
break
if dead_nodes:
for y in self._valid_pkgs:
for mytree in portdb.porttrees:
if portdb.findname2(y, mytree=mytree)[0]:
dead_nodes[mytree].discard(y)
for mytree, nodes in dead_nodes.items():
auxdb = portdb.auxdb[mytree]
for y in nodes:
try:
del auxdb[y]
except (KeyError, CacheError):
pass
portdb.flush_cache()
return self.returncode
示例3: run
def run(self):
portdb = self._portdb
from portage.cache.cache_errors import CacheError
dead_nodes = {}
while self._schedule():
self._poll_loop()
while self._jobs:
self._poll_loop()
if self._terminated_tasks:
self.returncode = 1
return
if self._global_cleanse:
for mytree in portdb.porttrees:
try:
dead_nodes[mytree] = set(portdb.auxdb[mytree])
except CacheError as e:
portage.writemsg("Error listing cache entries for " + \
"'%s': %s, continuing...\n" % (mytree, e),
noiselevel=-1)
del e
dead_nodes = None
break
else:
cp_set = self._cp_set
cpv_getkey = portage.cpv_getkey
for mytree in portdb.porttrees:
try:
dead_nodes[mytree] = set(cpv for cpv in \
portdb.auxdb[mytree] \
if cpv_getkey(cpv) in cp_set)
except CacheError as e:
portage.writemsg("Error listing cache entries for " + \
"'%s': %s, continuing...\n" % (mytree, e),
noiselevel=-1)
del e
dead_nodes = None
break
if dead_nodes:
for y in self._valid_pkgs:
for mytree in portdb.porttrees:
if portdb.findname2(y, mytree=mytree)[0]:
dead_nodes[mytree].discard(y)
for mytree, nodes in dead_nodes.items():
auxdb = portdb.auxdb[mytree]
for y in nodes:
try:
del auxdb[y]
except (KeyError, CacheError):
pass
示例4: _task_exit
def _task_exit(self, task):
if task.returncode != os.EX_OK:
if not self._terminated_tasks:
portage.writemsg(
"Error processing %s%s%s, continuing...\n" %
(task.cp, _repo_separator, task.repo_config.name),
noiselevel=-1)
AsyncScheduler._task_exit(self, task)
示例5: setexec
def setexec(ctx="\n"):
ctx = _unicode_encode(ctx, encoding=_encodings['content'], errors='strict')
if selinux.setexeccon(ctx) < 0:
ctx = _unicode_decode(ctx, encoding=_encodings['content'],
errors='replace')
if selinux.security_getenforce() == 1:
raise OSError(_("Failed setting exec() context \"%s\".") % ctx)
else:
portage.writemsg("!!! " + \
_("Failed setting exec() context \"%s\".") % ctx, \
noiselevel=-1)
示例6: _cleanup
def _cleanup(self):
super(MetadataRegen, self)._cleanup()
portdb = self._portdb
dead_nodes = {}
if self._terminated.is_set():
portdb.flush_cache()
return
if self._global_cleanse:
for mytree in portdb.porttrees:
try:
dead_nodes[mytree] = set(portdb.auxdb[mytree])
except CacheError as e:
portage.writemsg("Error listing cache entries for " + \
"'%s': %s, continuing...\n" % (mytree, e),
noiselevel=-1)
del e
dead_nodes = None
break
else:
cp_set = self._cp_set
cpv_getkey = portage.cpv_getkey
for mytree in portdb.porttrees:
try:
dead_nodes[mytree] = set(cpv for cpv in \
portdb.auxdb[mytree] \
if cpv_getkey(cpv) in cp_set)
except CacheError as e:
portage.writemsg("Error listing cache entries for " + \
"'%s': %s, continuing...\n" % (mytree, e),
noiselevel=-1)
del e
dead_nodes = None
break
if dead_nodes:
for y in self._valid_pkgs:
for mytree in portdb.porttrees:
if portdb.findname2(y, mytree=mytree)[0]:
dead_nodes[mytree].discard(y)
for mytree, nodes in dead_nodes.items():
auxdb = portdb.auxdb[mytree]
for y in nodes:
try:
del auxdb[y]
except (KeyError, CacheError):
pass
portdb.flush_cache()
示例7: sign_manifest
def sign_manifest(self, myupdates, myremoved, mymanifests):
try:
for x in sorted(vcs_files_to_cps(
chain(myupdates, myremoved, mymanifests),
self.scanner.repolevel, self.scanner.reposplit, self.scanner.categories)):
self.repoman_settings["O"] = os.path.join(self.repo_settings.repodir, x)
manifest_path = os.path.join(self.repoman_settings["O"], "Manifest")
if not need_signature(manifest_path):
continue
gpgsign(manifest_path, self.repoman_settings, self.options)
except portage.exception.PortageException as e:
portage.writemsg("!!! %s\n" % str(e))
portage.writemsg("!!! Disabled FEATURES='sign'\n")
self.repo_settings.sign_manifests = False
示例8: _task_exit
def _task_exit(self, metadata_process):
if metadata_process.returncode != os.EX_OK:
self._valid_pkgs.discard(metadata_process.cpv)
if not self._terminated_tasks:
portage.writemsg("Error processing %s, continuing...\n" % \
(metadata_process.cpv,), noiselevel=-1)
if self._consumer is not None:
# On failure, still notify the consumer (in this case the metadata
# argument is None).
self._consumer(metadata_process.cpv,
metadata_process.repo_path,
metadata_process.metadata,
metadata_process.ebuild_hash,
metadata_process.eapi_supported)
AsyncScheduler._task_exit(self, metadata_process)
示例9: _metadata_exit
def _metadata_exit(self, metadata_process):
self._jobs -= 1
if metadata_process.returncode != os.EX_OK:
self.returncode = 1
self._error_count += 1
self._valid_pkgs.discard(metadata_process.cpv)
portage.writemsg("Error processing %s, continuing...\n" % \
(metadata_process.cpv,), noiselevel=-1)
if self._consumer is not None:
# On failure, still notify the consumer (in this case the metadata
# argument is None).
self._consumer(metadata_process.cpv,
metadata_process.ebuild_path,
metadata_process.repo_path,
metadata_process.metadata)
self._schedule()
示例10: _iter_tasks
def _iter_tasks(self):
portdb = self._portdb
distdir = portdb.settings["DISTDIR"]
disabled_repos = set()
for cp in self._cp_iter:
if self._terminated.is_set():
break
# We iterate over portdb.porttrees, since it's common to
# tweak this attribute in order to adjust repo selection.
for mytree in portdb.porttrees:
if self._terminated.is_set():
break
repo_config = portdb.repositories.get_repo_for_location(mytree)
if not repo_config.create_manifest:
if repo_config.name not in disabled_repos:
disabled_repos.add(repo_config.name)
portage.writemsg(
_(">>> Skipping creating Manifest for %s%s%s; "
"repository is configured to not use them\n") %
(cp, _repo_separator, repo_config.name),
noiselevel=-1)
continue
cpv_list = portdb.cp_list(cp, mytree=[repo_config.location])
if not cpv_list:
continue
fetchlist_dict = {}
try:
for cpv in cpv_list:
fetchlist_dict[cpv] = \
list(portdb.getFetchMap(cpv, mytree=mytree))
except InvalidDependString as e:
portage.writemsg(
_("!!! %s%s%s: SRC_URI: %s\n") %
(cp, _repo_separator, repo_config.name, e),
noiselevel=-1)
self._error_count += 1
continue
yield ManifestTask(cp=cp, distdir=distdir,
fetchlist_dict=fetchlist_dict, repo_config=repo_config,
gpg_cmd=self._gpg_cmd, gpg_vars=self._gpg_vars,
force_sign_key=self._force_sign_key)
示例11: _set_rsync_defaults
def _set_rsync_defaults(self):
portage.writemsg("PORTAGE_RSYNC_OPTS empty or unset, using hardcoded defaults\n")
rsync_opts = [
"--recursive", # Recurse directories
"--links", # Consider symlinks
"--safe-links", # Ignore links outside of tree
"--perms", # Preserve permissions
"--times", # Preserive mod times
"--omit-dir-times",
"--compress", # Compress the data transmitted
"--force", # Force deletion on non-empty dirs
"--whole-file", # Don't do block transfers, only entire files
"--delete", # Delete files that aren't in the master tree
"--stats", # Show final statistics about what was transfered
"--human-readable",
"--timeout="+str(self.timeout), # IO timeout if not done in X seconds
"--exclude=/distfiles", # Exclude distfiles from consideration
"--exclude=/local", # Exclude local from consideration
"--exclude=/packages", # Exclude packages from consideration
]
return rsync_opts
示例12: _run
def _run(self):
mf = self.repo_config.load_manifest(
os.path.join(self.repo_config.location, self.cp),
self.distdir, fetchlist_dict=self.fetchlist_dict)
try:
mf.create(assumeDistHashesAlways=True)
except FileNotFound as e:
portage.writemsg(_("!!! File %s doesn't exist, can't update "
"Manifest\n") % e, noiselevel=-1)
return 1
except PortagePackageException as e:
portage.writemsg(("!!! %s\n") % (e,), noiselevel=-1)
return 1
try:
modified = mf.write(sign=False)
except PermissionDenied as e:
portage.writemsg("!!! %s: %s\n" % (_("Permission Denied"), e,),
noiselevel=-1)
return 1
else:
if modified:
return self.MODIFIED
else:
return os.EX_OK
示例13: setexec
def setexec(ctx="\n"):
ctx = _native_string(ctx, encoding=_encodings['content'], errors='strict')
rc = 0
try:
rc = selinux.setexeccon(ctx)
except OSError:
msg = _("Failed to set new SELinux execution context. " + \
"Is your current SELinux context allowed to run Portage?")
if selinux.security_getenforce() == 1:
raise OSError(msg)
else:
portage.writemsg("!!! %s\n" % msg, noiselevel=-1)
if rc < 0:
if sys.hexversion < 0x3000000:
ctx = _unicode_decode(ctx, encoding=_encodings['content'], errors='replace')
if selinux.security_getenforce() == 1:
raise OSError(_("Failed setting exec() context \"%s\".") % ctx)
else:
portage.writemsg("!!! " + \
_("Failed setting exec() context \"%s\".") % ctx, \
noiselevel=-1)
示例14: _iter_tasks
def _iter_tasks(self):
portdb = self._portdb
distdir = portdb.settings["DISTDIR"]
disabled_repos = set()
for cp in self._cp_iter:
if self._terminated.is_set():
break
# We iterate over portdb.porttrees, since it's common to
# tweak this attribute in order to adjust repo selection.
for mytree in portdb.porttrees:
if self._terminated.is_set():
break
repo_config = portdb.repositories.get_repo_for_location(mytree)
if not repo_config.create_manifest:
if repo_config.name not in disabled_repos:
disabled_repos.add(repo_config.name)
portage.writemsg(
_(">>> Skipping creating Manifest for %s%s%s; "
"repository is configured to not use them\n") %
(cp, _repo_separator, repo_config.name),
noiselevel=-1)
continue
cpv_list = portdb.cp_list(cp, mytree=[repo_config.location])
if not cpv_list:
continue
# Use _async_manifest_fetchlist(max_jobs=1), since we
# spawn concurrent ManifestTask instances.
yield ManifestTask(cp=cp, distdir=distdir,
fetchlist_dict=_async_manifest_fetchlist(
portdb, repo_config, cp, cpv_list=cpv_list,
max_jobs=1, loop=self._event_loop),
repo_config=repo_config,
gpg_cmd=self._gpg_cmd, gpg_vars=self._gpg_vars,
force_sign_key=self._force_sign_key)
示例15: _validate_rsync_opts
def _validate_rsync_opts(self, rsync_opts, syncuri):
# The below validation is not needed when using the above hardcoded
# defaults.
portage.writemsg("Using PORTAGE_RSYNC_OPTS instead of hardcoded defaults\n", 1)
rsync_opts.extend(portage.util.shlex_split(self.settings.get("PORTAGE_RSYNC_OPTS", "")))
for opt in ("--recursive", "--times"):
if opt not in rsync_opts:
portage.writemsg(
yellow("WARNING:") + " adding required option " + "%s not included in PORTAGE_RSYNC_OPTS\n" % opt
)
rsync_opts.append(opt)
for exclude in ("distfiles", "local", "packages"):
opt = "--exclude=/%s" % exclude
if opt not in rsync_opts:
portage.writemsg(
yellow("WARNING:")
+ " adding required option %s not included in " % opt
+ "PORTAGE_RSYNC_OPTS (can be overridden with --exclude='!')\n"
)
rsync_opts.append(opt)
if syncuri.rstrip("/").endswith(".gentoo.org/gentoo-portage"):
def rsync_opt_startswith(opt_prefix):
for x in rsync_opts:
if x.startswith(opt_prefix):
return (1, False)
return (0, False)
if not rsync_opt_startswith("--timeout="):
rsync_opts.append("--timeout=%d" % self.timeout)
for opt in ("--compress", "--whole-file"):
if opt not in rsync_opts:
portage.writemsg(
yellow("WARNING:")
+ " adding required option "
+ "%s not included in PORTAGE_RSYNC_OPTS\n" % opt
)
rsync_opts.append(opt)
return rsync_opts