[r7423]: website / externals.py Maximize Restore History

Download this file

externals.py    52 lines (43 with data), 1.5 kB

 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
import os
import sys
import subprocess
import re
externals = {"site_resources" : "http://svn.turbogears.org/site_resources/",
"ez_setup" : "svn://svn.eby-sarna.com/svnroot/ez_setup/",
}
urlline = re.compile("^URL: (.*)")
def update(proj):
os.chdir(proj)
svninfo = subprocess.Popen(["svn", "info"], stdout=subprocess.PIPE)
out = svninfo.stdout
line = out.readline()
while line:
line = out.readline()
url = urlline.match(line)
if url:
url = url.group(1).strip()
if url != externals[proj] and url != externals[proj][:-1]:
print "Switching project %s to %s" % (proj, externals[proj])
svnswitch = subprocess.call(["svn", "switch", externals[proj], "."])
else:
print "Updating project %s" % (proj)
svnupdate = subprocess.call(["svn", "update"])
break
if not url:
print "Error! Unable to find URL for project %s"
os.chdir("..")
def checkout(proj):
print "Checking out %s" % (proj)
svncheckout = subprocess.call(["svn", "checkout", externals[proj], proj])
def run():
if not os.path.exists("externals.py"):
print "You must run this script from the top directory."
sys.exit(1)
for proj in externals:
if os.path.exists(proj):
update(proj)
else:
checkout(proj)
if __name__ == "__main__":
run()