Created
September 25, 2013 17:16
-
-
Save dhylands/6702902 to your computer and use it in GitHub Desktop.
Removes an app from a directory tree, and also updates webapps.json to remove the app from there as well. Usage: remove-app.py <webapps-directory> webapp ... For example: remove-app.py gaia/profile/webapps uitest.gaiamobile.org cubevid.gaiamobile.org
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import json | |
import sys, string, os | |
import shutil | |
webapps_dir = sys.argv[1] | |
webapps_filename = os.path.join(webapps_dir, "webapps.json") | |
webapps = json.load(open(webapps_filename)) | |
del sys.argv[0] | |
del sys.argv[0] | |
for webapp in sys.argv: | |
if webapp not in webapps: | |
print "Webapp '%s' not found in webapps.json file" % webapp | |
continue | |
webapp_dir = os.path.join(webapps_dir, webapp) | |
if not os.path.isdir(webapp_dir): | |
print "Webapp directory '%s' not found" % webapp | |
continue | |
print "Removing webapp '%s'" % webapp | |
del webapps[webapp] | |
shutil.rmtree(webapp_dir) | |
json.dump(webapps, open(webapps_filename, "w"), indent=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment