On Jul 16, 8:34*am, Alia Khouri <alia_kho...@yahoo.comwrote:
Here's a very simple snippet I use to automatically keep my versioned
sources fresh.. Posted here in case it may be of use to anybody...
<code>
#!/usr/local/bin/python
import os, sys
src = '/Users/ak/Code/src'
# utility functions
join, isdir, listdir = os.path.join, os.path.isdir
def run(cmd):
* * print cmd
* * os.system(cmd)
ops = {
* * '.bzr': ['bzr pull', 'bzr update'],
* * '.hg': ['hg pull', 'hg update'],
* * '.svn': ['svn update']
}
for folder in os.listdir(src):
* * target = os.path.join(src,folder)
* * if os.path.isdir(target):
* * * * internal = os.listdir(target)
* * * * for f in internal:
* * * * * * if f in ops:
* * * * * * * * print
* * * * * * * * os.chdir(target)
* * * * * * * * cmds = ops[f]
* * * * * * * * print
* * * * * * * * print target, '-->',
* * * * * * * * for cmd in cmds:
* * * * * * * * * * run(cmd)
</code>
My bad...., here's the one that actually (-:
<code>
#!/usr/local/bin/python
import os, sys
src = '/Users/sa/Code/src'
# utility functions
join, isdir = os.path.join, os.path.isdir
def run(cmd):
print cmd
os.system(cmd)
ops = {
'.bzr': ['bzr pull', 'bzr update'],
'.hg': ['hg pull', 'hg update'],
'.svn': ['svn update']
}
for folder in os.listdir(src):
target = join(src,folder)
if isdir(target):
internal = os.listdir(target)
for f in internal:
if f in ops:
print
# print f, target
os.chdir(target)
cmds = ops[f]
print
print target, '-->',
for cmd in cmds:
run(cmd)
</code>