diff options
author | Devan Franchini <twitch153@gentoo.org> | 2013-11-05 17:11:07 -0500 |
---|---|---|
committer | Devan Franchini <twitch153@gentoo.org> | 2014-01-24 22:11:45 -0500 |
commit | af1bd6b54ef751af96ec800e256a6e91412401e8 (patch) | |
tree | a45c20a50a16c9edc1806b99b3df4d37858030ab | |
parent | WebappConfig/ebuild.py Restores changes done by previous commit. (diff) | |
download | webapp-config-af1bd6b54ef751af96ec800e256a6e91412401e8.tar.gz webapp-config-af1bd6b54ef751af96ec800e256a6e91412401e8.tar.bz2 webapp-config-af1bd6b54ef751af96ec800e256a6e91412401e8.zip |
WebappConfig/db.py: Adds prune_db() function.
This function will check for "stray" webapp installation entries in
the installs files located in /var/db/webapps/<package name>/<version>.
This function is not implemented yet.
X-Gentoo-Bug: 490090
X-Gentoo-Bug-URL: https://bugs.gentoo.org/490090
-rw-r--r-- | WebappConfig/db.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/WebappConfig/db.py b/WebappConfig/db.py index 11e5dae..37bfdc9 100644 --- a/WebappConfig/db.py +++ b/WebappConfig/db.py @@ -424,6 +424,43 @@ class WebappDB(AppHierarchy): return result + def prune_db(self): + ''' + Prunes the installs files to ensure no webapp + is incorrectly listed as installed. + ''' + + loc = self.read_db() + + if not loc and self.__v: + OUT.die('No virtual installs found!') + + files = self.list_locations() + keys = sorted(loc) + + for j in keys: + for i in loc[j]: + appdir = i[3].strip() + # We check to see if the webapp is installed. + if not os.path.exists(appdir+'/.webapp'): + if self.__v: + OUT.warn('No .webapp file found in dir: ') + OUT.warn(appdir) + OUT.warn('Assuming webapp is no longer installed.') + OUT.warn('Pruning entry from database.') + + for installs in files.keys(): + contents = open(installs).readlines() + new_entries = '' + for entry in contents: + # Grab all the other entries but the one that + # isn't installed. + if not re.search('.* ' + appdir +'\\n', entry): + new_entries += entry + f = open(installs, 'w') + f.write(new_entries) + f.close() + def has_installs(self): ''' Return True in case there are any virtual install locations listed in the db file ''' |