comparison python/install_config.py @ 410:ffa08f0de165

fix a thing
author Jeff Hammel <jhammel@mozilla.com>
date Sun, 04 Aug 2013 15:14:16 -0700
parents dc64beded724
children 9d6e7a471fc7
comparison
equal deleted inserted replaced
409:dc64beded724 410:ffa08f0de165
17 17
18 # go home 18 # go home
19 HOME=os.environ['HOME'] 19 HOME=os.environ['HOME']
20 os.chdir(HOME) 20 os.chdir(HOME)
21 21
22 ### standalone functions
23
22 def execute(*commands): 24 def execute(*commands):
23 """execute a series of commands""" 25 """execute a series of commands"""
24 for command in commands: 26 for command in commands:
25 print ' '.join(command) 27 print ' '.join(command)
26 code = subprocess.call(command) 28 code = subprocess.call(command)
27 if code: 29 if code:
28 sys.exit(code) 30 sys.exit(code)
31
32 def install_develop(package):
33 """install k0s.ware for development"""
34
35 src = 'http://k0s.org/hg/%s' % package
36 directory = '%s/src/%s' % (package, package)
37 commands = [ ['virtualenv/virtualenv.py', package],
38 ['mkdir', '-p', directory ],
39 ['hg', 'clone', src, directory] ]
40 execute(*commands)
41 old_directory = os.getcwd()
42 os.chdir(directory)
43 command = ['../../bin/python', 'setup.py', 'develop']
44 execute(command)
45 os.chdir(old_directory)
46
47
48 ### process steps
29 49
30 class Step(object): 50 class Step(object):
31 @classmethod 51 @classmethod
32 def check(cls): 52 def check(cls):
33 """checks if the step may be run""" 53 """checks if the step may be run"""
39 commands = [ 59 commands = [
40 ['hg', 'init'], 60 ['hg', 'init'],
41 ['hg', 'pull', SRC], 61 ['hg', 'pull', SRC],
42 ['hg', 'update', '-C'], 62 ['hg', 'update', '-C'],
43 ] 63 ]
64 @classmethd
65 def write_hgrc(self):
66 hgrc = """[paths]
67 default = http://k0s.org/hg/config
68 default-push = ssh://k0s.org/hg/config
69 """
70 with file('.hg/hgrc', 'w') as f
71 f.write(hgrc)
72 def __call__(self):
73 Step.__call__(self)
74 self.write_hgrc()
44 75
45 commands = [ 76 commands = [
46 ['hg', 'init'], 77 ['hg', 'init'],
47 ['hg', 'pull', SRC], 78 ['hg', 'pull', SRC],
48 ['hg', 'update', '-C'], 79 ['hg', 'update', '-C'],
49 ] 80 ]
50 81
51 execute(*commands) 82 execute(*commands)
52
53
54 # get the which command
55 sys.path.append(os.path.join(HOME, 'python'))
56 from which import which
57 83
58 84
59 # make a (correct) .hg/hgrc file for $HOME 85 # make a (correct) .hg/hgrc file for $HOME
60 hgrc = """[paths] 86 hgrc = """[paths]
61 default = http://k0s.org/hg/config 87 default = http://k0s.org/hg/config
63 """ 89 """
64 f = file('.hg/hgrc', 'w') 90 f = file('.hg/hgrc', 'w')
65 f.write(hgrc) 91 f.write(hgrc)
66 f.close() 92 f.close()
67 93
68 def install_develop(package): 94 # get the which command
69 """install k0s.ware for development""" 95 sys.path.append(os.path.join(HOME, 'python'))
96 from which import which
70 97
71 src = 'http://k0s.org/hg/%s' % package
72 directory = '%s/src/%s' % (package, package)
73 commands = [ ['virtualenv/virtualenv.py', package],
74 ['mkdir', '-p', directory ],
75 ['hg', 'clone', src, directory] ]
76 execute(*commands)
77 old_directory = os.getcwd()
78 os.chdir(directory)
79 command = ['../../bin/python', 'setup.py', 'develop']
80 execute(command)
81 os.chdir(old_directory)
82 98
83 # do git stuff 99 # do git stuff
84 git = which('git') 100 git = which('git')
85 if git: 101 if git:
86 # get virtual env 102 # get virtual env