This snippet is based on #844 and updates all apps in the current directory using hg, svn, git or bzr.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #!/usr/env/python
import os
import os.path
from subprocess import call
if __name__ == "__main__":
apps_dir = os.path.abspath('.')
for app_name in os.listdir(apps_dir):
app_dir = os.path.abspath(os.path.join(apps_dir, app_name))
git_path = os.path.join(app_dir, '.git')
svn_path = os.path.join(app_dir, '.svn')
hg_path = os.path.join(app_dir, '.hg')
bzr_path = os.path.join(app_dir, '.bzr')
if os.path.lexists(svn_path):
print "Updating svn %s" % app_dir
os.chdir(app_dir)
call(['svn', 'update'])
elif os.path.lexists(git_path):
print "Updating git %s" % app_dir
os.chdir(app_dir)
call(['git', 'pull'])
elif os.path.lexists(hg_path):
print "Updating hg %s" % app_dir
os.chdir(app_dir)
call(['hg', 'pull', '-u'])
if os.path.lexists(bzr_path):
print "Updating bzr %s" % app_dir
os.chdir(app_dir)
call(['bzr', 'update'])
else:
continue
|
More like this
- Template tag - list punctuation for a list of items by shapiromatron 10 months, 3 weeks ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 11 months ago
- Serializer factory with Django Rest Framework by julio 1 year, 5 months ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 6 months ago
- Help text hyperlinks by sa2812 1 year, 7 months ago
Comments
Cool! It would be nice if it detected if you had each VCS on your system, too. I wonder if that's easy.
#
What about searching for apps in subdirs? Let's say I have:
with some apps, and
with apps related to Django. And I want to update all my apps under my lib dir.
#
@dedaluz The script uses the current path (
.
) so you can do something like this:Or do I misunderstand your problem?
#
Please login first before commenting.