diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2010-06-29 11:23:31 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2010-06-29 11:23:31 +0200 |
| commit | 508f1ddb5b6a0cc69655e39dbd59fe3466173a84 (patch) | |
| tree | 0c8688b9adbea946ca41757e0c446d8374e06657 /apt/cache.py | |
| parent | cdaebccd5f7a5a0e23a9be7989b64850fabafed1 (diff) | |
| download | python-apt-508f1ddb5b6a0cc69655e39dbd59fe3466173a84.tar.gz | |
* apt/cache.py:
- add new "dpkg_journal_dirty" property that can be used to
detect a interrupted dpkg (the famous
"E: dpkg was interrupted, you must manually run 'dpkg --configure -a'")
Diffstat (limited to 'apt/cache.py')
| -rw-r--r-- | apt/cache.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/apt/cache.py b/apt/cache.py index 3679e4ba..3962bb4f 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -19,6 +19,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA +import fnmatch import os import weakref @@ -455,6 +456,20 @@ class Cache(object): return apt_pkg.ActionGroup(self._depcache) @property + def dpkg_journal_dirty(self): + """Return True if the dpkg was interrupted + + All dpkg operations will fail until this is fixed, the action to + fix the system if dpkg got interrupted is to run + 'dpkg --configure -a' as root. + """ + dpkg_status_dir = os.path.dirname(apt_pkg.Config.find_file("Dir::State::status")) + for f in os.listdir(os.path.join(dpkg_status_dir, "updates")): + if fnmatch.fnmatch(f, "[0-9]*"): + return True + return False + + @property def broken_count(self): """Return the number of packages with broken dependencies.""" return self._depcache.broken_count |
