Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _async_start(self):
if not self._force_async:
try:
self._imp = lockfile(self.path,
wantnewlockfile=True, flags=os.O_NONBLOCK)
except TryAgain:
pass
else:
self.returncode = os.EX_OK
self._async_wait()
return
if self._force_process or \
(not self._force_thread and \
(self._use_process_by_default or threading is dummy_threading)):
self._imp = _LockProcess(path=self.path, scheduler=self.scheduler)
else:
self._imp = _LockThread(path=self.path,
scheduler=self.scheduler,
_force_dummy=self._force_dummy)
self._imp.addExitListener(self._imp_exit)
yield self._imp.async_start()
logging.info("dry-run: copy '%s' from %s to distfiles" %
(self.distfile, current_mirror.name))
self._success()
self.returncode = os.EX_OK
self.wait()
return
else:
src = os.path.join(current_mirror.location, self.distfile)
dest = os.path.join(self.config.options.distfiles,
self.config.layouts[0].get_path(self.distfile))
if self._hardlink_atomic(src, dest,
"%s to %s" % (current_mirror.name, "distfiles")):
logging.debug("hardlink '%s' from %s to distfiles" %
(self.distfile, current_mirror.name))
self._success()
self.returncode = os.EX_OK
self.wait()
return
else:
self._start_task(
FileCopier(src_path=src, dest_path=dest,
background=(self.background and
self._log_path is not None),
logfile=self._log_path),
self._fs_mirror_copier_exit)
return
self._try_next_mirror()
def _merge_exit(self, merge_task):
if self._final_exit(merge_task) != os.EX_OK:
self._start_exit_hook(self.returncode)
return
self.postinst_failure = merge_task.postinst_failure
pkg = self.pkg
self.world_atom(pkg)
pkg_count = self.pkg_count
pkg_path = self.pkg_path
logger = self.logger
if "noclean" not in self.settings.features:
short_msg = "emerge: (%s of %s) %s Clean Post" % \
(pkg_count.curval, pkg_count.maxval, pkg.cpv)
logger.log((" === (%s of %s) " + \
"Post-Build Cleaning (%s::%s)") % \
(pkg_count.curval, pkg_count.maxval, pkg.cpv, pkg_path),
short_msg=short_msg)
def emirrordist_main(args):
# The calling environment is ignored, so the program is
# completely controlled by commandline arguments.
env = {}
if not sys.stdout.isatty():
portage.output.nocolor()
env['NOCOLOR'] = 'true'
parser, options, args = parse_args(args)
if options.version:
sys.stdout.write("Portage %s\n" % portage.VERSION)
return os.EX_OK
config_root = options.config_root
if options.repositories_configuration is not None:
env['PORTAGE_REPOSITORIES'] = options.repositories_configuration
settings = portage.config(config_root=config_root,
local_config=False, env=env)
default_opts = None
if not options.ignore_default_opts:
default_opts = settings.get('EMIRRORDIST_DEFAULT_OPTS', '').split()
if default_opts:
parser, options, args = parse_args(default_opts + args)
def _task_exit(self, task):
self._running_tasks.discard(task)
if task.returncode != os.EX_OK:
self._error_count += 1
self._schedule()
def _extractor_exit(self, extractor_proc):
if self._default_exit(extractor_proc) != os.EX_OK:
self._remove_dest_env()
self.wait()
return
# This is a signal to ebuild.sh, so that it knows to filter
# out things like SANDBOX_{DENY,PREDICT,READ,WRITE} that
# would be preserved between normal phases.
open(_unicode_encode(self._get_dest_env_path() + '.raw'), 'wb').close()
self._current_task = None
self.returncode = os.EX_OK
self.wait()
is_pty is True if a pty was successfully allocated, and
False if a normal pipe was allocated.
"""
got_pty = False
global _disable_openpty, _fbsd_test_pty
if _fbsd_test_pty and not _disable_openpty:
# Test for python openpty breakage after freebsd7 to freebsd8
# upgrade, which results in a 'Function not implemented' error
# and the process being killed.
pid = os.fork()
if pid == 0:
pty.openpty()
os._exit(os.EX_OK)
pid, status = os.waitpid(pid, 0)
if (status & 0xff) == 140:
_disable_openpty = True
_fbsd_test_pty = False
if _disable_openpty:
master_fd, slave_fd = os.pipe()
else:
try:
master_fd, slave_fd = pty.openpty()
got_pty = True
except EnvironmentError as e:
_disable_openpty = True
writemsg("openpty failed: '%s'\n" % str(e),
noiselevel=-1)
del e
def perform_post_sync_hook(self, reponame, dosyncuri='', repolocation=''):
succeeded = os.EX_OK
if reponame:
_hooks = self.hooks["repo.postsync.d"]
else:
_hooks = self.hooks["postsync.d"]
for filepath in _hooks:
writemsg_level("Spawning post_sync hook: %s\n"
% (_unicode_decode(_hooks[filepath])),
level=logging.ERROR, noiselevel=4)
if reponame:
retval = portage.process.spawn(
[filepath, reponame, dosyncuri, repolocation],
env=self.settings.environ())
else:
retval = portage.process.spawn([filepath],
env=self.settings.environ())
if retval != os.EX_OK:
def profile_check(trees, myaction):
if myaction in ("help", "info", "search", "sync", "version"):
return os.EX_OK
for root_trees in trees.values():
if (root_trees["root_config"].settings.profiles and
'ARCH' in root_trees["root_config"].settings):
continue
# generate some profile related warning messages
validate_ebuild_environment(trees)
msg = ("Your current profile is invalid. If you have just changed "
"your profile configuration, you should revert back to the "
"previous configuration. Allowed actions are limited to "
"--help, --info, --search, --sync, and --version.")
writemsg_level("".join("!!! %s\n" % l for l in textwrap.wrap(msg, 70)),
level=logging.ERROR, noiselevel=-1)
return 1
return os.EX_OK
prompt = "Would you like to remove these " + \
"packages from your world favorites?"
uq = UserQuery(opts)
if uq.query(prompt, enter_invalid) == 'No':
return 128 + signal.SIGINT
remaining = set(world_set)
remaining.difference_update(discard_atoms)
if not pretend:
world_set.replace(remaining)
else:
print(">>> No matching atoms found in \"world\" favorites file...")
finally:
if locked:
world_set.unlock()
return os.EX_OK