Skip to content

Instantly share code, notes, and snippets.

@dhylands
Created September 25, 2013 17:16
Show Gist options
  • Save dhylands/6702902 to your computer and use it in GitHub Desktop.
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
#!/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