file = file.rstrip()
try:
contents = open(file, "r")
- except IOError, e:
+ except IOError as e:
print >> sys.stderr, 'archive-conf: Unable to open %s: %s' % (file, e)
sys.exit(1)
lines = contents.readlines()
print y
print
- except OSError, e:
+ except OSError as e:
if e.errno in (errno.ENOENT, errno.ENOTDIR):
print "!!! %s is not a directory or does not exist" % x
else:
continue
os.mkdir(mydir)
SCRATCH_DIR = mydir
- except OSError, e:
+ except OSError as e:
if e.errno != 17:
raise
os.umask(oldmask)
os.system((DIFF_CONTENTS % (curconf, newconf)) + '>>' + self.options["log-file"])
try:
os.rename(newconf, curconf)
- except (IOError, os.error), why:
+ except (IOError, os.error) as why:
print >> sys.stderr, 'dispatch-conf: Error renaming %s to %s: %s; fatal' % \
(newconf, curconf, str(why))
except KeyError:
# aux_get error
a = 1
- except UnsupportedAPIException, e:
+ except UnsupportedAPIException as e:
from textwrap import wrap
msg = wrap(str(e), 70)
del e
for x in msg:
portage.writemsg("!!! %s\n" % x, noiselevel=-1)
a = 1
- except PortagePackageException, e:
+ except PortagePackageException as e:
portage.writemsg("!!! %s\n" % (e,), noiselevel=-1)
a = 1
- except PermissionDenied, e:
+ except PermissionDenied as e:
portage.writemsg("!!! Permission Denied: %s\n" % (e,), noiselevel=-1)
a = 1
if a == None:
try:
try:
self._trg_cache[cpv] = metadata
- except StatCollision, sc:
+ except StatCollision as sc:
# If the content of a cache entry changes and neither the
# file mtime nor size changes, it will prevent rsync from
# detecting changes. Cache backends may raise this
max_mtime = long(max_mtime)
try:
os.utime(ebuild_path, (max_mtime, max_mtime))
- except OSError, e:
+ except OSError as e:
self.returncode |= 1
writemsg_level(
"%s writing target: %s\n" % (cpv, e),
self._trg_cache[cpv] = metadata
self._portdb.auxdb[repo_path][cpv] = metadata
- except CacheError, ce:
+ except CacheError as ce:
self.returncode |= 1
writemsg_level(
"%s writing target: %s\n" % (cpv, ce),
level=logging.ERROR, noiselevel=-1)
else:
dead_nodes.add(cpv)
- except CacheError, ce:
+ except CacheError as ce:
self.returncode |= 1
writemsg_level(
"Error listing cache entries for " + \
cp_missing.discard(cp)
if cp in cp_set:
dead_nodes.add(cpv)
- except CacheError, ce:
+ except CacheError as ce:
self.returncode |= 1
writemsg_level(
"Error listing cache entries for " + \
del trg_cache[k]
except KeyError:
pass
- except CacheError, ce:
+ except CacheError as ce:
self.returncode |= 1
writemsg_level(
"%s deleting stale cache: %s\n" % (k, ce),
if not trg_cache.autocommits:
try:
trg_cache.commit()
- except CacheError, ce:
+ except CacheError as ce:
self.returncode |= 1
writemsg_level(
"committing target: %s\n" % (ce,),
keyfile = open(mydir+os.sep+k, "w")
keyfile.write(s+"\n")
keyfile.close()
- except (IOError, OSError), e:
+ except (IOError, OSError) as e:
errors.append("Could not write %s, reason was: %s" % (mydir+k, e))
return errors
from portage.exception import ParseError, PermissionDenied
try:
retval = emerge_main()
- except PermissionDenied, e:
+ except PermissionDenied as e:
sys.stderr.write("Permission denied: '%s'\n" % str(e))
sys.exit(e.errno)
- except ParseError, e:
+ except ParseError as e:
sys.stderr.write("%s\n" % str(e))
sys.exit(1)
except SystemExit:
import portage
try:
portage.env_update(makelinks)
-except IOError, e:
+except IOError as e:
if e.errno == errno.EACCES:
print "env-update: Need superuser access"
sys.exit(1)
try:
os.nice(int(mysettings.get("PORTAGE_NICENESS", "0")))
-except (OSError, ValueError), e:
+except (OSError, ValueError) as e:
portage.writemsg("!!! Failed to change nice value to '%s'\n" % \
mysettings["PORTAGE_NICENESS"])
portage.writemsg("!!! %s\n" % str(e))
for x in todolist:
try:
myglsa = Glsa(x, portage.settings, vardb, portdb)
- except (GlsaTypeException, GlsaFormatException), e:
+ except (GlsaTypeException, GlsaFormatException) as e:
if verbose:
sys.stderr.write(("invalid GLSA: %s (error message was: %s)\n" % (x, e)))
continue
for myid in myglsalist:
try:
myglsa = Glsa(myid, portage.settings, vardb, portdb)
- except (GlsaTypeException, GlsaFormatException), e:
+ except (GlsaTypeException, GlsaFormatException) as e:
if verbose:
fd2.write(("invalid GLSA: %s (error message was: %s)\n" % (myid, e)))
continue
for myid in glsalist:
try:
myglsa = Glsa(myid, portage.settings, vardb, portdb)
- except (GlsaTypeException, GlsaFormatException), e:
+ except (GlsaTypeException, GlsaFormatException) as e:
if verbose:
sys.stderr.write(("invalid GLSA: %s (error message was: %s)\n" % (myid, e)))
continue
for myid in glsalist:
try:
myglsa = Glsa(myid, portage.settings, vardb, portdb)
- except (GlsaTypeException, GlsaFormatException), e:
+ except (GlsaTypeException, GlsaFormatException) as e:
if verbose:
sys.stderr.write(("invalid GLSA: %s (error message was: %s)\n" % (myid, e)))
continue
for myid in glsalist:
try:
myglsa = Glsa(myid, portage.settings, vardb, portdb)
- except (GlsaTypeException, GlsaFormatException), e:
+ except (GlsaTypeException, GlsaFormatException) as e:
if verbose:
sys.stderr.write(("invalid GLSA: %s (error message was: %s)\n" % (myid, e)))
continue
retval = function(args)
if retval:
sys.exit(retval)
- except portage.exception.PermissionDenied, e:
+ except portage.exception.PermissionDenied as e:
sys.stderr.write("Permission denied: '%s'\n" % str(e))
sys.exit(e.errno)
- except portage.exception.ParseError, e:
+ except portage.exception.ParseError as e:
sys.stderr.write("%s\n" % str(e))
sys.exit(1)
- except ValueError, e:
+ except ValueError as e:
if not e.args or \
not hasattr(e.args[0], "__len__") or \
len(e.args[0]) < 2:
for arg in args:
try:
atom = dep_expand(arg, mydb=vardb, settings=vartree.settings)
- except ValueError, e:
+ except ValueError as e:
# Multiple matches thrown from cpv_expand
eout.eerror("Please use a more specific atom: %s" % \
" ".join(e.args[0]))
try:
restrict = flatten(use_reduce(
paren_reduce(restrict), uselist=use))
- except InvalidDependString, e:
+ except InvalidDependString as e:
eout.eerror("Invalid RESTRICT metadata " + \
"for '%s': %s; skipping" % (cpv, str(e)))
del e
binpkg_path = bintree.getname(cpv)
try:
s = os.stat(binpkg_path)
- except OSError, e:
+ except OSError as e:
# Sanity check, shouldn't happen normally.
eout.eend(1)
eout.eerror(str(e))
except (portage.exception.InvalidAtom, KeyError):
if "--debug" in sys.argv:
print "* ignoring broken log entry for %s (likely injected)" % mykey
- except ValueError, e:
+ except ValueError as e:
print "* %s is an ambigous package name, candidates are:\n%s" % (mykey, e)
continue
if mylist:
else:
must_fetch=0
- except (OSError,IOError), e:
+ except (OSError,IOError) as e:
if e.errno != 2:
print red("!!!")+" caught exception '%s' for %s/metadata.dtd, bailing" % (str(e), portage.CACHE_PATH)
sys.exit(1)
try:
try:
os.unlink(metadata_dtd)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
del e
val=portage.fetch(['http://www.gentoo.org/dtd/metadata.dtd'],repoman_settings,fetchonly=0, \
try_mirrors=0)
- except SystemExit, e:
+ except SystemExit as e:
raise # Need to propogate this
- except Exception,e:
+ except Exception as e:
print
print red("!!!")+" attempting to fetch 'http://www.gentoo.org/dtd/metadata.dtd', caught"
print red("!!!")+" exception '%s' though." % str(e)
encoding=_encodings['fs'], errors='strict'),
mode='r', encoding=_encodings['repo.content']):
line +=1
- except UnicodeDecodeError, ue:
+ except UnicodeDecodeError as ue:
stats["file.UTF8"] += 1
s = ue.object[:ue.start]
l2 = s.count("\n")
for mykey in fetchlist_dict:
try:
myfiles_all.extend(fetchlist_dict[mykey])
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
src_uri_error = True
try:
portdb.aux_get(mykey, ["SRC_URI"])
full_path = os.path.join(repodir, relative_path)
try:
mystat = os.stat(full_path)
- except OSError, oe:
+ except OSError as oe:
if oe.errno == 2:
# don't worry about it. it likely was removed via fix above.
continue
f = open(os.path.join(checkdir, "metadata.xml"))
utilities.parse_metadata_use(f, muselist)
f.close()
- except (EnvironmentError, ParseError), e:
+ except (EnvironmentError, ParseError) as e:
metadata_bad = True
stats["metadata.bad"] += 1
fails["metadata.bad"].append("%s/metadata.xml: %s" % (x, e))
except ValueError:
badsyntax.append("parenthesis mismatch")
mydeplist = []
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
badsyntax.append(str(e))
del e
mydeplist = []
try:
portage.dep.use_reduce(mydeplist, matchall=1)
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
badsyntax.append(str(e))
for token in operator_tokens:
try:
myrestrict = portage.dep.use_reduce(
portage.dep.paren_reduce(myaux["RESTRICT"]), matchall=1)
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
stats["RESTRICT.syntax"] = stats["RESTRICT.syntax"] + 1
fails["RESTRICT.syntax"].append(
"%s: RESTRICT: %s" % (relative_path, e))
try:
myvcstree=portage.cvstree.getentries("./",recursive=1)
myunadded=portage.cvstree.findunadded(myvcstree,recursive=1,basedir="./")
- except SystemExit, e:
+ except SystemExit as e:
raise # TODO propogate this
except:
err("Error retrieving CVS tree; exiting.")
try:
svnstatus=os.popen("svn status --no-ignore").readlines()
myunadded = [ "./"+elem.rstrip().split()[1] for elem in svnstatus if elem.startswith("?") or elem.startswith("I") ]
- except SystemExit, e:
+ except SystemExit as e:
raise # TODO propogate this
except:
err("Error retrieving SVN info; exiting.")
commitmessage = f.read()
f.close()
del f
- except (IOError, OSError), e:
+ except (IOError, OSError) as e:
if e.errno == errno.ENOENT:
portage.writemsg("!!! File Not Found: --commitmsgfile='%s'\n" % options.commitmsgfile)
else:
if not os.path.isdir(repoman_settings["O"]):
continue
gpgsign(os.path.join(repoman_settings["O"], "Manifest"))
- except portage.exception.PortageException, e:
+ except portage.exception.PortageException as e:
portage.writemsg("!!! %s\n" % str(e))
portage.writemsg("!!! Disabled FEATURES='sign'\n")
signed = False
writemsg("!!! Fetching Binary failed " + \
"for '%s'\n" % pkg.cpv, noiselevel=-1)
rval = 1
- except portage.exception.DigestException, e:
+ except portage.exception.DigestException as e:
writemsg("\n!!! Digest verification failed:\n",
noiselevel=-1)
writemsg("!!! %s\n" % e.value[0],
self._cache_data = mypickle.load()
f.close()
del f
- except (IOError, OSError, EOFError, ValueError, pickle.UnpicklingError), e:
+ except (IOError, OSError, EOFError, ValueError, pickle.UnpicklingError) as e:
if isinstance(e, pickle.UnpicklingError):
writemsg("!!! Error loading '%s': %s\n" % \
(self._cache_filename, str(e)), noiselevel=-1)
f.close()
portage.util.apply_secpass_permissions(
self._cache_filename, gid=portage.portage_gid, mode=0644)
- except (IOError, OSError), e:
+ except (IOError, OSError) as e:
pass
self._modified.clear()
if catdir_lock:
try:
os.rmdir(catdir)
- except OSError, e:
+ except OSError as e:
if e.errno not in (errno.ENOENT,
errno.ENOTEMPTY, errno.EEXIST):
raise
from tempfile import mkdtemp
try:
private_tmpdir = mkdtemp("", "._portage_fetch_.", global_tmpdir)
- except OSError, e:
+ except OSError as e:
if e.errno != portage.exception.PermissionDenied.errno:
raise
raise portage.exception.PermissionDenied(global_tmpdir)
for mytree in portdb.porttrees:
try:
dead_nodes[mytree] = set(portdb.auxdb[mytree].iterkeys())
- except CacheError, e:
+ except CacheError as e:
portage.writemsg("Error listing cache entries for " + \
"'%s': %s, continuing...\n" % (mytree, e),
noiselevel=-1)
dead_nodes[mytree] = set(cpv for cpv in \
portdb.auxdb[mytree].iterkeys() \
if cpv_getkey(cpv) in cp_set)
- except CacheError, e:
+ except CacheError as e:
portage.writemsg("Error listing cache entries for " + \
"'%s': %s, continuing...\n" % (mytree, e),
noiselevel=-1)
elif k in self._use_conditional_keys:
try:
use_reduce(paren_reduce(v), matchall=1)
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
self._pkg._invalid_metadata(k + ".syntax", "%s: %s" % (k, e))
def __getitem__(self, k):
[self.pkg.cpv], self.ldpath_mtimes, clean_world=0,
clean_delay=0, raise_on_error=1, scheduler=self.scheduler,
writemsg_level=self._writemsg_level)
- except UninstallFailure, e:
+ except UninstallFailure as e:
self.returncode = e.status
else:
self.returncode = os.EX_OK
try:
self._poll_event_queue.extend(self._poll_obj.poll(timeout))
break
- except select.error, e:
+ except select.error as e:
writemsg_level("\n!!! select error: %s\n" % (e,),
level=logging.ERROR, noiselevel=-1)
del e
success, mydepgraph, dropped_tasks = resume_depgraph(
self.settings, self.trees, self._mtimedb, self.myopts,
myparams, self._spinner)
- except depgraph.UnsatisfiedResumeDep, exc:
+ except depgraph.UnsatisfiedResumeDep as exc:
# rename variable to avoid python-3.0 error:
# SyntaxError: can not delete variable 'e' referenced in nested
# scope
write_successful = True
files.stdout.flush()
break
- except IOError, e:
+ except IOError as e:
if e.errno != errno.EAGAIN:
raise
del e
try:
retval = os.waitpid(self.pid, os.WNOHANG)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ECHILD:
raise
del e
if self.isAlive():
try:
os.kill(self.pid, signal.SIGTERM)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ESRCH:
raise
del e
try:
wait_retval = os.waitpid(self.pid, 0)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ECHILD:
raise
del e
success, mydepgraph, dropped_tasks = resume_depgraph(
settings, trees, mtimedb, myopts, myparams, spinner)
except (portage.exception.PackageNotFound,
- depgraph.UnsatisfiedResumeDep), e:
+ depgraph.UnsatisfiedResumeDep) as e:
if isinstance(e, depgraph.UnsatisfiedResumeDep):
mydepgraph = e.depgraph
if show_spinner:
try:
success, mydepgraph, favorites = backtrack_depgraph(
settings, trees, myopts, myparams, myaction, myfiles, spinner)
- except portage.exception.PackageSetNotFound, e:
+ except portage.exception.PackageSetNotFound as e:
if show_spinner:
print "\b\b... done!"
root_config = trees[settings["ROOT"]]["root_config"]
print
try:
pkgs = trees[settings["ROOT"]]["vartree"].dbapi.match(myfiles[0])
- except portage.exception.AmbiguousPackageName, e:
+ except portage.exception.AmbiguousPackageName as e:
# Multiple matches thrown from cpv_expand
pkgs = e.args[0]
if len(pkgs) == 0:
if args_set.findAtomForPackage(pkg) is None:
world_temp_set.add("=" + pkg.cpv)
continue
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
show_invalid_depstring_notice(pkg,
pkg.metadata["PROVIDE"], str(e))
del e
if args_set.findAtomForPackage(pkg) is None:
world_temp_set.add("=" + pkg.cpv)
continue
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
show_invalid_depstring_notice(pkg,
pkg.metadata["PROVIDE"], str(e))
del e
tree_data.valid_nodes.add(cpv)
try:
src = tree_data.src_db[cpv]
- except KeyError, e:
+ except KeyError as e:
noise.missing_entry(cpv)
del e
continue
- except CacheError, ce:
+ except CacheError as ce:
noise.exception(cpv, ce)
del ce
continue
try:
inherited = src.get('INHERITED', '')
eclasses = src.get('_eclasses_')
- except CacheError, ce:
+ except CacheError as ce:
noise.exception(cpv, ce)
del ce
continue
try:
tree_data.dest_db[cpv] = src
- except CacheError, ce:
+ except CacheError as ce:
noise.exception(cpv, ce)
del ce
for tree_data in porttrees_data:
try:
dead_nodes = set(tree_data.dest_db.iterkeys())
- except CacheError, e:
+ except CacheError as e:
writemsg_level("Error listing cache entries for " + \
"'%s': %s, continuing...\n" % (tree_data.path, e),
level=logging.ERROR, noiselevel=-1)
portage.writemsg_stdout("Regenerating cache entries...\n")
try:
os.close(sys.stdin.fileno())
- except SystemExit, e:
+ except SystemExit as e:
raise # Needed else can't exit
except:
pass
for mysearch in myfiles:
try:
searchinstance.execute(mysearch)
- except re.error, comment:
+ except re.error as comment:
print "\n!!! Regular expression error in \"%s\": %s" % ( mysearch, comment )
sys.exit(1)
searchinstance.output()
try:
maxretries=int(settings["PORTAGE_RSYNC_RETRIES"])
- except SystemExit, e:
+ except SystemExit as e:
raise # Needed else can't exit
except:
maxretries=3 #default number of retries
ips.append(addrinfo[4][0])
from random import shuffle
shuffle(ips)
- except SystemExit, e:
+ except SystemExit as e:
raise # Needed else can't exit
- except Exception, e:
+ except Exception as e:
print "Notice:",str(e)
dosyncuri=syncuri
dosyncuri = syncuri.replace(
"//" + user_name + hostname + port + "/",
"//" + user_name + ips[0] + port + "/", 1)
- except SystemExit, e:
+ except SystemExit as e:
raise # Needed else can't exit
- except Exception, e:
+ except Exception as e:
print "Notice:",str(e)
dosyncuri=syncuri
os.unlink(tmpservertimestampfile)
except OSError:
pass
- except portage.exception.PortageException, e:
+ except portage.exception.PortageException as e:
# timed out
print e
del e
sys.exit(1)
try:
os.rmdir(myportdir)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
sys.stderr.write(
"!!! existing '%s' directory; exiting.\n" % myportdir)
try:
valid_atoms.append(
portage.dep_expand(x, mydb=vardb, settings=settings))
- except portage.exception.AmbiguousPackageName, e:
+ except portage.exception.AmbiguousPackageName as e:
msg = "The short ebuild name \"" + x + \
"\" is ambiguous. Please specify " + \
"one of the following " + \
CLEAN_DELAY = 5
try:
CLEAN_DELAY = int(settings.get("CLEAN_DELAY", str(CLEAN_DELAY)))
- except ValueError, e:
+ except ValueError as e:
portage.writemsg("!!! %s\n" % str(e), noiselevel=-1)
portage.writemsg("!!! Unable to parse integer: CLEAN_DELAY='%s'\n" % \
settings["CLEAN_DELAY"], noiselevel=-1)
try:
EMERGE_WARNING_DELAY = int(settings.get(
"EMERGE_WARNING_DELAY", str(EMERGE_WARNING_DELAY)))
- except ValueError, e:
+ except ValueError as e:
portage.writemsg("!!! %s\n" % str(e), noiselevel=-1)
portage.writemsg("!!! Unable to parse integer: EMERGE_WARNING_DELAY='%s'\n" % \
settings["EMERGE_WARNING_DELAY"], noiselevel=-1)
portage.writemsg("!!! PORTAGE_DEBUG must be either 0 or 1\n",
noiselevel=-1)
PORTAGE_DEBUG = 0
- except ValueError, e:
+ except ValueError as e:
portage.writemsg("!!! %s\n" % str(e), noiselevel=-1)
portage.writemsg("!!! Unable to parse integer: PORTAGE_DEBUG='%s'\n" %\
settings["PORTAGE_DEBUG"], noiselevel=-1)
try:
cache_db = settings.load_best_module("portdbapi.metadbmodule")(
portdir, "metadata/cache", portage.auxdbkeys[:], readonly=True)
- except CacheError, e:
+ except CacheError as e:
writemsg_level("!!! Unable to instantiate cache: %s\n" % (e,),
level=logging.ERROR, noiselevel=-1)
return 1
try:
ec_names = set(f[:-7] for f in os.listdir(ec_dir) \
if f.endswith(".eclass"))
- except OSError, e:
+ except OSError as e:
writemsg_level("!!! Unable to list eclasses: %s\n" % (e,),
level=logging.ERROR, noiselevel=-1)
return 1
writemsg_level("!!! Missing cache entry: %s\n" % (cpv,),
level=logging.ERROR, noiselevel=-1)
continue
- except CacheError, e:
+ except CacheError as e:
writemsg_level("!!! Unable to access cache entry: %s %s\n" % \
(cpv, e), level=logging.ERROR, noiselevel=-1)
continue
encoding=_encodings['fs'], errors='strict'),
mode='r', encoding=_encodings['repo.content'], errors='replace'
).read()
- except SystemExit, e:
+ except SystemExit as e:
raise # Needed else can't exit
except:
return []
if True:
try:
arg_atoms = list(self._iter_atoms_for_pkg(pkg))
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
if not pkg.installed:
show_invalid_depstring_notice(
pkg, pkg.metadata["PROVIDE"], str(e))
settings.unlock()
settings.setinst(pkg.cpv, pkg.metadata)
settings.lock()
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
show_invalid_depstring_notice(
pkg, pkg.metadata["PROVIDE"], str(e))
del e
dep_string = list(self._queue_disjunctive_deps(
pkg, dep_root, dep_priority, dep_string))
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
if pkg.installed:
del e
continue
allow_unsatisfied):
return 0
- except portage.exception.AmbiguousPackageName, e:
+ except portage.exception.AmbiguousPackageName as e:
pkgs = e.args[0]
portage.writemsg("\n\n!!! An atom in the dependencies " + \
"is not fully-qualified. Multiple matches:\n\n", noiselevel=-1)
selected_atoms = self._select_atoms(dep_root,
dep_string, myuse=pkg.use.enabled, parent=pkg,
strict=strict, priority=dep_priority)
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
show_invalid_depstring_notice(pkg, dep_string, str(e))
del e
if pkg.installed:
"dependencies for %s\n") % atom)
return 0, myfavorites
- except portage.exception.MissingSignature, e:
+ except portage.exception.MissingSignature as e:
portage.writemsg("\n\n!!! A missing gpg signature is preventing portage from calculating the\n")
portage.writemsg("!!! required dependencies. This is a security feature enabled by the admin\n")
portage.writemsg("!!! to aid in the detection of malicious intent.\n\n")
portage.writemsg("!!! THIS IS A POSSIBLE INDICATION OF TAMPERED FILES -- CHECK CAREFULLY.\n")
portage.writemsg("!!! Affected file: %s\n" % (e), noiselevel=-1)
return 0, myfavorites
- except portage.exception.InvalidSignature, e:
+ except portage.exception.InvalidSignature as e:
portage.writemsg("\n\n!!! An invalid gpg signature is preventing portage from calculating the\n")
portage.writemsg("!!! required dependencies. This is a security feature enabled by the admin\n")
portage.writemsg("!!! to aid in the detection of malicious intent.\n\n")
portage.writemsg("!!! THIS IS A POSSIBLE INDICATION OF TAMPERED FILES -- CHECK CAREFULLY.\n")
portage.writemsg("!!! Affected file: %s\n" % (e), noiselevel=-1)
return 0, myfavorites
- except SystemExit, e:
+ except SystemExit as e:
raise # Needed else can't exit
- except Exception, e:
+ except Exception as e:
print >> sys.stderr, "\n\n!!! Problem in '%s' dependencies." % atom
print >> sys.stderr, "!!!", str(e), getattr(e, "__module__", None)
raise
success, atoms = portage.dep_check(depstr,
final_db, pkgsettings, myuse=pkg.use.enabled,
trees=self._dynamic_config._graph_trees, myroot=myroot)
- except Exception, e:
+ except Exception as e:
if isinstance(e, SystemExit):
raise
# This is helpful, for example, if a ValueError
blocker = Blocker(atom=portage.dep.Atom(atom),
eapi=pkg.metadata["EAPI"], root=myroot)
self._dynamic_config._blocker_parents.add(blocker, pkg)
- except portage.exception.InvalidAtom, e:
+ except portage.exception.InvalidAtom as e:
depstr = " ".join(vardb.aux_get(pkg.cpv, dep_keys))
show_invalid_depstring_notice(
pkg, depstr, "Invalid Atom: %s" % (e,))
running_root, running_portage.metadata["RDEPEND"],
myuse=running_portage.use.enabled,
parent=running_portage, strict=False)
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
portage.writemsg("!!! Invalid RDEPEND in " + \
"'%svar/db/pkg/%s/RDEPEND': %s\n" % \
(running_root, running_portage.cpv, e), noiselevel=-1)
try:
runtime_dep_atoms = \
list(runtime_deps.iterAtomsForPackage(task))
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
portage.writemsg("!!! Invalid PROVIDE in " + \
"'%svar/db/pkg/%s/PROVIDE': %s\n" % \
(task.root, task.cpv, e), noiselevel=-1)
"system"].iterAtomsForPackage(task):
skip = True
break
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
portage.writemsg("!!! Invalid PROVIDE in " + \
"'%svar/db/pkg/%s/PROVIDE': %s\n" % \
(task.root, task.cpv, e), noiselevel=-1)
skip = True
self._dynamic_config._blocked_world_pkgs[inst_pkg] = atom
break
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
portage.writemsg("!!! Invalid PROVIDE in " + \
"'%svar/db/pkg/%s/PROVIDE': %s\n" % \
(task.root, task.cpv, e), noiselevel=-1)
try:
myfilesdict = portdb.getfetchsizes(pkg_key,
useflags=pkg_use, debug=self._frozen_config.edebug)
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
src_uri = portdb.aux_get(pkg_key, ["SRC_URI"])[0]
show_invalid_depstring_notice(x, src_uri, str(e))
del e
if "COLUMNWIDTH" in self._frozen_config.settings:
try:
mywidth = int(self._frozen_config.settings["COLUMNWIDTH"])
- except ValueError, e:
+ except ValueError as e:
portage.writemsg("!!! %s\n" % str(e), noiselevel=-1)
portage.writemsg(
"!!! Unable to parse COLUMNWIDTH='%s'\n" % \
if myfavkey in added_favorites:
continue
added_favorites.add(myfavkey)
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
writemsg("\n\n!!! '%s' has invalid PROVIDE: %s\n" % \
(pkg_key, str(e)), noiselevel=-1)
writemsg("!!! see '%s'\n\n" % os.path.join(
try:
success = mydepgraph._loadResumeCommand(mtimedb["resume"],
skip_masked=skip_masked)
- except depgraph.UnsatisfiedResumeDep, e:
+ except depgraph.UnsatisfiedResumeDep as e:
if not skip_unsatisfied:
raise
if mylock:
portage.locks.unlockfile(mylock)
mylogfile.close()
- except (IOError,OSError,portage.exception.PortageException), e:
+ except (IOError,OSError,portage.exception.PortageException) as e:
if secpass >= 1:
print >> sys.stderr, "emergelog():",e
try:
os.rename(dir_file + ext, dir_file + ext + ".old")
moved_old_dir = True
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
del e
for ext in dir_extensions:
try:
os.rename(dir_file + ext + ".old", dir_file + ext)
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
del e
for ext in dir_extensions:
try:
os.unlink(dir_file + ext + ".old")
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
del e
try:
linkmap.rebuild()
- except portage.exception.CommandNotFound, e:
+ except portage.exception.CommandNotFound as e:
writemsg_level("!!! Command Not Found: %s\n" % (e,),
level=logging.ERROR, noiselevel=-1)
del e
def nice(settings):
try:
os.nice(int(settings.get("PORTAGE_NICENESS", "0")))
- except (OSError, ValueError), e:
+ except (OSError, ValueError) as e:
out = portage.output.EOutput()
out.eerror("Failed to change nice value to '%s'" % \
settings["PORTAGE_NICENESS"])
setconfig.active.append(s)
try:
set_atoms = setconfig.getSetAtoms(s)
- except portage.exception.PackageSetNotFound, e:
+ except portage.exception.PackageSetNotFound as e:
writemsg_level(("emerge: the given set '%s' " + \
"contains a non-existent set named '%s'.\n") % \
(s, e), level=logging.ERROR, noiselevel=-1)
try:
# At least the parent needs to exist for the lock file.
portage.util.ensure_dirs(settings['EMERGE_LOG_DIR'])
- except portage.exception.PortageException, e:
+ except portage.exception.PortageException as e:
writemsg_level("!!! Error creating directory for " + \
"EMERGE_LOG_DIR='%s':\n!!! %s\n" % \
(settings['EMERGE_LOG_DIR'], e),
try:
valid_atoms.append(
portage.dep_expand(x, mydb=vardb, settings=settings))
- except portage.exception.AmbiguousPackageName, e:
+ except portage.exception.AmbiguousPackageName as e:
msg = "The short ebuild name \"" + x + \
"\" is ambiguous. Please specify " + \
"one of the following " + \
pkgdir, self.settings["DISTDIR"])
try:
uri_map = self.portdb.getFetchMap(mycpv)
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
file_size_str = "Unknown (%s)" % (e,)
del e
else:
try:
mysum[0] = mf.getDistfilesSize(uri_map)
- except KeyError, e:
+ except KeyError as e:
file_size_str = "Unknown (missing " + \
"digest for %s)" % (e,)
del e
# what will and will not get unmerged
try:
mymatch = vartree.dbapi.match(x)
- except portage.exception.AmbiguousPackageName, errpkgs:
+ except portage.exception.AmbiguousPackageName as errpkgs:
print "\n\n!!! The short ebuild name \"" + \
x + "\" is ambiguous. Please specify"
print "!!! one of the following fully-qualified " + \
import shutil
del shutil
-except ImportError, e:
+except ImportError as e:
sys.stderr.write("\n\n")
sys.stderr.write("!!! Failed to complete python imports. These are internal modules for\n")
sys.stderr.write("!!! python and failure here indicates that you have a problem with python\n")
from portage.localization import _
-except ImportError, e:
+except ImportError as e:
sys.stderr.write("\n\n")
sys.stderr.write("!!! Failed to complete portage imports. There are internal modules for\n")
sys.stderr.write("!!! portage and failure here indicates that you have a problem with your\n")
encoding=_encodings['fs'])
_selinux_merge = _unicode_module_wrapper(_selinux,
encoding=_encodings['merge'])
-except OSError, e:
+except OSError as e:
sys.stderr.write("!!! SELinux not loaded: %s\n" % str(e))
del e
except ImportError:
mtime = pathstat.st_mtime
else:
raise portage.exception.DirectoryNotFound(mypath)
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno == portage.exception.PermissionDenied.errno:
raise portage.exception.PermissionDenied(mypath)
del e
cacheStale += 1
try:
list = os.listdir(mypath)
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno != errno.EACCES:
raise
del e
file_path = os.path.join(envd_dir, x)
try:
myconfig = getconfig(file_path, expand=False)
- except portage.exception.ParseError, e:
+ except portage.exception.ParseError as e:
writemsg("!!! '%s'\n" % str(e), noiselevel=-1)
del e
continue
if x[0]=="#":
continue
oldld.append(x[:-1])
- except (IOError, OSError), e:
+ except (IOError, OSError) as e:
if e.errno != errno.ENOENT:
raise
oldld = None
try:
newldpathtime = long(os.stat(x).st_mtime)
lib_dirs.add(normalize_path(x))
- except OSError, oe:
+ except OSError as oe:
if oe.errno == errno.ENOENT:
try:
del prev_mtimes[x]
f = codecs.open(_unicode_encode(pathname,
encoding=_encodings['fs'], errors='strict'), mode='r',
encoding=_encodings['content'], errors='replace')
- except OSError, details:
+ except OSError as details:
return (None, str(details))
- except IOError, details:
+ except IOError as details:
return (None, str(details))
try:
for i in range(4):
lines.append(f.readline())
- except OSError, details:
+ except OSError as details:
return (None, str(details))
- except IOError, details:
+ except IOError as details:
return (None, str(details))
lines = [l.strip() for l in lines]
self.profiles.append(currentPath)
try:
addProfile(os.path.realpath(self.profile_path))
- except portage.exception.ParseError, e:
+ except portage.exception.ParseError as e:
writemsg(_("!!! Unable to parse profile: '%s'\n") % \
self.profile_path, noiselevel=-1)
writemsg("!!! ParseError: %s\n" % str(e), noiselevel=-1)
encoding=_encodings['fs'], errors='strict'),
mode='r', encoding=_encodings['content'], errors='replace')
)
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
del e
- except ParsingError, e:
+ except ParsingError as e:
portage.util.writemsg_level(
_("!!! Error parsing '%s': %s\n") % \
(self._local_repo_conf_path, e),
continue
try:
portage.util.ensure_dirs(mydir, gid=gid, mode=mode, mask=modemask)
- except portage.exception.PortageException, e:
+ except portage.exception.PortageException as e:
writemsg(_("!!! Directory initialization failed: '%s'\n") % mydir,
noiselevel=-1)
writemsg("!!! %s\n" % str(e),
elif len(accept_chost) == 1:
try:
self._accept_chost_re = re.compile(r'^%s$' % accept_chost[0])
- except re.error, e:
+ except re.error as e:
writemsg(_("!!! Invalid ACCEPT_CHOSTS value: '%s': %s\n") % \
(accept_chost[0], e), noiselevel=-1)
self._accept_chost_re = re.compile("^$")
try:
self._accept_chost_re = re.compile(
r'^(%s)$' % "|".join(accept_chost))
- except re.error, e:
+ except re.error as e:
writemsg(_("!!! Invalid ACCEPT_CHOSTS value: '%s': %s\n") % \
(" ".join(accept_chost), e), noiselevel=-1)
self._accept_chost_re = re.compile("^$")
try:
master_fd, slave_fd = openpty()
got_pty = True
- except EnvironmentError, e:
+ except EnvironmentError as e:
_disable_openpty = True
writemsg("openpty failed: '%s'\n" % str(e),
noiselevel=-1)
filemode=filemode, filemask=modemask, onerror=onerror):
raise portage.exception.OperationNotPermitted(
_("Failed to apply recursive permissions for the portage group."))
- except portage.exception.PortageException, e:
+ except portage.exception.PortageException as e:
if not os.path.isdir(mysettings["DISTDIR"]):
writemsg("!!! %s\n" % str(e), noiselevel=-1)
writemsg(_("!!! Directory Not Found: DISTDIR='%s'\n") % mysettings["DISTDIR"], noiselevel=-1)
vfs_stat = os.statvfs(mysettings["DISTDIR"])
try:
mysize = os.stat(myfile_path).st_size
- except OSError, e:
+ except OSError as e:
if e.errno not in (errno.ENOENT, errno.ESTALE):
raise
del e
apply_secpass_permissions(myfile_path,
gid=portage_gid, mode=0664, mask=02,
stat_cached=mystat)
- except portage.exception.PortageException, e:
+ except portage.exception.PortageException as e:
if not os.access(myfile_path, os.R_OK):
writemsg(_("!!! Failed to adjust permissions:"
" %s\n") % str(e), noiselevel=-1)
if readonly_file is not None:
try:
os.unlink(myfile_path)
- except OSError, e:
+ except OSError as e:
if e.errno not in (errno.ENOENT, errno.ESTALE):
raise
del e
shutil.copyfile(mirror_file, myfile_path)
writemsg(_("Local mirror has file: %s\n") % myfile)
break
- except (IOError, OSError), e:
+ except (IOError, OSError) as e:
if e.errno not in (errno.ENOENT, errno.ESTALE):
raise
del e
try:
mystat = os.stat(myfile_path)
- except OSError, e:
+ except OSError as e:
if e.errno not in (errno.ENOENT, errno.ESTALE):
raise
del e
apply_secpass_permissions(
myfile_path, gid=portage_gid, mode=0664, mask=02,
stat_cached=mystat)
- except portage.exception.PortageException, e:
+ except portage.exception.PortageException as e:
if not os.access(myfile_path, os.R_OK):
writemsg(_("!!! Failed to adjust permissions:"
" %s\n") % str(e), noiselevel=-1)
if fetched != 2:
try:
mysize = os.stat(myfile_path).st_size
- except OSError, e:
+ except OSError as e:
if e.errno not in (errno.ENOENT, errno.ESTALE):
raise
del e
if fetched == 1:
try:
mystat = os.stat(myfile_path)
- except OSError, e:
+ except OSError as e:
if e.errno not in (errno.ENOENT, errno.ESTALE):
raise
del e
"ME_MIN_SIZE)\n") % mystat.st_size)
try:
os.unlink(myfile_path)
- except OSError, e:
+ except OSError as e:
if e.errno not in \
(errno.ENOENT, errno.ESTALE):
raise
try:
apply_secpass_permissions(myfile_path,
gid=portage_gid, mode=0664, mask=02)
- except portage.exception.FileNotFound, e:
+ except portage.exception.FileNotFound as e:
pass
- except portage.exception.PortageException, e:
+ except portage.exception.PortageException as e:
if not os.access(myfile_path, os.R_OK):
writemsg(_("!!! Failed to adjust permissions:"
" %s\n") % str(e), noiselevel=-1)
if mydigests is not None and myfile in mydigests:
try:
mystat = os.stat(myfile_path)
- except OSError, e:
+ except OSError as e:
if e.errno not in (errno.ENOENT, errno.ESTALE):
raise
del e
try:
private_tmpdir = mkdtemp("", "._portage_fetch_.",
global_tmpdir)
- except OSError, e:
+ except OSError as e:
if e.errno != portage.exception.PermissionDenied.errno:
raise
raise portage.exception.PermissionDenied(global_tmpdir)
try:
for myfile in fetchlist_dict[cpv]:
distfiles_map.setdefault(myfile, []).append(cpv)
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
writemsg("!!! %s\n" % str(e), noiselevel=-1)
del e
return 0
try:
st = os.stat(os.path.join(mysettings["DISTDIR"], myfile))
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
del e
assumeDistHashesSometimes=True,
assumeDistHashesAlways=(
"assume-digests" in mysettings.features))
- except portage.exception.FileNotFound, e:
+ except portage.exception.FileNotFound as e:
writemsg(_("!!! File %s doesn't exist, can't update "
"Manifest\n") % e, noiselevel=-1)
return 0
- except portage.exception.PortagePackageException, e:
+ except portage.exception.PortagePackageException as e:
writemsg(("!!! %s\n") % (e,), noiselevel=-1)
return 0
try:
mf.write(sign=False)
- except portage.exception.PermissionDenied, e:
+ except portage.exception.PermissionDenied as e:
writemsg(_("!!! Permission Denied: %s\n") % (e,), noiselevel=-1)
return 0
if "assume-digests" not in mysettings.features:
raise KeyError(f)
mf.checkFileHashes(ftype, f)
eout.eend(0)
- except KeyError, e:
+ except KeyError as e:
eout.eend(1)
writemsg(_("\n!!! Missing digest for %s\n") % str(e), noiselevel=-1)
return 0
- except portage.exception.FileNotFound, e:
+ except portage.exception.FileNotFound as e:
eout.eend(1)
writemsg(_("\n!!! A file listed in the Manifest could not be found: %s\n") % str(e),
noiselevel=-1)
return 0
- except portage.exception.DigestException, e:
+ except portage.exception.DigestException as e:
eout.eend(1)
writemsg(_("\n!!! Digest verification failed:\n"), noiselevel=-1)
writemsg("!!! %s\n" % e.value[0], noiselevel=-1)
for clean_dir in clean_dirs:
try:
shutil.rmtree(clean_dir)
- except OSError, oe:
+ except OSError as oe:
if errno.ENOENT == oe.errno:
pass
elif errno.EPERM == oe.errno:
def makedirs(dir_path):
try:
os.makedirs(dir_path)
- except OSError, oe:
+ except OSError as oe:
if errno.EEXIST == oe.errno:
pass
elif errno.EPERM == oe.errno:
portage.util.ensure_dirs(mysettings[dir_key], mode=0775)
portage.util.apply_secpass_permissions(mysettings[dir_key],
uid=portage_uid, gid=portage_gid)
- except portage.exception.PermissionDenied, e:
+ except portage.exception.PermissionDenied as e:
writemsg(_("Permission Denied: %s\n") % str(e), noiselevel=-1)
return 1
- except portage.exception.OperationNotPermitted, e:
+ except portage.exception.OperationNotPermitted as e:
writemsg(_("Operation Not Permitted: %s\n") % str(e), noiselevel=-1)
return 1
- except portage.exception.FileNotFound, e:
+ except portage.exception.FileNotFound as e:
writemsg(_("File Not Found: '%s'\n") % str(e), noiselevel=-1)
return 1
raise portage.exception.OperationNotPermitted(
_("Failed to apply recursive permissions for the portage group."))
- except portage.exception.DirectoryNotFound, e:
+ except portage.exception.DirectoryNotFound as e:
failure = True
writemsg(_("\n!!! Directory does not exist: '%s'\n") % \
(e,), noiselevel=-1)
writemsg(_("!!! Disabled FEATURES='%s'\n") % myfeature,
noiselevel=-1)
- except portage.exception.PortageException, e:
+ except portage.exception.PortageException as e:
failure = True
writemsg("\n!!! %s\n" % str(e), noiselevel=-1)
writemsg(_("!!! Failed resetting perms on %s='%s'\n") % \
raise ValueError("Invalid file mode: %s" % mode)
else:
workdir_mode = parsed_mode
- except KeyError, e:
+ except KeyError as e:
writemsg(_("!!! PORTAGE_WORKDIR_MODE is unset, using %s.\n") % oct(workdir_mode))
- except ValueError, e:
+ except ValueError as e:
if len(str(e)) > 0:
writemsg("%s\n" % e)
writemsg(_("!!! Unable to parse PORTAGE_WORKDIR_MODE='%s', using %s.\n") % \
if modified:
apply_secpass_permissions(mysettings["PORT_LOGDIR"],
uid=portage_uid, gid=portage_gid, mode=02770)
- except portage.exception.PortageException, e:
+ except portage.exception.PortageException as e:
writemsg("!!! %s\n" % str(e), noiselevel=-1)
writemsg(_("!!! Permission issues with PORT_LOGDIR='%s'\n") % \
mysettings["PORT_LOGDIR"], noiselevel=-1)
"could not be found: '%s'") % (myebuild,))
_doebuild_broken_ebuilds.add(myebuild)
return 1
- except portage.exception.DigestException, e:
+ except portage.exception.DigestException as e:
out = portage.output.EOutput()
out.eerror(_("Digest verification failed:"))
out.eerror("%s" % e.value[0])
saved_env = None
try:
env_stat = os.stat(env_file)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
del e
_shell_quote(env_file)))
try:
env_stat = os.stat(env_file)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
del e
saved_env, noiselevel=-1)
try:
os.unlink(env_file)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
del e
alist = mydbapi.getFetchMap(mycpv, useflags=useflags,
mytree=mytree)
aalist = mydbapi.getFetchMap(mycpv, mytree=mytree)
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
writemsg("!!! %s\n" % str(e), noiselevel=-1)
writemsg(_("!!! Invalid SRC_URI for '%s'.\n") % mycpv,
noiselevel=-1)
# for fetch (especially parallel-fetch) since it's not needed
# and it can interfere with parallel tasks.
digestgen(aalist, mysettings, overwrite=0, myportdb=mydbapi)
- except portage.exception.PermissionDenied, e:
+ except portage.exception.PermissionDenied as e:
writemsg(_("!!! Permission Denied: %s\n") % (e,), noiselevel=-1)
if mydo in ("digest", "manifest"):
return 1
try:
portage.dep.use_reduce(
portage.dep.paren_reduce(metadata[k]), matchall=True)
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
msgs.append(" %s: %s\n %s\n" % (
k, metadata[k], str(e)))
if not sstat:
sstat=os.lstat(src)
- except SystemExit, e:
+ except SystemExit as e:
raise
- except Exception, e:
+ except Exception as e:
print _("!!! Stating source file failed... movefile()")
print "!!!",e
return None
try:
os.unlink(dest)
destexists=0
- except SystemExit, e:
+ except SystemExit as e:
raise
- except Exception, e:
+ except Exception as e:
pass
if stat.S_ISLNK(sstat[stat.ST_MODE]):
# utime() only works on the target of a symlink, so it's not
# possible to perserve mtime on symlinks.
return os.lstat(dest)[stat.ST_MTIME]
- except SystemExit, e:
+ except SystemExit as e:
raise
- except Exception, e:
+ except Exception as e:
print _("!!! failed to properly create symlink:")
print "!!!",dest,"->",target
print "!!!",e
(tail, os.getpid()))
try:
os.unlink(hardlink_tmp)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
writemsg(_("!!! Failed to remove hardlink temp file: %s\n") % \
(hardlink_tmp,), noiselevel=-1)
else:
try:
os.rename(hardlink_tmp, dest)
- except OSError, e:
+ except OSError as e:
writemsg(_("!!! Failed to rename %s to %s\n") % \
(hardlink_tmp, dest), noiselevel=-1)
writemsg("!!! %s\n" % (e,), noiselevel=-1)
else:
ret=os.rename(src,dest)
renamefailed=0
- except SystemExit, e:
+ except SystemExit as e:
raise
- except Exception, e:
+ except Exception as e:
if e[0]!=errno.EXDEV:
# Some random error.
print _("!!! Failed to move %(src)s to %(dest)s") % {"src": src, "dest": dest}
shutil.copyfile(src,dest+"#new")
os.rename(dest+"#new",dest)
didcopy=1
- except SystemExit, e:
+ except SystemExit as e:
raise
- except Exception, e:
+ except Exception as e:
print _('!!! copy %(src)s -> %(dest)s failed.') % {"src": src, "dest": dest}
print "!!!",e
return None
os.chown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID])
os.chmod(dest, stat.S_IMODE(sstat[stat.ST_MODE])) # Sticky is reset on chown
os.unlink(src)
- except SystemExit, e:
+ except SystemExit as e:
raise
- except Exception, e:
+ except Exception as e:
print _("!!! Failed to chown/chmod/unlink in movefile()")
print "!!!",dest
print "!!!",e
# Instead of failing, use stat to return the mtime if possible.
try:
newmtime = long(os.stat(dest).st_mtime)
- except OSError, e:
+ except OSError as e:
writemsg(_("!!! Failed to stat in movefile()\n"), noiselevel=-1)
writemsg("!!! %s\n" % dest, noiselevel=-1)
writemsg("!!! %s\n" % str(e), noiselevel=-1)
#convert parenthesis to sublists
try:
mysplit = portage.dep.paren_reduce(depstring)
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
return [0, str(e)]
mymasks = set()
try:
mysplit = portage.dep.use_reduce(mysplit, uselist=myusesplit,
masklist=mymasks, matchall=(use=="all"), excludeall=useforce)
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
return [0, str(e)]
# Do the || conversions
use=use, mode=mode, myuse=myuse,
use_force=useforce, use_mask=mymasks, use_cache=use_cache,
use_binaries=use_binaries, myroot=myroot, trees=trees)
- except portage.exception.ParseError, e:
+ except portage.exception.ParseError as e:
return [0, str(e)]
mysplit2=mysplit[:]
try:
selected_atoms = dep_zapdeps(mysplit, mysplit2, myroot,
use_binaries=use_binaries, trees=trees)
- except portage.exception.InvalidAtom, e:
+ except portage.exception.InvalidAtom as e:
if portage.dep._dep_check_strict:
raise # This shouldn't happen.
# dbapi.match() failed due to an invalid atom in
msg = license_split[:]
msg.append("license(s)")
rValue.append(" ".join(msg))
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
rValue.append("LICENSE: "+str(e))
try:
msg = properties_split[:]
msg.append("properties")
rValue.append(" ".join(msg))
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
rValue.append("PROPERTIES: "+str(e))
# Only show KEYWORDS masks for installed packages
uid=portage_uid, gid=portage_gid, mode=070, mask=0)
try:
shutil.rmtree(builddir)
- except (IOError, OSError), e:
+ except (IOError, OSError) as e:
if e.errno != errno.ENOENT:
raise
del e
try:
if success:
shutil.rmtree(builddir)
- except (IOError, OSError), e:
+ except (IOError, OSError) as e:
if e.errno != errno.ENOENT:
raise
del e
f.close()
portage.util.apply_secpass_permissions(filename,
uid=uid, gid=portage_gid, mode=0644)
- except (IOError, OSError), e:
+ except (IOError, OSError) as e:
pass
def portageexit():
d = mypickle.load()
f.close()
del f
- except (IOError, OSError, EOFError, ValueError, pickle.UnpicklingError), e:
+ except (IOError, OSError, EOFError, ValueError, pickle.UnpicklingError) as e:
if isinstance(e, pickle.UnpicklingError):
writemsg(_("!!! Error loading '%s': %s\n") % \
(filename, str(e)), noiselevel=-1)
try:
self._ensure_dirs()
self._ensure_dirs(self._db_path)
- except (OSError, IOError), e:
+ except (OSError, IOError) as e:
raise cache_errors.InitializationError(self.__class__, e)
# try again if failed
if self.__db == None:
self.__db = anydbm_module.open(
_unicode_encode(self._db_path), 'c', self._perms)
- except anydbm_module.error, e:
+ except anydbm_module.error as e:
raise cache_errors.InitializationError(self.__class__, e)
self._ensure_access(self._db_path)
path = os.path.join(self.portdir,'profiles/repo_name')
try:
return int(self.__get(path,'value_max_len'))
- except NoValueException,e:
+ except NoValueException as e:
max = self.__calc_max(path)
self.__set(path,'value_max_len',str(max))
return max
while True:
self.__set(path,'test_max',s)
s+=hundred
- except IOError,e:
+ except IOError as e:
# ext based give wrong errno
# http://bugzilla.kernel.org/show_bug.cgi?id=12793
if e.errno in (E2BIG,ENOSPC):
try:
self.__remove(path,'test_max')
- except IOError,e:
+ except IOError as e:
if e.errno is not ENODATA:
raise e
def __has_cache(self,path):
try:
self.__get(path,'_mtime_')
- except NoValueException,e:
+ except NoValueException as e:
return False
return True
def __get(self,path,key,default=None):
try:
return xattr.get(path,key,namespace=self.ns)
- except IOError,e:
+ except IOError as e:
if not default is None and ENODATA == e.errno:
return default
else:
return d
finally:
myf.close()
- except (IOError, OSError), e:
+ except (IOError, OSError) as e:
if e.errno != errno.ENOENT:
raise cache_errors.CacheCorruption(cpv, e)
raise KeyError(cpv)
def _parse_data(self, data, cpv):
try:
d = dict(map(lambda x:x.rstrip("\n").split("=", 1), data))
- except ValueError, e:
+ except ValueError as e:
# If a line is missing an "=", the split length is 1 instead of 2.
raise cache_errors.CacheCorruption(cpv, e)
return d
encoding=_encodings['fs'], errors='strict'),
mode='w', encoding=_encodings['repo.content'],
errors='backslashreplace')
- except (IOError, OSError), e:
+ except (IOError, OSError) as e:
if errno.ENOENT == e.errno:
try:
self._ensure_dirs(cpv)
encoding=_encodings['fs'], errors='strict'),
mode='w', encoding=_encodings['repo.content'],
errors='backslashreplace')
- except (OSError, IOError),e:
+ except (OSError, IOError) as e:
raise cache_errors.CacheCorruption(cpv, e)
else:
raise cache_errors.CacheCorruption(cpv, e)
new_fp = os.path.join(self.location,cpv)
try:
os.rename(fp, new_fp)
- except (OSError, IOError), e:
+ except (OSError, IOError) as e:
os.remove(fp)
raise cache_errors.CacheCorruption(cpv, e)
# import pdb;pdb.set_trace()
try:
os.remove(os.path.join(self.location,cpv))
- except OSError, e:
+ except OSError as e:
if errno.ENOENT == e.errno:
raise KeyError(cpv)
else:
while len(dirs):
try:
dir_list = os.listdir(dirs[0])
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
del e
errors='replace')
for k,v in zip(self.auxdbkey_order, myf):
d[k] = v.rstrip("\n")
- except (OSError, IOError),e:
+ except (OSError, IOError) as e:
if errno.ENOENT == e.errno:
raise KeyError(cpv)
raise cache_errors.CacheCorruption(cpv, e)
try:
d["_mtime_"] = long(os.fstat(myf.fileno()).st_mtime)
- except OSError, e:
+ except OSError as e:
myf.close()
raise cache_errors.CacheCorruption(cpv, e)
myf.close()
encoding=_encodings['fs'], errors='strict'),
mode='w', encoding=_encodings['repo.content'],
errors='backslashreplace')
- except (OSError, IOError), e:
+ except (OSError, IOError) as e:
if errno.ENOENT == e.errno:
try:
self._ensure_dirs(cpv)
encoding=_encodings['fs'], errors='strict'),
mode='w', encoding=_encodings['repo.content'],
errors='backslashreplace')
- except (OSError, IOError),e:
+ except (OSError, IOError) as e:
raise cache_errors.CacheCorruption(cpv, e)
else:
raise cache_errors.CacheCorruption(cpv, e)
new_fp = os.path.join(self._base,cpv)
try:
os.rename(fp, new_fp)
- except (OSError, IOError), e:
+ except (OSError, IOError) as e:
os.remove(fp)
raise cache_errors.CacheCorruption(cpv, e)
def _delitem(self, cpv):
try:
os.remove(os.path.join(self._base,cpv))
- except OSError, e:
+ except OSError as e:
if errno.ENOENT == e.errno:
raise KeyError(cpv)
else:
try:
d["_eclasses_"] = self.ec.get_eclass_data(
d["INHERITED"].split())
- except KeyError, e:
+ except KeyError as e:
# INHERITED contains a non-existent eclass.
raise cache_errors.CacheCorruption(cpv, e)
del d["INHERITED"]
try:
myf = open(_unicode_encode(fp,
encoding=_encodings['fs'], errors='strict'), 'wb')
- except EnvironmentError, e:
+ except EnvironmentError as e:
if errno.ENOENT == e.errno:
try:
self._ensure_dirs(cpv)
myf = open(_unicode_encode(fp,
encoding=_encodings['fs'], errors='strict'), 'wb')
- except EnvironmentError, e:
+ except EnvironmentError as e:
raise cache_errors.CacheCorruption(cpv, e)
else:
raise cache_errors.CacheCorruption(cpv, e)
try:
os.rename(fp, new_fp)
- except EnvironmentError, e:
+ except EnvironmentError as e:
try:
os.unlink(fp)
except EnvironmentError:
self.SCHEMA_PACKAGE_NAME)
try:
self.con.execute(self.SCHEMA_PACKAGE_CREATE)
- except self._BaseError, e:
+ except self._BaseError as e:
raise cache_errors.InitializationError(self.__class__, e)
if not self._table_exists(self.SCHEMA_VALUES_NAME):
self.SCHEMA_VALUES_NAME)
try:
self.con.execute(self.SCHEMA_VALUES_CREATE)
- except self._BaseError, e:
+ except self._BaseError as e:
raise cache_errors.InitializationError(self.__class__, e)
self.con.execute("SELECT key, value FROM %s NATURAL JOIN %s "
"WHERE label=%s AND cpv=%s" % (self.SCHEMA_PACKAGE_NAME, self.SCHEMA_VALUES_NAME,
self.label, self._sfilter(cpv)))
- except self._BaseError, e:
+ except self._BaseError as e:
raise cache_errors.CacheCorruption(self, cpv, e)
rows = self.con.fetchall()
(self.SCHEMA_PACKAGE_NAME, self.label, self._sfilter(cpv)))
if self.autocommits:
self.commit()
- except self._BaseError, e:
+ except self._BaseError as e:
raise cache_errors.CacheCorruption(self, cpv, e)
if self.con.rowcount <= 0:
raise KeyError(cpv)
# insert.
try:
pkgid = self._insert_cpv(cpv)
- except self._BaseError, e:
+ except self._BaseError as e:
raise cache_errors.CacheCorruption(cpv, e)
# __getitem__ fills out missing values,
try:
self.con.executemany("INSERT INTO %s (pkgid, key, value) VALUES(\"%s\", %%(key)s, %%(value)s)" % \
(self.SCHEMA_VALUES_NAME, str(pkgid)), db_values)
- except self._BaseError, e:
+ except self._BaseError as e:
raise cache_errors.CacheCorruption(cpv, e)
if self.autocommits:
self.commit()
if not self.autocommits:
try:
self.commit()
- except self._BaseError, e:
+ except self._BaseError as e:
raise cache_errors.GeneralCacheCorruption(e)
try:
self.con.execute("SELECT cpv FROM %s WHERE label=%s AND cpv=%s" % \
(self.SCHEMA_PACKAGE_NAME, self.label, self._sfilter(cpv)))
- except self._BaseError, e:
+ except self._BaseError as e:
raise cache_errors.GeneralCacheCorruption(e)
return self.con.rowcount > 0
if not self.autocommits:
try:
self.commit()
- except self._BaseError, e:
+ except self._BaseError as e:
raise cache_errors.GeneralCacheCorruption(e)
try:
self.con.execute("SELECT cpv FROM %s WHERE label=%s" %
(self.SCHEMA_PACKAGE_NAME, self.label))
- except self._BaseError, e:
+ except self._BaseError as e:
raise cache_errors.GeneralCacheCorruption(e)
# return [ row[0] for row in self.con.fetchall() ]
for x in self.con.fetchall():
self.con.execute("SELECT cpv, key, value FROM %s NATURAL JOIN %s "
"WHERE label=%s" % (self.SCHEMA_PACKAGE_NAME, self.SCHEMA_VALUES_NAME,
self.label))
- except self._BaseError, e:
+ except self._BaseError as e:
raise cache_errors.CacheCorruption(self, cpv, e)
oldcpv = None
try:
self.con.execute("SELECT cpv from package_cache natural join values_cache WHERE label=%s %s" % \
(self.label, query))
- except self._BaseError, e:
+ except self._BaseError as e:
raise cache_errors.GeneralCacheCorruption(e)
return [ row[0] for row in self.con.fetchall() ]
raise cache_errors.InitializationError(self.__class__, "can't ensure perms on %s" % self._dbpath)
self._db_init_cache_size(config["cache_bytes"])
self._db_init_synchronous(config["synchronous"])
- except self._db_error, e:
+ except self._db_error as e:
raise cache_errors.InitializationError(self.__class__, e)
def _db_init_structures(self):
try:
s = " ".join(update_statement)
cursor.execute(s)
- except self._db_error, e:
+ except self._db_error as e:
writemsg("%s: %s\n" % (cpv, str(e)))
raise
restricts[key] = re.compile(match).match
else:
restricts[key] = re.compile(match[0],match[1]).match
- except re.error, e:
+ except re.error as e:
raise InvalidRestriction(key, match, e)
if key not in self.__known_keys:
raise InvalidRestriction(key, match, "Key isn't valid")
dead_nodes.discard(x)
try:
entry = src_cache[x]
- except KeyError, e:
+ except KeyError as e:
noise.missing_entry(x)
del e
continue
- except cache_errors.CacheError, ce:
+ except cache_errors.CacheError as ce:
noise.exception(x, ce)
del ce
continue
try:
inherited = entry.get("INHERITED", "")
eclasses = entry.get("_eclasses_")
- except cache_errors.CacheError, ce:
+ except cache_errors.CacheError as ce:
noise.exception(x, ce)
del ce
continue
# been updated/translated (if needs be, for metadata/cache mainly)
try:
trg_cache[x] = entry
- except cache_errors.CacheError, ce:
+ except cache_errors.CacheError as ce:
noise.exception(x, ce)
del ce
continue
del trg_cache[key]
except KeyError:
pass
- except cache_errors.CacheError, ce:
+ except cache_errors.CacheError as ce:
noise.exception(ce)
del ce
noise.finish()
from Crypto.Hash import SHA256, RIPEMD
sha256hash = _generate_hash_function("SHA256", SHA256.new, origin="pycrypto")
rmd160hash = _generate_hash_function("RMD160", RIPEMD.new, origin="pycrypto")
-except ImportError, e:
+except ImportError as e:
pass
# Use hashlib from python-2.5 if available and prefer it over pycrypto and internal fallbacks.
def rmd160():
return hashlib.new('ripemd160')
rmd160hash = _generate_hash_function("RMD160", rmd160, origin="hashlib")
-except ImportError, e:
+except ImportError as e:
pass
mysize = os.stat(filename)[stat.ST_SIZE]
if mydict["size"] != mysize:
return False,(_("Filesize does not match recorded size"), mysize, mydict["size"])
- except OSError, e:
+ except OSError as e:
if e.errno == errno.ENOENT:
raise portage.exception.FileNotFound(filename)
return False, (str(e), None, None)
raise portage.exception.DigestException(hashname + \
" hash function not available (needs dev-python/pycrypto)")
myhash, mysize = hashfunc_map[hashname](myfilename)
- except (OSError, IOError), e:
+ except (OSError, IOError) as e:
if e.errno == errno.ENOENT:
raise portage.exception.FileNotFound(myfilename)
raise
if prelink_tmpfile:
try:
os.unlink(prelink_tmpfile)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
del e
mode='r', encoding=_encodings['content'], errors='strict')
mylines=myfile.readlines()
myfile.close()
- except SystemExit, e:
+ except SystemExit as e:
raise
except:
mylines=[]
print "stat done"
del mystat
- except SystemExit, e:
+ except SystemExit as e:
raise
- except Exception, e:
+ except Exception as e:
print "failed to stat",file
print e
return
os.unlink(mylink)
try:
os.rmdir(os.path.join(self.pkgdir, mycat))
- except OSError, e:
+ except OSError as e:
if e.errno not in (errno.ENOENT,
errno.ENOTEMPTY, errno.EEXIST):
raise
self._ensure_dir(os.path.dirname(full_path))
try:
os.unlink(full_path)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
del e
src_path = os.path.join(self.pkgdir, mycat, myfile)
try:
mystat = os.lstat(src_path)
- except OSError, e:
+ except OSError as e:
mystat = None
if mystat and stat.S_ISREG(mystat.st_mode):
self._ensure_dir(os.path.join(self.pkgdir, "All"))
pkgindex.read(f)
finally:
f.close()
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
local_timestamp = pkgindex.header.get("TIMESTAMP", None)
pkgindex = rmt_idx
finally:
f.close()
- except EnvironmentError, e:
+ except EnvironmentError as e:
writemsg(_("\n\n!!! Error fetching binhost package" \
" info from '%s'\n") % base_url)
writemsg("!!! %s\n\n" % str(e))
remote_metadata[k] = v.strip()
self._remotepkgs[fullpkg] = remote_metadata
#print " -- Injected"
- except SystemExit, e:
+ except SystemExit as e:
raise
except:
writemsg(_("!!! Failed to inject remote binary package: %s\n") % fullpkg,
full_path = filename
try:
s = os.stat(full_path)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
del e
deps = use_reduce(deps, uselist=raw_use)
deps = paren_normalize(deps)
deps = paren_enclose(deps)
- except portage.exception.InvalidDependString, e:
+ except portage.exception.InvalidDependString as e:
writemsg("%s: %s\n" % (k, str(e)),
noiselevel=-1)
raise
myslot = ""
try:
myslot = self.dbapi.aux_get(mycatpkg,["SLOT"])[0]
- except SystemExit, e:
+ except SystemExit as e:
raise
- except Exception, e:
+ except Exception as e:
pass
return myslot
try:
ensure_dirs(self.depcachedir, gid=portage_gid,
mode=dirmode, mask=modemask)
- except PortageException, e:
+ except PortageException as e:
pass
def close_caches(self):
mystat = None
try:
mystat = os.stat(file_path)
- except OSError, e:
+ except OSError as e:
pass
if mystat is None:
existing_size = 0
try:
ok, reason = portage.checksum.verify_all(
os.path.join(self.mysettings["DISTDIR"], x), mysums[x])
- except FileNotFound, e:
+ except FileNotFound as e:
ok = False
reason = _("File Not Found: '%s'") % (e,)
if not ok:
metadata.update(izip(aux_keys, self.aux_get(mycpv, aux_keys)))
except KeyError:
continue
- except PortageException, e:
+ except PortageException as e:
writemsg("!!! Error: aux_get('%s', %s)\n" % (mycpv, aux_keys),
noiselevel=-1)
writemsg("!!! %s\n" % (e,), noiselevel=-1)
myslot = ""
try:
myslot = self.dbapi.aux_get(mycatpkg, ["SLOT"])[0]
- except SystemExit, e:
+ except SystemExit as e:
raise
- except Exception, e:
+ except Exception as e:
pass
return myslot
self._data = pickle.load(
open(_unicode_encode(self._filename,
encoding=_encodings['fs'], errors='strict'), 'rb'))
- except (ValueError, pickle.UnpicklingError), e:
+ except (ValueError, pickle.UnpicklingError) as e:
writemsg_level(_("!!! Error loading '%s': %s\n") % \
(self._filename, e), level=logging.ERROR, noiselevel=-1)
- except (EOFError, IOError), e:
+ except (EOFError, IOError) as e:
if isinstance(e, EOFError) or e.errno == errno.ENOENT:
pass
elif e.errno == PermissionDenied.errno:
f = atomic_ofstream(self._filename, 'wb')
pickle.dump(self._data, f, protocol=2)
f.close()
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno != PermissionDenied.errno:
writemsg("!!! %s %s\n" % (e, self._filename), noiselevel=-1)
else:
for x in items)
try:
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
raise CommandNotFound(args[0])
try:
os.rename(os.path.join(newpath, old_pf + ".ebuild"),
os.path.join(newpath, new_pf + ".ebuild"))
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
del e
cat_dir = self.getpath(mysplit[0])
try:
dir_list = os.listdir(cat_dir)
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno == PermissionDenied.errno:
raise PermissionDenied(cat_dir)
del e
try:
return [x for x in os.listdir(p) \
if os.path.isdir(os.path.join(p, x))]
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno == PermissionDenied.errno:
raise PermissionDenied(p)
del e
f.close()
apply_secpass_permissions(
self._aux_cache_filename, gid=portage_gid, mode=0644)
- except (IOError, OSError), e:
+ except (IOError, OSError) as e:
pass
self._aux_cache["modified"] = set()
aux_cache = mypickle.load()
f.close()
del f
- except (IOError, OSError, EOFError, ValueError, pickle.UnpicklingError), e:
+ except (IOError, OSError, EOFError, ValueError, pickle.UnpicklingError) as e:
if isinstance(e, pickle.UnpicklingError):
writemsg(_("!!! Error loading '%s': %s\n") % \
(self._aux_cache_filename, str(e)), noiselevel=-1)
mydir_stat = None
try:
mydir_stat = os.stat(mydir)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
raise KeyError(mycpv)
if st is None:
try:
st = os.stat(mydir)
- except OSError, e:
+ except OSError as e:
if e.errno == errno.ENOENT:
raise KeyError(mycpv)
elif e.errno == PermissionDenied.errno:
encoding=_encodings['fs'], errors='strict'),
mode='r', encoding=_encodings['repo.content'],
errors='replace')
- except EnvironmentError, e:
+ except EnvironmentError as e:
new_vdb = not bool(self.cpv_all())
if not new_vdb:
writemsg(_("!!! Unable to read COUNTER file: '%s'\n") % \
counter = long(cfile.readline().strip())
finally:
cfile.close()
- except (OverflowError, ValueError), e:
+ except (OverflowError, ValueError) as e:
writemsg(_("!!! COUNTER file is corrupt: '%s'\n") % \
self._counter_path, noiselevel=-1)
writemsg("!!! %s\n" % str(e), noiselevel=-1)
mys = myprovide.split("/")
myprovides += [mys[0] + "/" + mys[1]]
return myprovides
- except SystemExit, e:
+ except SystemExit as e:
raise
- except Exception, e:
+ except Exception as e:
mydir = os.path.join(self.root, VDB_PATH, mycpv)
writemsg(_("\nParse Error reading PROVIDE and USE in '%s'\n") % mydir,
noiselevel=-1)
encoding=_encodings['fs'], errors='strict'),
mode='r', encoding=_encodings['repo.content'],
errors='replace')
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
del e
try:
doebuild_environment(myebuildpath, "prerm", self.myroot,
self.settings, 0, 0, self.vartree.dbapi)
- except UnsupportedAPIException, e:
+ except UnsupportedAPIException as e:
# Sometimes this happens due to corruption of the EAPI file.
writemsg(_("!!! FAILED prerm: %s\n") % \
os.path.join(self.dbdir, "EAPI"), noiselevel=-1)
if catdir_lock:
try:
os.rmdir(catdir)
- except OSError, e:
+ except OSError as e:
if e.errno not in (errno.ENOENT,
errno.ENOTEMPTY, errno.EEXIST):
raise
not self.isprotected(obj):
try:
unlink(obj, lstatobj)
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno not in ignored_unlink_errnos:
raise
del e
try:
unlink(obj, lstatobj)
show_unmerge("<<<", "", file_type, obj)
- except (OSError, IOError),e:
+ except (OSError, IOError) as e:
if e.errno not in ignored_unlink_errnos:
raise
del e
mymd5 = None
try:
mymd5 = perf_md5(obj, calc_prelink=1)
- except FileNotFound, e:
+ except FileNotFound as e:
# the file has disappeared between now and our stat call
show_unmerge("---", unmerge_desc["!obj"], file_type, obj)
continue
continue
try:
unlink(obj, lstatobj)
- except (OSError, IOError), e:
+ except (OSError, IOError) as e:
if e.errno not in ignored_unlink_errnos:
raise
del e
# Restore the parent flags we saved before unlinking
bsd_chflags.chflags(parent_name, pflags)
show_unmerge("<<<", "", "dir", obj)
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno not in ignored_rmdir_errnos:
raise
if e.errno != errno.ENOENT:
parent_path = os_filename_arg.path.dirname(destfile)
try:
parent_stat = os_filename_arg.stat(parent_path)
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
del e
return
try:
self.vartree.dbapi.linkmap.rebuild(**kwargs)
- except CommandNotFound, e:
+ except CommandNotFound as e:
self._linkmap_broken = True
self._display_merge(_("!!! Disabling preserve-libs " \
"due to error: Command Not Found: %s\n") % (e,),
obj_type = _("obj")
try:
os.unlink(obj)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
del e
os.path.join(destroot, f.lstrip(os.path.sep)))
try:
dest_lstat = os.lstat(dest_path)
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno == errno.ENOENT:
del e
continue
try:
dest_lstat = os.lstat(parent_path)
break
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno != errno.ENOTDIR:
raise
del e
path = os.path.join(root, f.lstrip(os.sep))
try:
st = os.lstat(path)
- except OSError, e:
+ except OSError as e:
if e.errno not in (errno.ENOENT, errno.ENOTDIR):
raise
del e
try:
s = os.lstat(path)
- except OSError, e:
+ except OSError as e:
if e.errno not in (errno.ENOENT, errno.ENOTDIR):
raise
del e
encoding=_encodings['fs'], errors='strict'),
mode='r', encoding=_encodings['repo.content'],
errors='replace').readline().strip()
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
del e
try:
os.unlink(os.path.join(
os.path.dirname(normalize_path(srcroot)), ".installed"))
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
del e
try:
mydstat = os.lstat(mydest)
mydmode = mydstat.st_mode
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
del e
curval += 1
try:
lst = os.lstat(path)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
del e
try:
shutil.copy2(curconf, archive)
- except(IOError, os.error), why:
+ except(IOError, os.error) as why:
print >> sys.stderr, _('dispatch-conf: Error copying %(curconf)s to %(archive)s: %(reason)s; fatal') % \
{"curconf": curconf, "archive": archive, "reason": str(why)}
if os.path.exists(archive + ',v'):
try:
shutil.copy2(newconf, archive)
- except(IOError, os.error), why:
+ except(IOError, os.error) as why:
print >> sys.stderr, _('dispatch-conf: Error copying %(newconf)s to %(archive)s: %(reason)s; fatal') % \
{"newconf": newconf, "archive": archive, "reason": str(why)}
try:
shutil.copy2(curconf, archive)
- except(IOError, os.error), why:
+ except(IOError, os.error) as why:
print >> sys.stderr, _('dispatch-conf: Error copying %(curconf)s to %(archive)s: %(reason)s; fatal') % \
{"curconf": curconf, "archive": archive, "reason": str(why)}
# Save off new config file in the archive dir with .dist.new suffix
try:
shutil.copy2(newconf, archive + '.dist.new')
- except(IOError, os.error), why:
+ except(IOError, os.error) as why:
print >> sys.stderr, _('dispatch-conf: Error copying %(newconf)s to %(archive)s: %(reason)s; fatal') % \
{"newconf": newconf, "archive": archive + '.dist.new', "reason": str(why)}
for x in [normalize_path(os.path.join(y,"eclass")) for y in self.porttrees]:
try:
eclass_filenames = os.listdir(x)
- except OSError, e:
+ except OSError as e:
if e.errno in ignored_listdir_errnos:
del e
continue
if hasattr(m, "finalize") and not m.finalize in _elog_atexit_handlers:
_elog_atexit_handlers.append(m.finalize)
atexit_register(m.finalize)
- except (ImportError, AttributeError), e:
+ except (ImportError, AttributeError) as e:
writemsg(_("!!! Error while importing logging modules "
"while loading \"mod_%s\":\n") % str(s))
writemsg("%s\n" % str(e), noiselevel=-1)
- except PortageException, e:
+ except PortageException as e:
writemsg("%s\n" % str(e), noiselevel=-1)
mymessage = portage.mail.create_message(myfrom, myrecipient, mysubject, fulltext)
try:
portage.mail.send_mail(mysettings, mymessage)
- except PortageException, e:
+ except PortageException as e:
writemsg("%s\n" % str(e), noiselevel=-1)
return
portage.mail.send_mail(mysettings, mymessage)
finally:
signal.alarm(0)
- except PortageException, e:
+ except PortageException as e:
writemsg("%s\n" % str(e), noiselevel=-1)
return
f = codecs.open(_unicode_encode(fn,
encoding=_encodings['fs'], errors='strict'), mode='r',
encoding=_encodings['content'], errors='replace')
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno not in (errno.ENOENT, errno.ESTALE):
raise
del e
try:
import ftplib
-except ImportError, e:
+except ImportError as e:
sys.stderr.write(colorize("BAD","!!! CANNOT IMPORT FTPLIB: ")+str(e)+"\n")
try:
import httplib
-except ImportError, e:
+except ImportError as e:
sys.stderr.write(colorize("BAD","!!! CANNOT IMPORT HTTPLIB: ")+str(e)+"\n")
def make_metadata_dict(data):
return mydata,not (fsize==data_size),""
- except ValueError, e:
+ except ValueError as e:
return None,int(str(e)[:4]),str(e)
if (rc != 0):
conn,ignore,ignore,ignore,ignore = create_conn(address)
conn.request("GET", address, params, headers)
- except SystemExit, e:
+ except SystemExit as e:
raise
- except Exception, e:
+ except Exception as e:
return None,None,"Server request failed: "+str(e)
response = conn.getresponse()
rc = response.status
try:
conn, protocol, address, params, headers = create_conn(baseurl, conn)
- except socket.error, e:
+ except socket.error as e:
# ftplib.FTP(host) can raise errors like this:
# socket.error: (111, 'Connection refused')
sys.stderr.write("!!! %s\n" % (e,))
import portage.exception
try:
filelist = dir_get_list(baseurl, conn)
- except portage.exception.PortageException, e:
+ except portage.exception.PortageException as e:
sys.stderr.write(_("!!! Error connecting to '%s'.\n") % baseurl)
sys.stderr.write("!!! %s\n" % str(e))
del e
if mytempfile.tell() > len(data):
mytempfile.seek(0)
data = mytempfile.read()
- except ValueError, e:
+ except ValueError as e:
sys.stderr.write("--- "+str(e)+"\n")
if trynum < 3:
sys.stderr.write(_("Retrying...\n"))
mytempfile.seek(0)
gzindex = gzip.GzipFile(mfile[:-3],'rb',9,mytempfile)
data = gzindex.read()
- except SystemExit, e:
+ except SystemExit as e:
raise
- except Exception, e:
+ except Exception as e:
mytempfile.close()
sys.stderr.write(_("!!! Failed to use gzip: ")+str(e)+"\n")
sys.stderr.flush()
out.write(_("Pickle loaded.\n"))
out.flush()
break
- except SystemExit, e:
+ except SystemExit as e:
raise
- except Exception, e:
+ except Exception as e:
sys.stderr.write(_("!!! Failed to read data from index: ")+str(mfile)+"\n")
sys.stderr.write("!!! "+str(e)+"\n")
sys.stderr.flush()
encoding=_encodings['fs'], errors='strict'), 'wb')
pickle.dump(metadata, metadatafile, protocol=2)
metadatafile.close()
- except SystemExit, e:
+ except SystemExit as e:
raise
- except Exception, e:
+ except Exception as e:
sys.stderr.write(_("!!! Failed to write binary metadata to disk!\n"))
sys.stderr.write("!!! "+str(e)+"\n")
sys.stderr.flush()
encoding=_encodings['fs'], errors='strict'), 'wb')
pickle.dump(metadata[baseurl]["data"], metadatafile, protocol=2)
metadatafile.close()
- except SystemExit, e:
+ except SystemExit as e:
raise
- except Exception, e:
+ except Exception as e:
sys.stderr.write(_("!!! Failed to write binary metadata to disk!\n"))
sys.stderr.write("!!! "+str(e)+"\n")
sys.stderr.flush()
try:
try:
myfd = os.open(lockfilename, os.O_CREAT|os.O_RDWR, 0660)
- except OSError, e:
+ except OSError as e:
func_call = "open('%s')" % lockfilename
if e.errno == OperationNotPermitted.errno:
raise OperationNotPermitted(func_call)
try:
if os.stat(lockfilename).st_gid != portage_gid:
os.chown(lockfilename, -1, portage_gid)
- except OSError, e:
+ except OSError as e:
if e.errno in (errno.ENOENT, errno.ESTALE):
return lockfile(mypath,
wantnewlockfile=wantnewlockfile,
locking_method = fcntl.lockf
try:
fcntl.lockf(myfd,fcntl.LOCK_EX|fcntl.LOCK_NB)
- except IOError, e:
+ except IOError as e:
if "errno" not in dir(e):
raise
if e.errno in (errno.EACCES, errno.EAGAIN):
# try for the exclusive lock now.
try:
fcntl.lockf(myfd, fcntl.LOCK_EX)
- except EnvironmentError, e:
+ except EnvironmentError as e:
out.eend(1, str(e))
raise
out.eend(os.EX_OK)
"""
try:
return os.fstat(fd).st_nlink
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno in (errno.ENOENT, errno.ESTALE):
# Some filesystems such as CIFS return
# ENOENT which means st_nlink == 0.
writemsg(_("lockfile does not exist '%s'\n") % lockfilename, 1)
os.close(myfd)
return False
- except Exception, e:
+ except Exception as e:
writemsg(_("Failed to get lock... someone took it.\n"), 1)
writemsg(str(e)+"\n",1)
myconn.login(mymailuser, mymailpasswd)
myconn.sendmail(myfrom, myrecipient, message.as_string())
myconn.quit()
- except smtplib.SMTPException, e:
+ except smtplib.SMTPException as e:
raise portage.exception.PortageException(_("!!! An error occured while trying to send logmail:\n")+str(e))
- except socket.error, e:
+ except socket.error as e:
raise portage.exception.PortageException(_("!!! A network error occured while trying to send logmail:\n%s\nSure you configured PORTAGE_ELOG_MAILURI correctly?") % str(e))
return
self._parseDigests(fd, myhashdict=myhashdict, **kwargs)
fd.close()
return myhashdict
- except (OSError, IOError), e:
+ except (OSError, IOError) as e:
if e.errno == errno.ENOENT:
raise FileNotFound(file_path)
else:
if oldentries[i] != myentries[i]:
update_manifest = True
break
- except (IOError, OSError), e:
+ except (IOError, OSError) as e:
if e.errno == errno.ENOENT:
pass
else:
"".join("%s\n" % str(myentry) for myentry in myentries))
if sign:
self.sign()
- except (IOError, OSError), e:
+ except (IOError, OSError) as e:
if e.errno == errno.EACCES:
raise PermissionDenied(str(e))
raise
if not ok:
raise DigestException(tuple([self._getAbsname(ftype, fname)]+list(reason)))
return ok, reason
- except FileNotFound, e:
+ except FileNotFound as e:
if not ignoreMissing:
raise
return False, _("File Not Found: '%s'") % str(e)
_styles[k] = tuple(code_list)
elif k in codes:
codes[k] = "".join(code_list)
- except (IOError, OSError), e:
+ except (IOError, OSError) as e:
if e.errno == errno.ENOENT:
raise FileNotFound(myfile)
elif e.errno == errno.EACCES:
onerror=lambda e: writemsg("%s\n" % str(e), noiselevel=-1))
except FileNotFound:
pass
- except PermissionDenied, e:
+ except PermissionDenied as e:
writemsg(_("Permission denied: '%s'\n") % str(e), noiselevel=-1)
del e
- except PortageException, e:
+ except PortageException as e:
writemsg("%s\n" % str(e), noiselevel=-1)
del e
try:
_exec(binary, mycommand, opt_name, fd_pipes,
env, gid, groups, uid, umask, pre_exec)
- except Exception, e:
+ except Exception as e:
# We need to catch _any_ exception so that it doesn't
# propogate out of this function and cause exiting
# with anything other than os._exit()
newsets = {}
try:
newsets = setclass.multiBuilder(optdict, self.settings, self.trees)
- except SetConfigError, e:
+ except SetConfigError as e:
self.errors.append(_("Configuration error in section '%s': %s") % (sname, str(e)))
continue
for x in newsets:
if parser.has_option(sname, "world-candidate") and \
not parser.getboolean(sname, "world-candidate"):
self.psets[setname].world_candidate = False
- except SetConfigError, e:
+ except SetConfigError as e:
self.errors.append(_("Configuration error in section '%s': %s") % (sname, str(e)))
continue
else:
raise SetConfigError(_("invalid 'mode' value %s (use either 'newer' or 'older')") % mode)
try:
age = int(options.get("age", "7"))
- except ValueError, e:
+ except ValueError as e:
raise SetConfigError(_("value of option 'age' is not an integer"))
return AgeSet(vardb=trees["vartree"].dbapi, mode=mode, age=age)
for fname in errors:
for e in errors[fname]:
self.errors.append(fname+": "+e)
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
del e
for fname in errors:
for e in errors[fname]:
self.errors.append(fname+": "+e)
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
del e
for fname in errors:
for e in errors[fname]:
self.errors.append(fname+": "+e)
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
del e
if logfile:
try:
os.unlink(logfile)
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
del e
given then only updates with differing mtimes are considered."""
try:
mylist = os.listdir(updpath)
- except OSError, oe:
+ except OSError as oe:
if oe.errno == errno.ENOENT:
raise DirectoryNotFound(updpath)
raise
updating_file = new_protect_filename(updating_file)
try:
write_atomic(updating_file, "".join(file_contents[x]))
- except PortageException, e:
+ except PortageException as e:
writemsg("\n!!! %s\n" % str(e), noiselevel=-1)
writemsg(_("!!! An error occured while updating a config file:") + \
" '%s'\n" % updating_file, noiselevel=-1)
mode='r', encoding=_encodings['content'], errors='replace')
mylines = myfile.readlines()
myfile.close()
- except IOError, e:
+ except IOError as e:
if e.errno == PermissionDenied.errno:
raise PermissionDenied(myfilename)
pass
def sourcehook(self, newfile):
try:
return shlex.shlex.sourcehook(self, newfile)
- except EnvironmentError, e:
+ except EnvironmentError as e:
writemsg(_("!!! Parse error in '%s': source command failed: %s\n") % \
(self.infile, str(e)), noiselevel=-1)
return (newfile, StringIO())
encoding=_encodings['content'], errors='replace').read()
if content and content[-1] != '\n':
content += '\n'
- except IOError, e:
+ except IOError as e:
if e.errno == PermissionDenied.errno:
raise PermissionDenied(mycfg)
if e.errno != errno.ENOENT:
expand_map[key] = mykeys[key]
else:
mykeys[key] = val
- except SystemExit, e:
+ except SystemExit as e:
raise
- except Exception, e:
+ except Exception as e:
raise portage.exception.ParseError(str(e)+" in "+mycfg)
return mykeys
myf.close()
del mypickle,myf
writemsg(_("pickle_read(): Loaded pickle. '")+filename+"'\n",1)
- except SystemExit, e:
+ except SystemExit as e:
raise
- except Exception, e:
+ except Exception as e:
writemsg(_("!!! Failed to load pickle: ")+str(e)+"\n",1)
data = default
return data
stat_cached = os.stat(filename)
else:
stat_cached = os.lstat(filename)
- except OSError, oe:
+ except OSError as oe:
func_call = "stat('%s')" % filename
if oe.errno == errno.EPERM:
raise OperationNotPermitted(func_call)
import portage.data
portage.data.lchown(filename, uid, gid)
modified = True
- except OSError, oe:
+ except OSError as oe:
func_call = "chown('%s', %i, %i)" % (filename, uid, gid)
if oe.errno == errno.EPERM:
raise OperationNotPermitted(func_call)
try:
os.chmod(filename, new_mode)
modified = True
- except OSError, oe:
+ except OSError as oe:
func_call = "chmod('%s', %s)" % (filename, oct(new_mode))
if oe.errno == errno.EPERM:
raise OperationNotPermitted(func_call)
uid=uid, gid=gid, mode=dirmode, mask=dirmask)
if not applied:
all_applied = False
- except PortageException, e:
+ except PortageException as e:
all_applied = False
onerror(e)
uid=uid, gid=gid, mode=filemode, mask=filemask)
if not applied:
all_applied = False
- except PortageException, e:
+ except PortageException as e:
# Ignore InvalidLocation exceptions such as FileNotFound
# and DirectoryNotFound since sometimes things disappear,
# like when adjusting permissions on DISTCC_DIR.
stat_cached = os.stat(filename)
else:
stat_cached = os.lstat(filename)
- except OSError, oe:
+ except OSError as oe:
func_call = "stat('%s')" % filename
if oe.errno == errno.EPERM:
raise OperationNotPermitted(func_call)
encoding=_encodings['fs'], errors='strict'),
mode=mode, **kargs))
return
- except IOError, e:
+ except IOError as e:
if canonical_path == filename:
raise
writemsg(_("!!! Failed to open file: '%s'\n") % tmp_name,
pass
except FileNotFound:
pass
- except OSError, oe: # from the above os.stat call
+ except OSError as oe: # from the above os.stat call
if oe.errno in (errno.ENOENT, errno.EPERM):
pass
else:
# even if an exception is raised.
try:
os.unlink(f.name)
- except OSError, oe:
+ except OSError as oe:
pass
def abort(self):
f = atomic_ofstream(file_path, **kwargs)
f.write(content)
f.close()
- except (IOError, OSError), e:
+ except (IOError, OSError) as e:
if f:
f.abort()
func_call = "write_atomic('%s')" % file_path
try:
os.makedirs(dir_path)
created_dir = True
- except OSError, oe:
+ except OSError as oe:
func_call = "makedirs('%s')" % dir_path
if oe.errno in (errno.EEXIST, errno.EISDIR):
pass
mydata=myid[1]
try:
origdir=os.getcwd()
- except SystemExit, e:
+ except SystemExit as e:
raise
except:
os.chdir("/")
# thus the above sanity check.
try:
shutil.rmtree(datadir)
- except OSError, oe:
+ except OSError as oe:
if oe.errno == errno.ENOENT:
pass
else:
self.datapos=a.tell()
a.close()
return 2
- except SystemExit, e:
+ except SystemExit as e:
raise
except:
return 0
return 0
try:
origdir=os.getcwd()
- except SystemExit, e:
+ except SystemExit as e:
raise
except:
os.chdir("/")
uselist = []
try:
metadatadom = minidom.parse(mylines)
- except ExpatError, e:
+ except ExpatError as e:
raise exception.ParseError("metadata.xml: %s" % (e,))
try:
encoding=_encodings['fs'], errors='strict'),
mode='r', encoding=_encodings['content'], errors='replace'
).readlines()
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
del e