Mercurial > hg > config
annotate python/install_config.py @ 897:ba2630ce851b
update default branch for git
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Mon, 01 Aug 2022 16:40:53 -0700 |
parents | 8a86595a6f9c |
children | d6cce2e5cca6 |
rev | line source |
---|---|
1 | 1 #!/usr/bin/env python |
234
761e7dfc675e
updates from most recent usage
Jeff Hammel <jhammel@mozilla.com>
parents:
219
diff
changeset
|
2 |
1 | 3 """ |
4 installs config to a user's home directory | |
5 this can be done with | |
16 | 6 curl http://k0s.org/hg/config/raw-file/tip/python/install_config.py | python |
1 | 7 """ |
8 | |
579
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
9 # TODO: |
878
e641fdf325bb
STUB: installing silvermirror
Jeff Hammel <k0scist@gmail.com>
parents:
876
diff
changeset
|
10 # - install silvermirror: |
e641fdf325bb
STUB: installing silvermirror
Jeff Hammel <k0scist@gmail.com>
parents:
876
diff
changeset
|
11 # ``` |
e641fdf325bb
STUB: installing silvermirror
Jeff Hammel <k0scist@gmail.com>
parents:
876
diff
changeset
|
12 # python -m venv "${HOME}"/k0s |
e641fdf325bb
STUB: installing silvermirror
Jeff Hammel <k0scist@gmail.com>
parents:
876
diff
changeset
|
13 # mkdir -p "${HOME}"/k0s/src |
e641fdf325bb
STUB: installing silvermirror
Jeff Hammel <k0scist@gmail.com>
parents:
876
diff
changeset
|
14 # "${HOME}"/k0s/bin/pip install "${HOME}"/k0s/k0s-requirements.txt |
e641fdf325bb
STUB: installing silvermirror
Jeff Hammel <k0scist@gmail.com>
parents:
876
diff
changeset
|
15 # ``` |
579
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
16 # - dl and get ~/web/sync.ini : |
876 | 17 # ``` |
18 # mkdir -p "${HOME}/web" | |
19 # scp jhammel@k0s.org:~/web/sync.ini "${HOME}"/web/sync.ini | |
579
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
20 # ln -s /home/jhammel/web/sync.ini /home/jhammel/.silvermirror |
876 | 21 # ``` |
579
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
22 # - handle cases where config is autogenerated BUT you still want |
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
23 # to have some base (e.g. .gkrellm2/user_config) |
591
542d329835ec
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
590
diff
changeset
|
24 # - scp k0s.org:~/web/sync.ini ~/.silvermirror |
542d329835ec
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
590
diff
changeset
|
25 # - make idempotent |
595
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
26 # - step to install (and setup) firefox |
579
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
27 |
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
28 # imports |
218 | 29 import imp |
408 | 30 import optparse |
1 | 31 import os |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
32 import subprocess |
6 | 33 import sys |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
34 |
579
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
35 # globals |
590
e93b81d8a586
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
584
diff
changeset
|
36 SRC = 'http://k0s.org/hg/config' # config repository |
e93b81d8a586
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
584
diff
changeset
|
37 HOME = os.environ['HOME'] # home directory |
1 | 38 |
591
542d329835ec
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
590
diff
changeset
|
39 |
410 | 40 ### standalone functions |
41 | |
591
542d329835ec
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
590
diff
changeset
|
42 def class_mapping(_type): |
846
1259f9d79961
[BBB] we still in 2017 need py26 sometimes
Jeff Hammel <k0scist@gmail.com>
parents:
738
diff
changeset
|
43 """ |
1259f9d79961
[BBB] we still in 2017 need py26 sometimes
Jeff Hammel <k0scist@gmail.com>
parents:
738
diff
changeset
|
44 returns a dict of (name, class) for objects |
1259f9d79961
[BBB] we still in 2017 need py26 sometimes
Jeff Hammel <k0scist@gmail.com>
parents:
738
diff
changeset
|
45 in the current globals() of _type |
1259f9d79961
[BBB] we still in 2017 need py26 sometimes
Jeff Hammel <k0scist@gmail.com>
parents:
738
diff
changeset
|
46 """ |
1259f9d79961
[BBB] we still in 2017 need py26 sometimes
Jeff Hammel <k0scist@gmail.com>
parents:
738
diff
changeset
|
47 |
1259f9d79961
[BBB] we still in 2017 need py26 sometimes
Jeff Hammel <k0scist@gmail.com>
parents:
738
diff
changeset
|
48 return dict([(name,cls) |
1259f9d79961
[BBB] we still in 2017 need py26 sometimes
Jeff Hammel <k0scist@gmail.com>
parents:
738
diff
changeset
|
49 for name, cls in globals().items() if |
1259f9d79961
[BBB] we still in 2017 need py26 sometimes
Jeff Hammel <k0scist@gmail.com>
parents:
738
diff
changeset
|
50 cls.issubclass(_type)]) |
591
542d329835ec
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
590
diff
changeset
|
51 |
542d329835ec
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
590
diff
changeset
|
52 |
590
e93b81d8a586
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
584
diff
changeset
|
53 def execute(*commands, **kwargs): |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
54 """execute a series of commands""" |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
55 for command in commands: |
619
fd50f457185c
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
595
diff
changeset
|
56 print (subprocess.list2cmdline(command)) |
590
e93b81d8a586
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
584
diff
changeset
|
57 code = subprocess.call(command, **kwargs) |
591
542d329835ec
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
590
diff
changeset
|
58 if code: |
542d329835ec
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
590
diff
changeset
|
59 raise subprocess.CalledProcessError(code, command) |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
60 |
592
33b313fa1eb0
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
591
diff
changeset
|
61 |
410 | 62 def install_develop(package): |
63 """install k0s.ware for development""" | |
64 | |
65 src = 'http://k0s.org/hg/%s' % package | |
66 directory = '%s/src/%s' % (package, package) | |
590
e93b81d8a586
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
584
diff
changeset
|
67 commands = [['virtualenv/virtualenv.py', package], |
e93b81d8a586
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
584
diff
changeset
|
68 ['mkdir', '-p', directory ], |
e93b81d8a586
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
584
diff
changeset
|
69 ['hg', 'clone', src, directory] ] |
410 | 70 execute(*commands) |
71 old_directory = os.getcwd() | |
72 os.chdir(directory) | |
73 command = ['../../bin/python', 'setup.py', 'develop'] | |
74 execute(command) | |
75 os.chdir(old_directory) | |
76 | |
591
542d329835ec
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
590
diff
changeset
|
77 |
584 | 78 ### generic step framework |
410 | 79 |
592
33b313fa1eb0
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
591
diff
changeset
|
80 class StepGraph(object): |
33b313fa1eb0
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
591
diff
changeset
|
81 """a bunch of steps""" |
33b313fa1eb0
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
591
diff
changeset
|
82 |
408 | 83 class Step(object): |
84 @classmethod | |
85 def check(cls): | |
86 """checks if the step may be run""" | |
584 | 87 @classmethod |
88 def name(cls): | |
89 return cls.__name__ | |
619
fd50f457185c
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
595
diff
changeset
|
90 __str__ = name # XXX does not work! :( |
408 | 91 def __call__(self): |
92 execute(*self.commands) | |
93 | |
595
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
94 |
584 | 95 class Command(object): |
96 """require a command""" | |
97 | |
595
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
98 #@require(Virtualenv) |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
99 class InstallVirtualenv(Step): |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
100 """ABC for installing packages in a virtualenv""" |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
101 # TODO: move install_develop sctuff to here |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
102 |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
103 |
584 | 104 ### process steps |
105 | |
408 | 106 class InitializeRepository(Step): |
107 """make the home directory a repository""" | |
409 | 108 commands = [ |
109 ['hg', 'init'], | |
110 ['hg', 'pull', SRC], | |
111 ['hg', 'update', '-C'], | |
112 ] | |
577 | 113 @classmethod |
410 | 114 def write_hgrc(self): |
584 | 115 """make a (correct) .hg/hgrc file for $HOME""" |
116 | |
410 | 117 hgrc = """[paths] |
118 default = http://k0s.org/hg/config | |
119 default-push = ssh://k0s.org/hg/config | |
120 """ | |
886 | 121 with open('.hg/hgrc', 'w') as f: |
410 | 122 f.write(hgrc) |
595
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
123 |
410 | 124 def __call__(self): |
125 Step.__call__(self) | |
126 self.write_hgrc() | |
408 | 127 |
584 | 128 # get the which command |
129 sys.path.append(os.path.join(HOME, 'python')) | |
130 from which import which | |
579
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
131 |
411 | 132 #@requires(Command('git')) |
590
e93b81d8a586
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
584
diff
changeset
|
133 class ConfigureGit(Step): |
e93b81d8a586
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
584
diff
changeset
|
134 """configure git""" |
595
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
135 commands = [ |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
136 # setup git's global ignore, since git is silly about this |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
137 # and doesn't look for the file in the right place |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
138 ['git', 'config', '--global', 'core.excludesfile', os.path.join(HOME, '.gitignore')] |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
139 ] |
590
e93b81d8a586
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
584
diff
changeset
|
140 |
e93b81d8a586
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
584
diff
changeset
|
141 #@requires(Command('git')) |
584 | 142 class InstallVirtualenv(Step): |
143 commands = [['git', 'clone', 'https://github.com/pypa/virtualenv.git'], | |
590
e93b81d8a586
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
584
diff
changeset
|
144 ['ln', '-s', |
e93b81d8a586
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
584
diff
changeset
|
145 os.path.join(HOME, 'virtualenv/virtualenv.py'), |
e93b81d8a586
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
584
diff
changeset
|
146 os.path.join(HOME, 'bin', 'virtualenv.py')] |
e93b81d8a586
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
584
diff
changeset
|
147 ] |
e93b81d8a586
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
584
diff
changeset
|
148 |
645
753a5358535f
correct syntax errors; now works again
Jeff Hammel <k0scist@gmail.com>
parents:
619
diff
changeset
|
149 class InstallKWare(Step): |
590
e93b81d8a586
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
584
diff
changeset
|
150 """install k0s.ware""" |
595
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
151 # TODO |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
152 # from legacy |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
153 # # install some python |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
154 # install_develop('smartopen') |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
155 # install_develop('silvermirror') # XXX this won't actually work since python-dev isn't installed; install it first |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
156 |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
157 # postinstall_commands = [['ln', '-s', os.path.join(HOME, 'smartopen', 'bin', 'smartopen'), os.path.join(HOME, 'bin', 'smartopen') ], |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
158 # ['ln', '-s', os.path.join(HOME, 'silvermirror', 'bin', 'silvermirror'), os.path.join(HOME, 'bin', 'silvermirror') ], |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
159 # ] |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
160 # execute(*postinstall_commands) |
4b79ee6c8539
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
594
diff
changeset
|
161 |
577 | 162 |
582 | 163 class DebianPackages(Step): |
578 | 164 """ubuntu packages to install""" |
584 | 165 # TODO: actually install packages |
578 | 166 |
593
dbdc68d85986
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
592
diff
changeset
|
167 PACKAGES=["antiword", |
594
98ccb704e241
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
593
diff
changeset
|
168 "arandr", |
98ccb704e241
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
593
diff
changeset
|
169 "curl", |
98ccb704e241
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
593
diff
changeset
|
170 "emacs", |
593
dbdc68d85986
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
592
diff
changeset
|
171 "fluxbox", |
594
98ccb704e241
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
593
diff
changeset
|
172 "git", |
98ccb704e241
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
593
diff
changeset
|
173 "gkrellm", |
98ccb704e241
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
593
diff
changeset
|
174 "graphviz", |
98ccb704e241
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
593
diff
changeset
|
175 "graphviz-dev", |
98ccb704e241
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
593
diff
changeset
|
176 "irssi", |
593
dbdc68d85986
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
592
diff
changeset
|
177 "mercurial", |
731
e56610c5ece2
now we need pkg-config for pygraphviz
Jeff Hammel <k0scist@gmail.com>
parents:
645
diff
changeset
|
178 "pkg-config", |
594
98ccb704e241
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
593
diff
changeset
|
179 "python-dev", |
98ccb704e241
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
593
diff
changeset
|
180 "python-lxml", |
738 | 181 "libxml2", |
593
dbdc68d85986
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
592
diff
changeset
|
182 "libxml2-dev", |
dbdc68d85986
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
592
diff
changeset
|
183 "libxslt1-dev", |
579
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
184 "unison", |
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
185 "xclip", |
594
98ccb704e241
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
593
diff
changeset
|
186 ] |
98ccb704e241
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
593
diff
changeset
|
187 |
579
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
188 def __call__(self): |
594
98ccb704e241
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
593
diff
changeset
|
189 # TODO: actually install this shit |
645
753a5358535f
correct syntax errors; now works again
Jeff Hammel <k0scist@gmail.com>
parents:
619
diff
changeset
|
190 print ("Ensure the following packages are installed:") |
753a5358535f
correct syntax errors; now works again
Jeff Hammel <k0scist@gmail.com>
parents:
619
diff
changeset
|
191 print ("sudo apt-get install %s" % ' '.join(self.PACKAGES)) |
579
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
192 |
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
193 |
582 | 194 ### CLI |
416 | 195 |
408 | 196 def main(args=sys.argv[1:]): |
578 | 197 |
198 # go home | |
199 os.chdir(HOME) | |
200 | |
201 # parse command line | |
408 | 202 usage = '%prog [options]' |
203 parser = optparse.OptionParser(usage=usage, description=__doc__) | |
578 | 204 parser.add_option('--deb', '--dpkg', '--debian-packages', |
205 dest='debian_packages', | |
206 action='store_true', default=False, | |
207 help="display debian packages to install") | |
579
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
208 parser.add_option('-l', '--list', '--list-steps', |
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
209 dest='list_steps', |
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
210 action='store_true', default=False, |
580
b563a9c1f2b7
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
579
diff
changeset
|
211 help="list steps to be run and exit") |
591
542d329835ec
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
590
diff
changeset
|
212 parser.add_option('--all', dest='all', |
542d329835ec
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
590
diff
changeset
|
213 action='store_true', default=False, |
542d329835ec
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
590
diff
changeset
|
214 help="list all actions") |
542d329835ec
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
590
diff
changeset
|
215 parser.add_option('--run', dest='run', |
542d329835ec
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
590
diff
changeset
|
216 action='append', |
542d329835ec
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
590
diff
changeset
|
217 help="run particular actions, in order") |
408 | 218 options, args = parser.parse_args() |
219 | |
578 | 220 # plan steps |
582 | 221 steps = [InitializeRepository, DebianPackages] |
579
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
222 if options.debian_packages: |
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
223 steps = [DebianPackages] |
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
224 |
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
225 if options.list_steps: |
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
226 # list steps if specified |
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
227 for step in steps: |
584 | 228 print(step.name()) |
580
b563a9c1f2b7
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
579
diff
changeset
|
229 parser.exit() |
578 | 230 |
591
542d329835ec
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
590
diff
changeset
|
231 if options.all: |
645
753a5358535f
correct syntax errors; now works again
Jeff Hammel <k0scist@gmail.com>
parents:
619
diff
changeset
|
232 raise NotImplementedError("TODO") |
591
542d329835ec
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
590
diff
changeset
|
233 |
578 | 234 # execute steps |
409 | 235 for step in steps: |
579
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
236 instance = step() |
f894bd779943
STUB: python/install_config.py
Jeff Hammel <k0scist@gmail.com>
parents:
578
diff
changeset
|
237 instance() |
416 | 238 |
408 | 239 if __name__ == '__main__': |
240 main() |