Catch ENOENT errors when $PORTDIR/profiles/updates does not exist.
authorZac Medico <zmedico@gentoo.org>
Tue, 7 Mar 2006 01:53:44 +0000 (01:53 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 7 Mar 2006 01:53:44 +0000 (01:53 -0000)
svn path=/main/trunk/; revision=2821

pym/portage.py
pym/portage_update.py

index f2bf9d6d6400e9255b2ae03dc407d6ec7e58b12c..e3d5ad742ed5d8ee2902d6ed72a3d64474e85d92 100644 (file)
@@ -6850,10 +6850,14 @@ def global_updates():
        updpath = os.path.join(settings["PORTDIR"], "profiles", "updates")
        if not mtimedb.has_key("updates"):
                mtimedb["updates"] = {}
-       if settings["PORTAGE_CALLER"] == "fixpackages":
-               update_data = grab_updates(updpath)
-       else:
-               update_data = grab_updates(updpath, mtimedb["updates"])
+       try:
+               if settings["PORTAGE_CALLER"] == "fixpackages":
+                       update_data = grab_updates(updpath)
+               else:
+                       update_data = grab_updates(updpath, mtimedb["updates"])
+       except portage_exception.DirectoryNotFound:
+               writemsg("--- 'profiles/updates' is empty or not available. Empty portage tree?\n")
+               return
        if len(update_data) > 0:
                do_upgrade_packagesmessage = 0
                myupd = []
index a33bc918826c60cb90317d4681b6795423f741b3..f2d0675d19db082a7aad5df6cc2718da3d46a46e 100644 (file)
@@ -1,7 +1,8 @@
 
-import os, re
+import errno, os, re
 
 from portage_util import write_atomic
+from portage_exception import DirectoryNotFound
 
 ignored_dbentries = ("CONTENTS", "environment.bz2")
 
@@ -49,7 +50,13 @@ def grab_updates(updpath, prev_mtimes=None):
        """Returns all the updates from the given directory as a sorted list of
        tuples, each containing (file_path, statobj, content).  If prev_mtimes is
        given then only updates with differing mtimes are considered."""
-       mylist = os.listdir(updpath)
+       try:
+               mylist = os.listdir(updpath)
+       except OSError, oe:
+               if oe.errno == errno.ENOENT:
+                       raise DirectoryNotFound(oe)
+               else:
+                       raise oe
        if prev_mtimes is None:
                prev_mtimes = {}
        # validate the file name (filter out CVS directory, etc...)