diff options
author | Zac Medico <zmedico@gentoo.org> | 2006-03-07 01:53:44 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2006-03-07 01:53:44 +0000 |
commit | 4fa498dee32248291386428d9a64c1f130ec1df5 (patch) | |
tree | ee33af5781bd54e3180c7eaf7e4ff5eb6b902f67 | |
parent | 23eb7737da6eed79a1d79f5ee6dc722b78481cca (diff) | |
download | portage-4fa498dee32248291386428d9a64c1f130ec1df5.tar.gz portage-4fa498dee32248291386428d9a64c1f130ec1df5.tar.bz2 portage-4fa498dee32248291386428d9a64c1f130ec1df5.zip |
Catch ENOENT errors when $PORTDIR/profiles/updates does not exist.
svn path=/main/trunk/; revision=2821
-rw-r--r-- | pym/portage.py | 12 | ||||
-rw-r--r-- | pym/portage_update.py | 11 |
2 files changed, 17 insertions, 6 deletions
diff --git a/pym/portage.py b/pym/portage.py index f2bf9d6d6..e3d5ad742 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -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 = [] diff --git a/pym/portage_update.py b/pym/portage_update.py index a33bc9188..f2d0675d1 100644 --- a/pym/portage_update.py +++ b/pym/portage_update.py @@ -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...) |