comparison buttercup/checkout.py @ 31:f6b768417d27

now listing kinda works
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 31 May 2011 07:39:07 -0700
parents a54543838686
children 86c3c0d4d434
comparison
equal deleted inserted replaced
30:6089d6ec745a 31:f6b768417d27
8 # pip install --editable hg+https://slinkp@bitbucket.org/slinkp/purplevoter#egg=purplevoter 8 # pip install --editable hg+https://slinkp@bitbucket.org/slinkp/purplevoter#egg=purplevoter
9 # -or - 9 # -or -
10 # pip install -r foo.txt 10 # pip install -r foo.txt
11 11
12 import os 12 import os
13 import source
13 import sys 14 import sys
14 import subprocess 15 import subprocess
15 from buttercup import Buttercup 16 from buttercup import Buttercup
16 from optparse import OptionParser 17 from optparse import OptionParser
17 18
54 help="list the source to be installed") 55 help="list the source to be installed")
55 options, args = parser.parse_args(args) 56 options, args = parser.parse_args(args)
56 57
57 # list sources if specified 58 # list sources if specified
58 if options.list: 59 if options.list:
59 for source in sources: 60 buttercup = Buttercup(srcdir=None)
60 print '%s: %s' % (source[0], source[1]) 61 sources = source.sources(buttercup.sources)
62 for s in sources:
63 print '%s: %s' % (s.directory_name(s.uri), s.uri)
61 sys.exit(0) 64 sys.exit(0)
62 65
63 # setup the src directory in a virtualenv 66 # setup the src directory in a virtualenv
64 assert 'VIRTUAL_ENV' in os.environ, "You must have a virtualenv activated" 67 assert 'VIRTUAL_ENV' in os.environ, "You must have a virtualenv activated"
65 src = os.path.join(os.environ['VIRTUAL_ENV'], 'src') 68 src = os.path.join(os.environ['VIRTUAL_ENV'], 'src')
66 if not os.path.exists(src): 69 if not os.path.exists(src):
67 os.mkdir(src) 70 os.mkdir(src)
68 os.chdir(src) 71 os.chdir(src)
69 72
70 # clone the sources 73 # clone the sources
71 for source in sources: 74 for s in sources:
72 if os.path.exists(source[0]): 75 if os.path.exists(s[0]):
73 if options.update: 76 if options.update:
74 os.chdir(source[0]) 77 os.chdir(s[0])
75 subprocess.call(['hg', 'pull']) 78 subprocess.call(['hg', 'pull'])
76 subprocess.call(['hg', 'update']) 79 subprocess.call(['hg', 'update'])
77 os.chdir('..') 80 os.chdir('..')
78 else: 81 else:
79 print "%s already exists" % source[0] 82 print "%s already exists" % s[0]
80 else: 83 else:
81 subprocess.call(['hg', 'clone', source[1]]) 84 subprocess.call(['hg', 'clone', s[1]])
82 85
83 # install the sources 86 # install the sources
84 if options.install: 87 if options.install:
85 for source in sources: 88 for s in sources:
86 os.chdir(source[0]) 89 os.chdir(s[0])
87 subprocess.call(['python', 'setup.py', 'develop']) 90 subprocess.call(['python', 'setup.py', 'develop'])
88 os.chdir('..') 91 os.chdir('..')
89 92
90 if __name__ == '__main__': 93 if __name__ == '__main__':
91 main() 94 main()