Fix error handling for getlist().
authorZac Medico <zmedico@gentoo.org>
Fri, 23 Jun 2006 08:03:54 +0000 (08:03 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 23 Jun 2006 08:03:54 +0000 (08:03 -0000)
svn path=/main/trunk/; revision=3622

bin/emerge

index 89241d33dc0b76eb8ed4ce4195760c84809714d1..b5e043190aaf05f28f3cb83364df08a0b0db2b92 100755 (executable)
@@ -853,20 +853,16 @@ def getlist(mode):
                mylines=portage.settings.packages
        elif mode=="world":
                try:
-                       myfile = open(os.path.join(portage.root, portage.WORLD_FILE), "r")
-                       mylines=myfile.readlines()
+                       file_path = os.path.join(portage.root, portage.WORLD_FILE)
+                       myfile = open(file_path, "r")
+                       mylines = myfile.readlines()
                        myfile.close()
-               except OSError:
-                       print "!!! Couldn't open "+pfile+"; exiting."
-                       sys.exit(1)
-               except IOError, e:
-                       #Permission denied is a fatal error, as opposed to a missing file
-                       if e.errno == errno.EACCES:
-                               raise
-                       else:
-                               if "--quiet" not in myopts:
-                                       portage.writemsg(red("\n!!! ") + "Warning %s does not exist.\n" % os.path.join(portage.root, portage.WORLD_FILE) )
+               except (OSError, IOError), e:
+                       if e.errno == errno.ENOENT:
+                               portage.writemsg("\n!!! World file does not exist: '%s'\n" % file_path)
                                mylines=[]
+                       else:
+                               raise
        mynewlines=[]
        for x in mylines:
                myline=string.join(string.split(x))