Merged from trunk 5581:5597
authorFabian Groffen <grobian@gentoo.org>
Fri, 12 Jan 2007 23:05:07 +0000 (23:05 -0000)
committerFabian Groffen <grobian@gentoo.org>
Fri, 12 Jan 2007 23:05:07 +0000 (23:05 -0000)
portage_versions.py, more string.atoi -> int, fix another except: that
should be ValueError (WarnerBro)
(Prefix: string.atof -> float)

Fix broad except statement, should only be KeyError (WarnerBro)

comment the excepts in a few places (WarnerBro)

getbinpkg.py fix except: open can be IOERror or OSError and cPickle can
throw an unpicklingError (WarnerBro)

EOFError is also important according to Zac (WarnerBro)

os.cwd can return OSError (maybe IOError with wrong perms for ./, will
test actually), load_mod should be IMportError, nuke a stupid try except
around shuffle which used to break years ago with old glibcs, remove try
except around what appears to be a regex? and make the try except around
the unlink a bit cleaner (WarnerBro)

FIx a bunch of random Except: statements in portage.py, most of them are
IO/OS related (WarnerBro)

Return early from finddigest if findname2 found nothing.

For bug #88485, show the location of the build log whenever a build
fails.

Prevent an InvalidData exception during global updates due to the new
stricter catpkgsplit behavior.

Fix incremental virtuals code for the new stricter catpkgsplit behavior.

Remove a duplicate % character.

Begin the deprecation of the string module (WarnerBro)

more string deprecation (WarnerBro)

set Id on tests (WarnerBro)

More String deprecation (WarnerBro)

svn path=/main/branches/prefix/; revision=5619

37 files changed:
bin/archive-conf
bin/chkcontents
bin/dispatch-conf
bin/dohtml
bin/ebuild.sh
bin/md5check.py
bin/portageq
bin/regenworld
pym/cvstree.py
pym/eclass_cache.py
pym/emergehelp.py
pym/getbinpkg.py
pym/portage.py
pym/portage_dep.py
pym/portage_exec.py
pym/portage_locks.py
pym/portage_update.py
pym/portage_util.py
pym/portage_versions.py
pym/xpak.py
tests/portage/__init__.py
tests/portage_dep/__init__.py
tests/portage_dep/test_dep_getcpv.py
tests/portage_dep/test_dep_getslot.py
tests/portage_dep/test_get_operator.py
tests/portage_dep/test_isjustname.py
tests/portage_dep/test_isvalidatom.py
tests/portage_dep/test_match_from_list.py
tests/portage_util/__init__.py
tests/portage_util/test_grabdict.py
tests/portage_util/test_normalizedPath.py
tests/portage_util/test_stackDictList.py
tests/portage_util/test_stackDicts.py
tests/portage_util/test_stackLists.py
tests/portage_util/test_uniqueArray.py
tests/portage_util/test_varExpand.py
tests/portage_versions/__init__.py

index 6c8f007d10756cc7ca8006e5d2c889e47c4ccd9b..0adb2508ba4a30d3bdb8ddef08d55d8769a2daa3 100755 (executable)
@@ -10,7 +10,7 @@
 #  Jeremy Wohl's dispatch-conf script and the portage chkcontents script.
 #
 
-import os, sys, string
+import os, sys
 try:
     import portage
 except ImportError:
@@ -32,7 +32,7 @@ except ImportError:
         hexform = ""
         for ix in xrange(len(md5sum)):
             hexform = hexform + "%02x" % ord(md5sum[ix])
-        return string.lower(hexform)
+        return hexform.lower()
     
     def perform_checksum(filename):
         f = open(filename, 'rb')
@@ -75,12 +75,12 @@ def archive_conf():
                 sys.exit(1)
             lines = contents.readlines()
             for line in lines:
-                items = string.split(line)
+                items = line.split()
                 if items[0] == 'obj':
                     for conf in args:
                         if items[1] == conf:
-                            stored = string.lower(items[2])
-                            real = string.lower(perform_checksum(conf)[0])
+                            stored = items[2].lower()
+                            real = perform_checksum(conf)[0].lower()
                             if stored == real:
                                 md5_match_hash[conf] = conf
                             todo_cnt -= 1
index eecb55762d748011cae02d3a3daf1b59f950080e..90a58633707bbc5cd6b180c66b7b70cb0a25dd5f 100755 (executable)
@@ -8,7 +8,7 @@
 # actual programs on the system (and makes sure that symlinks point to
 # the right files).
 
-import string, os.path, os, sys
+import os.path, os, sys
 try:
        import portage
 except ImportError:
@@ -23,7 +23,7 @@ def CONTENTScheck(path):
                sys.exit(1)
        lines = contents.readlines()
        for line in lines:
-               items = string.split(line)
+               items = line.split()
                # items is a list w/ size depending on the type of item listed in item[0]
                # if items[0] = 'dir' then items[1] is the path of a directory
                # if items[0] = 'obj' then items[1] is the path of a file,
@@ -34,9 +34,9 @@ def CONTENTScheck(path):
                #                          items[3] is the file the symlink should point to
                #                          items[4] is the symlink mtime 
                if (items[0] == 'obj'):
-                       md5stored = string.lower(items[2])
+                       md5stored = items[2].lower()
                        # fchksum.fmdft(file) returns the file's md5sum and the file's size
-                       md5real = string.lower(portage.perform_checksum(items[1])[0])
+                       md5real = portage.perform_checksum(items[1])[0].lower()
                        if (md5stored != md5real):
                                if md5real:
                                        print "%s has md5sum of %s instead of %s" % (items[1], md5real, md5stored)
