Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try:
error_msg = str(e)
except UnicodeDecodeError as uerror:
error_msg = str(uerror.object,
encoding='utf_8', errors='replace')
writemsg("!!! %s\n\n" % error_msg)
del e
pkgindex = None
if proc is not None:
if proc.poll() is None:
proc.kill()
proc.wait()
proc = None
if tmp_filename is not None:
try:
os.unlink(tmp_filename)
except OSError:
pass
if pkgindex is rmt_idx:
pkgindex.modified = False # don't update the header
pkgindex.header["DOWNLOAD_TIMESTAMP"] = "%d" % time.time()
try:
ensure_dirs(os.path.dirname(pkgindex_file))
f = atomic_ofstream(pkgindex_file)
pkgindex.write(f)
f.close()
except (IOError, PortageException):
if os.access(os.path.dirname(pkgindex_file), os.W_OK):
raise
# The current user doesn't have permission to cache the
# file, but that's alright.
if pkgindex:
def _calc_changelog(ebuildpath,current,next): # pylint: disable=redefined-builtin
if ebuildpath == None or not os.path.exists(ebuildpath):
return []
current = '-'.join(catpkgsplit(current)[1:])
if current.endswith('-r0'):
current = current[:-3]
next = '-'.join(catpkgsplit(next)[1:])
if next.endswith('-r0'):
next = next[:-3]
changelogdir = os.path.dirname(ebuildpath)
changelogs = ['ChangeLog']
# ChangeLog-YYYY (see bug #389611)
changelogs.extend(sorted((fn for fn in os.listdir(changelogdir)
if fn.startswith('ChangeLog-')), reverse=True))
divisions = []
found_current = False
for fn in changelogs:
changelogpath = os.path.join(changelogdir, fn)
try:
with io.open(_unicode_encode(changelogpath,
encoding=_encodings['fs'], errors='strict'),
mode='r', encoding=_encodings['repo.content'],
errors='replace') as f:
changelog = f.read()
except EnvironmentError:
return []
for node in _find_changelog_tags(changelog):
if node[0] == current:
def catdir_locked(catdir_lock):
if catdir_lock.wait() != os.EX_OK:
result.set_result(None)
else:
try:
os.rmdir(self._catdir)
except OSError:
pass
catdir_lock.async_unlock().add_done_callback(catdir_unlocked)
def writable(self):
"""
Check if PKGDIR is writable, or permissions are sufficient
to create it if it does not exist yet.
@rtype: bool
@return: True if PKGDIR is writable or can be created,
False otherwise
"""
return os.access(first_existing(self.bintree.pkgdir), os.W_OK)
def gpgsign(filename, repoman_settings, options):
gpgcmd = repoman_settings.get("PORTAGE_GPG_SIGNING_COMMAND")
if gpgcmd in [None, '']:
raise MissingParameter("PORTAGE_GPG_SIGNING_COMMAND is unset!"
" Is make.globals missing?")
if "${PORTAGE_GPG_KEY}" in gpgcmd and \
"PORTAGE_GPG_KEY" not in repoman_settings:
raise MissingParameter("PORTAGE_GPG_KEY is unset!")
if "${PORTAGE_GPG_DIR}" in gpgcmd:
if "PORTAGE_GPG_DIR" not in repoman_settings:
repoman_settings["PORTAGE_GPG_DIR"] = \
os.path.expanduser("~/.gnupg")
logging.info(
"Automatically setting PORTAGE_GPG_DIR to '%s'" %
repoman_settings["PORTAGE_GPG_DIR"])
else:
repoman_settings["PORTAGE_GPG_DIR"] = \
os.path.expanduser(repoman_settings["PORTAGE_GPG_DIR"])
if not os.access(repoman_settings["PORTAGE_GPG_DIR"], os.X_OK):
raise portage.exception.InvalidLocation(
"Unable to access directory: PORTAGE_GPG_DIR='%s'" %
repoman_settings["PORTAGE_GPG_DIR"])
gpgvars = {"FILE": filename}
for k in ("PORTAGE_GPG_DIR", "PORTAGE_GPG_KEY"):
v = repoman_settings.get(k)
if v is not None:
gpgvars[k] = v
gpgcmd = portage.util.varexpand(gpgcmd, mydict=gpgvars)
for filename in files:
try:
filename = _unicode_decode(filename,
encoding=_encodings['fs'], errors='strict')
except UnicodeDecodeError:
continue
if filename.startswith(".") or filename.endswith("~"):
continue
if filename.endswith(".metadata"):
continue
filename = os.path.join(parent,
filename)[1 + len(directory):]
myname = name_pattern.replace("$name", filename)
myname = myname.replace("${name}", filename)
rValue[myname] = StaticFileSet(
os.path.join(directory, filename),
greedy=greedy, dbapi=trees["vartree"].dbapi)
return rValue
multiBuilder = classmethod(multiBuilder)
def _locate_failure_log(self, failed_pkg):
log_paths = [failed_pkg.build_log]
for log_path in log_paths:
if not log_path:
continue
try:
log_size = os.stat(log_path).st_size
except OSError:
continue
if log_size == 0:
continue
return log_path
return None
if _disable:
return
mystr = _unicode_decode(mystr)
if short_msg is not None:
short_msg = _unicode_decode(short_msg)
if xterm_titles and short_msg:
if "HOSTNAME" in os.environ:
short_msg = os.environ["HOSTNAME"]+": "+short_msg
xtermTitle(short_msg)
try:
file_path = os.path.join(_emerge_log_dir, 'emerge.log')
existing_log = os.path.exists(file_path)
mylogfile = io.open(_unicode_encode(file_path,
encoding=_encodings['fs'], errors='strict'),
mode='a', encoding=_encodings['content'],
errors='backslashreplace')
if not existing_log:
portage.util.apply_secpass_permissions(file_path,
uid=portage.portage_uid, gid=portage.portage_gid,
mode=0o660)
mylock = portage.locks.lockfile(file_path)
try:
mylogfile.write("%.0f: %s\n" % (time.time(), mystr))
mylogfile.close()
finally:
portage.locks.unlockfile(mylock)
except (IOError,OSError,portage.exception.PortageException) as e:
if secpass >= 1:
path = self.config.get_option('overlay_defs') + '/reposconf.xml'
result = create_overlay_xml(overlay_package=overlay_package,
path=path)
if not result:
msg = '!!! layman add error in %(repo)s: Failed to add'\
'%(repo)s to %(path)s' % ({'repo': self.repo.name,
'path': path})
self.logger(self.xterm_titles, msg)
writemsg_level(msg + '\n', level=logging.ERROR, noiselevel=-1)
return (1, False)
results = layman_inst.add_repos(self.repo.name)
exitcode = self._eval_exitcode(results)
if exitcode != os.EX_OK:
msg = "!!! layman add error in %(repo)s"\
% ({'repo': self.repo.name})
self.logger(self.xterm_titles, msg)
writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
return (exitcode, False)
msg = ">>> Addition of layman repo succeeded: %(repo)s"\
% ({'repo': self.repo.name})
self.logger(self.xterm_titles, msg)
writemsg_level(msg + '\n')
msg = '>>> laymansync sez... "Hasta la add ya, baby!"'
self.logger(self.xterm_titles, msg)
writemsg_level(msg + '\n')
return (exitcode, True)