comparison python/install_config.py @ 578:c16238544fca

move towards modern system
author Jeff Hammel <k0scist@gmail.com>
date Mon, 20 Jan 2014 16:35:03 -0800
parents 9b9b66c2c1fc
children f894bd779943
comparison
equal deleted inserted replaced
577:9b9b66c2c1fc 578:c16238544fca
12 import subprocess 12 import subprocess
13 import sys 13 import sys
14 14
15 # config repository 15 # config repository
16 SRC='http://k0s.org/hg/config' 16 SRC='http://k0s.org/hg/config'
17
18 # go home
19 HOME=os.environ['HOME'] 17 HOME=os.environ['HOME']
20 os.chdir(HOME)
21 18
22 ### standalone functions 19 ### standalone functions
23 20
24 def execute(*commands): 21 def execute(*commands):
25 """execute a series of commands""" 22 """execute a series of commands"""
84 ['hg', 'init'], 81 ['hg', 'init'],
85 ['hg', 'pull', SRC], 82 ['hg', 'pull', SRC],
86 ['hg', 'update', '-C'], 83 ['hg', 'update', '-C'],
87 ] 84 ]
88 85
86 os.chdir(HOME) # go home
87
89 execute(*commands) 88 execute(*commands)
90
91 89
92 # make a (correct) .hg/hgrc file for $HOME 90 # make a (correct) .hg/hgrc file for $HOME
93 hgrc = """[paths] 91 hgrc = """[paths]
94 default = http://k0s.org/hg/config 92 default = http://k0s.org/hg/config
95 default-push = ssh://k0s.org/hg/config 93 default-push = ssh://k0s.org/hg/config
96 """ 94 """
97 f = file('.hg/hgrc', 'w') 95 with file(os.path.join(HOME, '.hg/hgrc', 'w')) as f:
98 f.write(hgrc) 96 f.write(hgrc)
99 f.close()
100 97
101 # get the which command 98 # get the which command
102 sys.path.append(os.path.join(HOME, 'python')) 99 sys.path.append(os.path.join(HOME, 'python'))
103 from which import which 100 from which import which
104 101
124 ] 121 ]
125 execute(*postinstall_commands) 122 execute(*postinstall_commands)
126 else: 123 else:
127 print "git not installed" 124 print "git not installed"
128 125
129 # - ubuntu packages to install: 126 class UbuntuPackages(Step):
127 """ubuntu packages to install"""
128
130 PACKAGES=["mercurial", "unison", "fluxbox", "antiword", "xclip", 129 PACKAGES=["mercurial", "unison", "fluxbox", "antiword", "xclip",
131 "graphviz", "python-dev", "python-lxml", "curl", "arandr", 130 "graphviz", "python-dev", "python-lxml", "curl", "arandr",
132 "git", "emacs", "irssi"] 131 "git", "emacs", "irssi"]
133 print "Ensure the following packages are installed:" 132 print "Ensure the following packages are installed:"
134 print "sudo apt-get install %s" % ' '.join(PACKAGES) 133 print "sudo apt-get install %s" % ' '.join(PACKAGES)
138 # ln -s /home/jhammel/web/sync.ini /home/jhammel/.silvermirror 137 # ln -s /home/jhammel/web/sync.ini /home/jhammel/.silvermirror
139 # - handle cases where config is autogenerated BUT you still want 138 # - handle cases where config is autogenerated BUT you still want
140 # to have some base (e.g. .gkrellm2/user_config) 139 # to have some base (e.g. .gkrellm2/user_config)
141 140
142 def main(args=sys.argv[1:]): 141 def main(args=sys.argv[1:]):
142
143 # go home
144 os.chdir(HOME)
145
146 # parse command line
143 usage = '%prog [options]' 147 usage = '%prog [options]'
144 parser = optparse.OptionParser(usage=usage, description=__doc__) 148 parser = optparse.OptionParser(usage=usage, description=__doc__)
149 parser.add_option('--deb', '--dpkg', '--debian-packages',
150 dest='debian_packages',
151 action='store_true', default=False,
152 help="display debian packages to install")
145 options, args = parser.parse_args() 153 options, args = parser.parse_args()
146 return
147 154
155 # plan steps
148 steps = [InitializeRepository] 156 steps = [InitializeRepository]
157
158 # execute steps
149 for step in steps: 159 for step in steps:
150 pass # TODO 160 pass # TODO
151 161
152 if __name__ == '__main__': 162 if __name__ == '__main__':
153 main() 163 main()