index c5b27b728b040e43b0a4fd702836c844a3a58b34..eee066442260dd4782f7bd0d80c8f276920480a5 100755 (executable)
@@ -17,7 +17,7 @@ if not hasattr(__builtins__, "set"):
 
 from stat import *
 from random import *
-import atexit, commands, os, re, shutil, stat, string, sys
+import atexit, commands, os, re, shutil, stat, sys
 try:
     import portage
 except ImportError:
@@ -362,6 +362,6 @@ d = dispatch ()
 
 if len(sys.argv) > 1:
     # for testing
-    d.grind (string.join (sys.argv [1:]))
+    d.grind ("".join( (sys.argv [1:]))
 else:
     d.grind (portage.settings ['CONFIG_PROTECT'])
index f9c6e33aca9ce8459a8497cfd056c82473adc1ae..bb4789d64b62eb0744f3a15555d58b54a77ee770 100755 (executable)
@@ -30,7 +30,6 @@
 #
 
 import os
-import string
 import sys
 import types
 
@@ -95,11 +94,11 @@ def print_help():
        print "       [-r] [-V] <file> [file ...]"
        print
        print " -a   Set the list of allowed to those that are specified."
-       print "      Default:", string.join(opts.allowed_exts, ",")
+       print "      Default:", ",".join(opts.allowed_exts)
        print " -A   Extend the list of allowed file types."
        print " -f   Set list of allowed extensionless file names."
        print " -x   Set directories to be excluded from recursion."
-       print "      Default:", string.join(opts.disallowed_dirs, ",")
+       print "      Default:", ",".join(opts.disallowed_dirs)
        print " -r   Install files and directories recursively."
        print " -V   Be verbose."
        print
@@ -127,7 +126,7 @@ def parse_args():
                        elif arg == "-p":
                                options.doc_prefix = sys.argv[x]
                        else:
-                               values = string.split(sys.argv[x], ",")
+                               values = sys.argv[x].split(",")
                                if arg == "-A":
                                        options.allowed_exts.extend(values)
                                elif arg == "-a":
index 5e77aa6021e3d3c18a1e31fa0afeb2ec01c73579..f4d0b5bef1b943aabbc49b486483bac7bc4a74cb 100755 (executable)
@@ -431,6 +431,7 @@ diefunc() {
        echo >&2
        echo "!!! ${*:-(no error message)}" >&2
        echo "!!! If you need support, post the topmost build error, and the call stack if relevant." >&2
+       echo "!!! A complete build log is located at '${PORTAGE_LOG_FILE}'." >&2
        echo >&2
        if [ -n "${EBUILD_OVERLAY_ECLASSES}" ] ; then
                echo "This ebuild used the following eclasses from overlays:" >&2
index e9c36cf7f90041ab85e2724ebcface22d284a34a..220ef83087158e494d074f7fc884ab7b3c8d6cb8 100755 (executable)
@@ -3,7 +3,7 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id: /var/cvsroot/gentoo-src/portage/bin/md5check.py,v 1.4 2004/10/10 10:07:20 carpaski Exp $
 
-import os,sys,string
+import os,sys
 os.environ["FEATURES"]="mirror cvs"
 try:
        import portage
@@ -33,10 +33,10 @@ for mycp in portage.db["/"]["porttree"].dbapi.cp_all():
 hugelist.sort()
 
 for mycpv in hugelist:
-       pv = string.split(mycpv, "/")[-1]
+       pv = mycpv.split("/")[-1]
 
        newuri = portage.db["/"]["porttree"].dbapi.aux_get(mycpv,["SRC_URI"])[0]
-       newuri = string.split(newuri)
+       newuri = newuri.split()
 
        digestpath = portage.db["/"]["porttree"].dbapi.findname(mycpv)
        digestpath = os.path.dirname(digestpath)+"/files/digest-"+pv
@@ -79,8 +79,8 @@ for mycpv in hugelist:
                                   (md5_list[mybn]["size"] != md5sums[mybn]["size"]):
 
                                        # This associates teh md5 with each file. [md5/size]
-                                       md5joins = string.split(md5_list[mybn][2],",")
-                                       md5joins = string.join(md5joins," ["+md5_list[mybn][0]+"/"+md5_list[mybn][1]+"],")
+                                       md5joins = md5_list[mybn][2].split(",")
+                                       md5joins = " ["+md5_list[mybn][0]+"/"+md5_list[mybn][1]+"],".join(md5joins))
                                        md5joins += " ["+md5_list[mybn][0]+"/"+md5_list[mybn][1]+"]"
 
                                        portage.writemsg("Colliding md5: %s of %s [%s/%s] and %s\n" % (mybn,mycpv,md5sums[mybn][0],md5sums[mybn][1],md5joins))
index 8f067181b5aa96be5c2c7e4a4b9757171b8119c3..55723e10a7ccc8a7fb63a93b707655b91a1f3cd3 100755 (executable)
@@ -21,8 +21,7 @@ except KeyboardInterrupt:
 
 import os
 
-import types,string
-
+import types
 
 #-----------------------------------------------------------------------------
 #
@@ -179,7 +178,7 @@ def match(argv):
                print "ERROR: insufficient parameters!"
                sys.exit(2)
        try:
-               print string.join(portage.db[argv[0]]["vartree"].dbapi.match(argv[1]),"\n")
+               print "\n".join(portage.db[argv[0]]["vartree"].dbapi.match(argv[1]))
        except KeyError:
                sys.exit(1)
 match.uses_root = True
@@ -269,7 +268,7 @@ def envvar(argv):
 
 def usage(argv):
        rev="$Revision: 1.13.2.1 $"
-       ver=string.split(rev, ' ')[1]
+       ver= rev.split(' ')[1]
        print ">>> Portage information query tool -- version "+ver
        print ">>> Usage: portageq <command> [<option> ...]"
        print ""
@@ -296,13 +295,13 @@ def usage(argv):
                        print ""
                        continue
 
-               lines = string.split(doc, '\n')
-               print "   "+name+" "+string.strip(lines[0])
+               lines = doc.split("\n")
+               print "   "+name+" "+lines[0].strip()
                if (len(sys.argv) > 1):
                        if ("--help" not in sys.argv):
                                lines = lines[:-1]
                        for line in lines[1:]:
-                               print "      "+string.strip(line)
+                               print "      "+line.strip()
        if (len(sys.argv) == 1):
                print "\nRun portageq with --help for info"
 
index ea1b46e824f3da304d7b61b8cf5d27896d1e5484..ec3c4c6642a50f4d166897306824ec48b85ff463 100755 (executable)
@@ -9,7 +9,7 @@ try:
 except ImportError:
        sys.path.insert(0, "@PORTAGE_BASE@/pym")
        import portage
-import string, re, portage_const
+import re, portage_const
 
 __candidatematcher__ = re.compile("^[0-9]+: \\*\\*\\* emerge ")
 __noncandidatematcher__ = re.compile(" sync( |$)| clean( |$)| search( |$)|--oneshot|--fetchonly| unmerge( |$)")
index 6e91af9efbbcff12887f5c64e6e62dadf7912190..8a9450afda6c0949cddb5640d584a459bf067cbd 100644 (file)
@@ -4,7 +4,7 @@
 # $Id: /var/cvsroot/gentoo-src/portage/pym/cvstree.py,v 1.12.2.1 2005/01/16 02:35:33 carpaski Exp $
 
 
-import string,os,time,sys,re
+import os,time,sys,re
 from stat import *
 
 # [D]/Name/Version/Date/Flags/Tags
@@ -12,7 +12,7 @@ from stat import *
 def pathdata(entries, path):
        """(entries,path)
        Returns the data(dict) for a specific file/dir at the path specified."""
-       mysplit=string.split(path,"/")
+       mysplit=path.split("/")
        myentries=entries
        mytarget=mysplit[-1]
        mysplit=mysplit[:-1]
@@ -191,7 +191,7 @@ def getentries(mydir,recursive=0):
                        continue
                if line=="D": # End of entries file
                        break
-               mysplit=string.split(line, "/")
+               mysplit=line.split("/")
                if len(mysplit)!=6:
                        print "Confused:",mysplit
                        continue
index b0f82fd02661cd56c007d3ad2edd40f38bb3c202..91b98fec5902ff3df18f1754682d97b78b78017f 100644 (file)
@@ -72,7 +72,7 @@ class cache:
                for x in inherits:
                        try:
                                ec_dict[x] = self.eclasses[x]
-                       except:
+                       except KeyError:
                                print "ec=",ec_dict
                                print "inherits=",inherits
                                raise
index e7f87aacf42fed3b75c153df3258ca96b4c0bc1b..373e0bf444e40ae33604b8aede53460cc01feb22 100644 (file)
@@ -112,7 +112,7 @@ def help(myaction,myopts,havecolor=1):
                print "              Searches for matches of the supplied string in the current local"
                print "              portage tree. By default emerge uses a case-insensitive simple "
                print "              search, but you can enable a regular expression search by "
-               print "              prefixing the search string with %%."
+               print "              prefixing the search string with %."
                print "              Prepending the expression with a '@' will cause the category to"
                print "              be included in the search."
                print "              A few examples:"
index 074f7fa283dd034afb0be66b2a09d2642308ae84..f8da11c4bfe1363931826a7fc15c833b54c1635c 100644 (file)
@@ -7,7 +7,7 @@ if not hasattr(__builtins__, "set"):
        from sets import Set as set
 
 from output import *
-import htmllib,HTMLParser,string,formatter,sys,os,xpak,time,tempfile,base64,urllib2
+import htmllib,HTMLParser,formatter,sys,os,xpak,time,tempfile,base64,urllib2
 from portage_const import CACHE_PATH
 
 try:
@@ -79,22 +79,22 @@ def create_conn(baseurl,conn=None):
        """(baseurl,conn) --- Takes a protocol://site:port/address url, and an
        optional connection. If connection is already active, it is passed on.
        baseurl is reduced to address and is returned in tuple (conn,address)"""
-       parts = string.split(baseurl, "://", 1)
+       parts = baseurl.split("://",1)
        if len(parts) != 2:
                raise ValueError, "Provided URL does not contain protocol identifier. '%s'" % baseurl
        protocol,url_parts = parts
        del parts
-       host,address = string.split(url_parts, "/", 1)
+       host,address = url_parts.split("/",1)
        del url_parts
        address = "/"+address
 
-       userpass_host = string.split(host, "@", 1)
+       userpass_host = host.split("@",1)
        if len(userpass_host) == 1:
                host = userpass_host[0]
                userpass = ["anonymous"]
        else:
                host = userpass_host[1]
-               userpass = string.split(userpass_host[0], ":")
+               userpass = userpass_host[0].split(":")
        del userpass_host
 
        if len(userpass) > 2:
@@ -112,8 +112,7 @@ def create_conn(baseurl,conn=None):
        if username and password:
                http_headers = {
                        "Authorization": "Basic %s" %
-                         string.replace(
-                           base64.encodestring("%s:%s" % (username, password)),
+                         base64.encodestring("%s:%s" % (username, password)).replace(
                            "\012",
                            ""
                          ),
@@ -212,8 +211,8 @@ def make_http_request(conn, address, params={}, headers={}, dest=None):
                if ((rc == 301) or (rc == 302)):
                        ignored_data = response.read()
                        del ignored_data
-                       for x in string.split(str(response.msg), "\n"):
-                               parts = string.split(x, ": ", 1)
+                       for x in str(response.msg).split("\n"):
+                               parts = x.split(": ",1)
                                if parts[0] == "Location":
                                        if (rc == 301):
                                                sys.stderr.write(red("Location has moved: ")+str(parts[1])+"\n")
@@ -362,10 +361,10 @@ def file_get(baseurl,dest,conn=None,fcmd=None):
        if not fcmd:
                return file_get_lib(baseurl,dest,conn)
 
-       fcmd = string.replace(fcmd, "${DISTDIR}", dest)
-       fcmd = string.replace(fcmd, "${URI}", baseurl)
-       fcmd = string.replace(fcmd, "${FILE}", os.path.basename(baseurl))
-       mysplit = string.split(fcmd)
+       fcmd = fcmd.replace("${DISTDIR}",dest)
+       fcmd = fcmd.replace("${URI}", baseurl)
+       fcmd = fcmd.replace("${FILE}", os.path.basename(baseurl))
+       mysplit = fcmd.split()
        mycmd   = mysplit[0]
        myargs  = [os.path.basename(mycmd)]+mysplit[1:]
        mypid=os.fork()
@@ -434,9 +433,7 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
                metadata = cPickle.load(metadatafile)
                sys.stderr.write("Loaded metadata pickle.\n")
                metadatafile.close()
-       except SystemExit, e:
-               raise
-       except:
+       except (cPickle.UnpicklingError, OSError, IOError, EOFError):
                metadata = {}
        if not metadata.has_key(baseurl):
                metadata[baseurl]={}
index ea43e5d648ffd3884fbeb751d1971375654797a3..4246798d9a72a801b152b61c68b1a390881b126b 100644 (file)
@@ -153,9 +153,7 @@ def getcwd():
        "this fixes situations where the current directory doesn't exist"
        try:
                return os.getcwd()
-       except SystemExit, e:
-               raise
-       except:
+       except OSError: #dir doesn't exist
                os.chdir("/")
                return "/"
 getcwd()
@@ -1541,7 +1539,7 @@ class config:
                best_mod = best_from_dict(property_string,self.modules,self.module_priority)
                try:
                        mod = load_mod(best_mod)
-               except:
+               except ImportError:
                        dump_traceback(red("Error: Failed to import module '%s'") % best_mod, noiselevel=0)
                        sys.exit(1)
                return mod
@@ -1969,7 +1967,11 @@ class config:
                                        continue
                                myvalues = virtuals_dict[k]
                                for x in myvalues:
-                                       if not isvalidatom(x):
+                                       myatom = x
+                                       if x.startswith("-"):
+                                               # allow incrementals
+                                               myatom = x[1:]
+                                       if not isvalidatom(myatom):
                                                writemsg("--- Invalid atom in %s: %s\n" % \
                                                        (virtuals_file, x), noiselevel=-1)
                                                myvalues.remove(x)
@@ -2288,17 +2290,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                        thirdpartymirrors[mirrorname].remove(cmirr)
                                # now try the official mirrors
                                if thirdpartymirrors.has_key(mirrorname):
-                                       try:
-                                               shuffle(thirdpartymirrors[mirrorname])
-                                       except SystemExit, e:
-                                               raise
-                                       except:
-                                               writemsg(red("!!! YOU HAVE A BROKEN PYTHON/GLIBC.\n"), noiselevel=-1)
-                                               writemsg(    "!!! You are most likely on a pentium4 box and have specified -march=pentium4\n")
-                                               writemsg(    "!!! or -fpmath=sse2. GCC was generating invalid sse2 instructions in versions\n")
-                                               writemsg(    "!!! prior to 3.2.3. Please merge the latest gcc or rebuid python with either\n")
-                                               writemsg(    "!!! -march=pentium3 or set -mno-sse2 in your cflags.\n\n\n")
-                                               time.sleep(10)
+                                       shuffle(thirdpartymirrors[mirrorname])
 
                                        for locmirr in thirdpartymirrors[mirrorname]:
                                                filedict[myfile].append(locmirr+"/"+myuri[eidx+1:])
@@ -2551,21 +2543,14 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                                # Fetch failed... Try the next one... Kill 404 files though.
                                                                if (mystat[stat.ST_SIZE]<100000) and (len(myfile)>4) and not ((myfile[-5:]==".html") or (myfile[-4:]==".htm")):
                                                                        html404=re.compile("<title>.*(not found|404).*</title>",re.I|re.M)
-                                                                       try:
-                                                                               if html404.search(open(mysettings["DISTDIR"]+"/"+myfile).read()):
-                                                                                       try:
-                                                                                               os.unlink(mysettings["DISTDIR"]+"/"+myfile)
-                                                                                               writemsg(">>> Deleting invalid distfile. (Improper 404 redirect from server.)\n")
-                                                                                               fetched = 0
-                                                                                               continue
-                                                                                       except SystemExit, e:
-                                                                                               raise
-                                                                                       except:
-                                                                                               pass
-                                                                       except SystemExit, e:
-                                                                               raise
-                                                                       except:
-                                                                               pass
+                                                                       if html404.search(open(mysettings["DISTDIR"]+"/"+myfile).read()):
+                                                                               try:
+                                                                                       os.unlink(mysettings["DISTDIR"]+"/"+myfile)
+                                                                                       writemsg(">>> Deleting invalid distfile. (Improper 404 redirect from server.)\n")
+                                                                                       fetched = 0
+                                                                                       continue
+                                                                               except (IOError, OSError):
+                                                                                       pass
                                                                fetched = 1
                                                                continue
                                                        if not fetchonly:
@@ -3681,9 +3666,7 @@ def movefile(src,dest,newmtime=None,sstat=None,mysettings=None):
        destexists=1
        try:
                dstat=os.lstat(dest)
-       except SystemExit, e:
-               raise
-       except:
+       except (OSError, IOError):
                dstat=os.lstat(os.path.dirname(dest))
                destexists=0
 
@@ -5084,9 +5067,7 @@ class vardbapi(dbapi):
                        return mymatch
                try:
                        curmtime=os.stat(self.root+VDB_PATH+"/"+mycat)[stat.ST_MTIME]
-               except SystemExit, e:
-                       raise
-               except:
+               except (IOError, OSError):
                        curmtime=0
 
                if not self.matchcache.has_key(mycat) or not self.mtdircache[mycat]==curmtime:
@@ -5249,9 +5230,7 @@ class vardbapi(dbapi):
                                try:
                                        old_counter = long(self.aux_get(x,["COUNTER"])[0])
                                        writemsg("COUNTER '%d' '%s'\n" % (old_counter, x),1)
-                               except SystemExit, e:
-                                       raise
-                               except:
+                               except (ValueError, KeyError): # valueError from long(), KeyError from aux_get
                                        old_counter = 0
                                        writemsg("!!! BAD COUNTER in '%s'\n" % (x), noiselevel=-1)
                                if old_counter > min_counter:
@@ -5285,9 +5264,7 @@ class vardbapi(dbapi):
                                counter = long(commands.getoutput(find_counter).strip())
                                writemsg("!!! Global counter missing. Regenerated from counter files to: %s\n" % counter,
                                        noiselevel=-1)
-                       except SystemExit, e:
-                               raise
-                       except:
+                       except ValueError: # Value Error for long(), probably others for commands.getoutput
                                writemsg("!!! Initializing global counter.\n", noiselevel=-1)
                                counter=long(0)
                        changed=1
@@ -5596,13 +5573,13 @@ class portdbapi(dbapi):
        def finddigest(self,mycpv):
                try:
                        mydig   = self.findname2(mycpv)[0]
+                       if not mydig:
+                               return ""
                        mydigs  = string.split(mydig, "/")[:-1]
                        mydig   = string.join(mydigs, "/")
 
                        mysplit = mycpv.split("/")
-               except SystemExit, e:
-                       raise
-               except:
+               except OSError:
                        return ""
                return mydig+"/files/digest-"+mysplit[-1]
 
@@ -6410,9 +6387,7 @@ class binarytree(object):
                                chunk_size = long(self.settings["PORTAGE_BINHOST_CHUNKSIZE"])
                                if chunk_size < 8:
                                        chunk_size = 8
-                       except SystemExit, e:
-                               raise
-                       except:
+                       except (ValueError, KeyError):
                                chunk_size = 3000
 
                        writemsg(green("Fetching binary packages info...\n"))
@@ -6515,9 +6490,7 @@ class binarytree(object):
                mydest = self.pkgdir+"/All/"
                try:
                        os.makedirs(mydest, 0775)
-               except SystemExit, e:
-                       raise
-               except:
+               except (OSError, IOError):
                        pass
                return getbinpkg.file_get(
                        self.settings["PORTAGE_BINHOST"] + "/" + tbz2name,
@@ -6950,7 +6923,7 @@ class dblink:
                        os.path.join(destroot, filename.lstrip(os.path.sep)))
                try:
                        mylstat = os.lstat(destfile)
-               except OSError:
+               except (OSError, IOError):
                        return True
 
                pkgfiles = self.getcontents()
@@ -7157,9 +7130,7 @@ class dblink:
                                sys.exit(1)
                        try:
                                os.chdir(mycwd)
-                       except SystemExit, e:
-                               raise
-                       except:
+                       except OSError:
                                pass
 
                if os.stat(srcroot).st_dev == os.stat(destroot).st_dev:
@@ -7363,8 +7334,6 @@ class dblink:
                        # stat file once, test using S_* macros many times (faster that way)
                        try:
                                mystat=os.lstat(mysrc)
-                       except SystemExit, e:
-                               raise
                        except OSError, e:
                                writemsg("\n")
                                writemsg(red("!!! ERROR: There appears to be ")+bold("FILE SYSTEM CORRUPTION.")+red(" A file that is listed\n"))
index f6131cc470c97d7bc2dbb01e65e1ac0c14c1ed36..8abacfe3fe13b887cea11c699dc292b8d7da69fa 100644 (file)
@@ -18,7 +18,7 @@
 # "a? ( b? ( z ) ) -- Valid
 #
 
-import re, string, sys, types
+import re,  sys, types
 import portage_exception
 from portage_exception import InvalidData
 from portage_versions import catpkgsplit, catsplit, pkgcmp, pkgsplit, ververify
@@ -180,7 +180,7 @@ def use_reduce(deparray, uselist=[], masklist=[], matchall=0, excludeall=[]):
                                        sys.stderr.write("Note: Nested use flags without parenthesis (Deprecated)\n")
                                        warned = 1
                                if warned:
-                                       sys.stderr.write("  --> "+string.join(map(str,[head]+newdeparray))+"\n")
+                                       sys.stderr.write("  --> "+"".join(map(str,[head]+newdeparray))+"\n")
 
                                # Check that each flag matches
                                ismatch = True
@@ -618,7 +618,7 @@ def match_from_list(mydep, candidate_list):
                for x in candidate_list:
                        try:
                                result = pkgcmp(pkgsplit(x), mysplit)
-                       except ValueError:
+                       except ValueError: # pkgcmp may return ValueError during int() conversion
                                writemsg("\nInvalid package name: %s\n" % x, noiselevel=-1)
                                raise
                        if result is None:
index 77f3da66ec5993ea368af825250a45d395723318..c7dc28d4706cc79d76e953f2c025ec8f2c83dbd1 100644 (file)
@@ -84,7 +84,7 @@ def run_exitfuncs():
                        func(*targs, **kargs)
                except SystemExit:
                        exc_info = sys.exc_info()
-               except:
+               except: # No idea what they called, so we need this broad except here.
                        dump_traceback("Error in portage_exec.run_exitfuncs", noiselevel=0)
                        exc_info = sys.exc_info()
 
index 340fe46f89dbe1127e6eb95147966fa6df318a80..6214011823a4ad11c122e0bcb6262ed30f290f35 100644 (file)
@@ -7,7 +7,6 @@
 import errno
 import os
 import stat
-import string
 import time
 import types
 import portage_exception
@@ -265,11 +264,11 @@ def hardlock_cleanup(path, remove_all_locks=False):
        mylist = {}
        for x in mydl:
                if os.path.isfile(path+"/"+x):
-                       parts = string.split(x, ".hardlock-")
+                       parts = x.split(".hardlock-")
                        if len(parts) == 2:
                                filename = parts[0]
-                               hostpid  = string.split(parts[1],"-")
-                               host  = string.join(hostpid[:-1], "-")
+                               hostpid  = parts[1].split("-")
+                               host  = "-".join(hostpid[:-1])
                                pid   = hostpid[-1]
                                
                                if not mylist.has_key(filename):
index f156c39bccc1996392960b0362e2b1ab8b282943..1a2a1d8841ed5c697f4fbaedb01f875aa1978561 100644 (file)
@@ -188,7 +188,13 @@ def update_config_files(config_root, protect, protect_mask, update_iter):
                                        line = file_contents[x][mypos]
                                        if line[0] == "#" or not line.strip():
                                                continue
-                                       key = dep_getkey(line.split()[0])
+                                       myatom = line.split()[0]
+                                       if myatom.startswith("-"):
+                                               # package.mask supports incrementals
+                                               myatom = myatom[1:]
+                                       if not isvalidatom(myatom):
+                                               continue
+                                       key = dep_getkey(myatom)
                                        if key == old_value:
                                                file_contents[x][mypos] = \
                                                        line.replace(old_value, new_value)
index 374d9061689545ce48ceb5a3dd07458adba2a8f1..79724b51a70482ab96b7f18547ddde6426e0f29e 100644 (file)
@@ -47,16 +47,16 @@ def grabfile(myfilename, compat_level=0, recursive=0):
        for x in mylines:
                #the split/join thing removes leading and trailing whitespace, and converts any whitespace in the line
                #into single spaces.
-               myline=string.join(string.split(x))
+               myline="".join(x.split())
                if not len(myline):
                        continue
                if myline[0]=="#":
                        # Check if we have a compat-level string. BC-integration data.
                        # '##COMPAT==>N<==' 'some string attached to it'
-                       mylinetest = string.split(myline, "<==", 1)
+                       mylinetest = myline.split("<==",1)
                        if len(mylinetest) == 2:
                                myline_potential = mylinetest[1]
-                               mylinetest = string.split(mylinetest[0],"##COMPAT==>")
+                               mylinetest = mylinetest[0].split("##COMPAT==>")
                                if len(mylinetest) == 2:
                                        if compat_level >= int(mylinetest[1]):
                                                # It's a compat line, and the key matches.
@@ -154,7 +154,7 @@ def stack_dicts(dicts, incremental=0, incrementals=[], ignore_none=0):
                                        final_dict[y] += " "+mydict[y][:]
                                else:
                                        final_dict[y]  = mydict[y][:]
-                       mydict[y] = string.join(mydict[y].split()) # Remove extra spaces.
+                       mydict[y] = "".join(mydict[y].split()) # Remove extra spaces.
        return final_dict
 
 def stack_lists(lists, incremental=1):
@@ -205,7 +205,7 @@ def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1):
                #into single spaces.
                if x[0] == "#":
                        continue
-               myline=string.split(x)
+               myline=x.split()
                if len(myline) < 2 and empty == 0:
                        continue
                if len(myline) < 1 and empty == 1:
index 16073ba7aeb2dc768403f7762722ffd453dc7d2d..0127e029bef2b2e74e4b0bd1a5312c0d5b6b4f03 100644 (file)
@@ -3,7 +3,7 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-import re,string
+import re
 
 # PREFIX hack: -r(\\d+) -> -r(\\d+|0\\d+\\.\\d+) (see below)
 ver_regexp = re.compile("^(cvs\\.)?(\\d+)((\\.\\d+)*)([a-z]?)((_(pre|p|beta|alpha|rc)\\d*)*)(-r(\\d+|0\\.\\d+))?$")
@@ -89,18 +89,18 @@ def vercmp(ver1, ver2, silent=1):
                        # are given the same value (in sorting, for example).
                        if len(vlist1) <= i or len(vlist1[i]) == 0:
                                list1.append(-1)
-                               list2.append(string.atoi(vlist2[i]))
+                               list2.append(int(vlist2[i]))
                        elif len(vlist2) <= i or len(vlist2[i]) == 0:
-                               list1.append(string.atoi(vlist1[i]))
+                               list1.append(int(vlist1[i]))
                                list2.append(-1)
                        # Let's make life easy and use integers unless we're forced to use floats
                        elif (vlist1[i][0] != "0" and vlist2[i][0] != "0"):
-                               list1.append(string.atoi(vlist1[i]))
-                               list2.append(string.atoi(vlist2[i]))
+                               list1.append(int(vlist1[i]))
+                               list2.append(int(vlist2[i]))
                        # now we have to use floats so 1.02 compares correctly against 1.1
                        else:
-                               list1.append(string.atof("0."+vlist1[i]))
-                               list2.append(string.atof("0."+vlist2[i]))
+                               list1.append(float("0."+vlist1[i]))
+                               list2.append(float("0."+vlist2[i]))
 
        # and now the final letter
        if len(match1.group(5)):
@@ -137,9 +137,9 @@ def vercmp(ver1, ver2, silent=1):
                if s1[1] != s2[1]:
                        # it's possible that the s(1|2)[1] == ''
                        # in such a case, fudge it.
-                       try:                    r1 = string.atoi(s1[1])
+                       try:                    r1 = int(s1[1])
                        except ValueError:      r1 = 0
-                       try:                    r2 = string.atoi(s2[1])
+                       try:                    r2 = int(s2[1])
                        except ValueError:      r2 = 0
                        return r1 - r2
        
@@ -153,16 +153,16 @@ def vercmp(ver1, ver2, silent=1):
        # while still staying in the main tree versioning scheme.
        if match1.group(10):
                if match1.group(10)[0] == '0':
-                       r1 = string.atof(match1.group(10)[1:])
+                       r1 = float(match1.group(10)[1:])
                else:
-                       r1 = string.atoi(match1.group(10))
+                       r1 = int(match1.group(10))
        else:
                r1 = 0
        if match2.group(10):
                if match2.group(10)[0] == '0':
-                       r2 = string.atof(match2.group(10)[1:])
+                       r2 = float(match2.group(10)[1:])
                else:
-                       r2 = string.atoi(match2.group(10))
+                       r2 = int(match2.group(10))
        else:
                r2 = 0
        vercmp_cache[mykey] = r1 - r2
@@ -197,8 +197,8 @@ def pkgcmp(pkg1, pkg2):
                return 1
        if mycmp<0:
                return -1
-       r1=string.atof(pkg1[2][1:])
-       r2=string.atof(pkg2[2][1:])
+       r1=float(pkg1[2][1:])
+       r2=float(pkg2[2][1:])
        if r1>r2:
                return 1
        if r2>r1:
@@ -215,7 +215,7 @@ def pkgsplit(mypkg,silent=1):
                return pkgcache[mypkg][:]
        except KeyError:
                pass
-       myparts=string.split(mypkg,'-')
+       myparts=mypkg.split("-")
        
        if len(myparts)<2:
                if not silent:
@@ -235,9 +235,9 @@ def pkgsplit(mypkg,silent=1):
        if len(myrev) and myrev[0]=="r":
                try:
                        # PREFIX hack: allow floats in revisions
-                       string.atof(myrev[1:])
+                       float(myrev[1:])
                        revok=1
-               except: 
+               except ValueError: # from int()
                        pass
        if revok:
                verPos = -2
@@ -256,7 +256,7 @@ def pkgsplit(mypkg,silent=1):
                                        pkgcache[mypkg]=None
                                        return None
                                        #names can't have versiony looking parts
-                       myval=[string.join(myparts[:verPos],"-"),myparts[verPos],revision]
+                       myval=["-".join(myparts[:verPos]),myparts[verPos],revision]
                        pkgcache[mypkg]=myval
                        return myval
        else:
index f72fed804a308b386b94b5ded28a10aee3003289..2700bef09b908c00ed5a20225490458997f78810 100644 (file)
@@ -16,7 +16,7 @@
 # (integer) == encodeint(integer)  ===> 4 characters (big-endian copy)
 # '+' means concatenate the fields ===> All chunks are strings
 
-import sys,os,string,shutil,errno
+import sys,os,shutil,errno
 from stat import *
 
 def addtolist(mylist,curdir):
@@ -353,7 +353,7 @@ class tbz2:
                mydat=self.getfile(myfile)
                if not mydat:
                        return []
-               return string.split(mydat)
+               return mydat.split()
 
        def unpackinfo(self,mydest):
                """Unpacks all the files from the dataSegment into 'mydest'."""
index e1c0ae5951b0993292e90b00781386ff7f0e83f7..920c2f7e3822b0601ba8b8a50641068e8e9c5de1 100644 (file)
@@ -1,4 +1,4 @@
 # tests/portage/__init__.py -- Portage Unit Test functionality
 # Copyright 2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: __init__.py 5522 2007-01-10 12:30:05Z antarus $
+# $Id$
index e1c0ae5951b0993292e90b00781386ff7f0e83f7..920c2f7e3822b0601ba8b8a50641068e8e9c5de1 100644 (file)
@@ -1,4 +1,4 @@
 # tests/portage/__init__.py -- Portage Unit Test functionality
 # Copyright 2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: __init__.py 5522 2007-01-10 12:30:05Z antarus $
+# $Id$
index 90e1b6e56bc30524b68f320e4a84e18233ad8210..3652169d4d798e4af3af219cdb7191375a31182a 100644 (file)
@@ -1,7 +1,7 @@
 # test_dep_getcpv.py -- Portage Unit Testing Functionality
 # Copyright 2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_atoms.py 5525 2007-01-10 13:35:03Z antarus $
+# $Id$
 
 from unittest import TestCase
 from portage_dep import dep_getcpv
index 5e18d7cd4acc2f396665558db6da18530280858e..fc5a6e3cd212e3ddda1969f10b1e27127fe509c3 100644 (file)
@@ -1,7 +1,7 @@
 # test_dep_getslot.py -- Portage Unit Testing Functionality
 # Copyright 2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_atoms.py 5525 2007-01-10 13:35:03Z antarus $
+# $Id$
 
 from unittest import TestCase
 from portage_dep import dep_getslot
index ec052d9146a8770e8485bb48b81cc7f158b25cef..72063f39ab48594059bc4cf5ba4b5066956248b1 100644 (file)
@@ -1,7 +1,7 @@
 # test_match_from_list.py -- Portage Unit Testing Functionality
 # Copyright 2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_atoms.py 5525 2007-01-10 13:35:03Z antarus $
+# $Id$
 
 from unittest import TestCase
 from portage_dep import get_operator
index a8a4e24bef089f62c69961e557153d5f0874d7cc..1e152e73d114f39104c3d8e03a0bbe5e68d2a085 100644 (file)
@@ -1,7 +1,7 @@
 # test_isjustname.py -- Portage Unit Testing Functionality
 # Copyright 2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_atoms.py 5525 2007-01-10 13:35:03Z antarus $
+# $Id$
 
 from unittest import TestCase
 from portage_dep import isjustname
index 7835fbd0c984a3be8ddd4b32a017827f9e250013..f1410366ce994d60af69b3cf0b801e6d7fcef9b9 100644 (file)
@@ -1,7 +1,7 @@
 # test_isvalidatom.py -- Portage Unit Testing Functionality
 # Copyright 2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_atoms.py 5525 2007-01-10 13:35:03Z antarus $
+# $Id$
 
 from unittest import TestCase
 from portage_dep import isvalidatom
index 4526d4e312677a87981aae691d2fd08bd288231a..d9d53ccbd29d1a0330bfc11fcca219eb9610f6ce 100644 (file)
@@ -1,7 +1,7 @@
 # test_match_from_list.py -- Portage Unit Testing Functionality
 # Copyright 2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_atoms.py 5525 2007-01-10 13:35:03Z antarus $
+# $Id$
 
 from unittest import TestCase
 from portage_dep import match_from_list
index ede012f667338c568a030ed70139e0e5773b3f50..9325f85f14dc625789428ead6a3d0bdcef3321d0 100644 (file)
@@ -1,5 +1,5 @@
 # tests/portage_util/__init__.py -- Portage Unit Test functionality
 # Copyright 2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: __init__.py 5522 2007-01-10 12:30:05Z antarus $
+# $Id$
 
index 74b28ca27b8bc0d3fc8a37d68d4020986682f6c1..9b995fa2494402f89543680a6d04e3364c99ee14 100644 (file)
@@ -1,7 +1,7 @@
 # test_grabDict.py -- Portage Unit Testing Functionality
 # Copyright 2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_vercmp.py 5213 2006-12-08 00:12:41Z antarus $
+# $Id$
 
 from unittest import TestCase, TestLoader
 from portage_util import grabdict
index 3354e254e9f41b5f1eef7f6157e65e94ae6866ea..9740306aa3114d5d0ae31cdd6f73b55f5109f97b 100644 (file)
@@ -1,7 +1,7 @@
 # test_normalizePath.py -- Portage Unit Testing Functionality
 # Copyright 2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_vercmp.py 5213 2006-12-08 00:12:41Z antarus $
+# $Id$
 
 from unittest import TestCase
 
index 02284e8f4400ad5c5ca2f73d02fe98293177e432..45b67b83898cb35593ece1e56f0c6c315d3d0880 100644 (file)
@@ -1,7 +1,7 @@
 # test_stackDictList.py -- Portage Unit Testing Functionality
 # Copyright 2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_vercmp.py 5213 2006-12-08 00:12:41Z antarus $
+# $Id$
 
 from unittest import TestCase
 
index 98467b5a56a4d7b517f32c45471c8d72ee0452cf..7293004b603da1e42f70ffd9b1c1c7796d9e449f 100644 (file)
@@ -1,7 +1,7 @@
 # test_stackDicts.py -- Portage Unit Testing Functionality
 # Copyright 2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_vercmp.py 5213 2006-12-08 00:12:41Z antarus $
+# $Id$
 
 from unittest import TestCase
 from portage_util import stack_dicts
index c4e1e005627bdb81ec0cc569e44381a73bd0d45c..9a88902da48f8e52e0fd1a798fb6edd3f658913d 100644 (file)
@@ -1,7 +1,7 @@
 # test_stackLists.py -- Portage Unit Testing Functionality
 # Copyright 2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_vercmp.py 5213 2006-12-08 00:12:41Z antarus $
+# $Id$
 
 from unittest import TestCase
 from portage_util import stack_lists
index bc0b750b994c80d679e342b6627f732d7ffb49b3..c9c9e217d3ee5691f839e91395460670170a9d44 100644 (file)
@@ -1,7 +1,7 @@
 # test_uniqueArray.py -- Portage Unit Testing Functionality
 # Copyright 2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_vercmp.py 5213 2006-12-08 00:12:41Z antarus $
+# $Id$
 
 from unittest import TestCase
 from portage_util import unique_array
index f3602727359f3eb777c18797a164c5e72aca4711..0515bf7e56c116711da53a615085559b1e07c5c1 100644 (file)
@@ -1,7 +1,7 @@
 # test_varExpand.py -- Portage Unit Testing Functionality
 # Copyright 2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_vercmp.py 5213 2006-12-08 00:12:41Z antarus $
+# $Id$
 
 from unittest import TestCase, TestLoader
 from portage_util import varexpand
index e1c0ae5951b0993292e90b00781386ff7f0e83f7..920c2f7e3822b0601ba8b8a50641068e8e9c5de1 100644 (file)
@@ -1,4 +1,4 @@
 # tests/portage/__init__.py -- Portage Unit Test functionality
 # Copyright 2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: __init__.py 5522 2007-01-10 12:30:05Z antarus $
+# $Id$