Mercurial > hg > config
changeset 591:542d329835ec
STUB: python/install_config.py
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Fri, 24 Jan 2014 18:40:45 -0800 |
parents | e93b81d8a586 |
children | 33b313fa1eb0 |
files | python/install_config.py |
diffstat | 1 files changed, 23 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/python/install_config.py Fri Jan 24 17:53:23 2014 -0800 +++ b/python/install_config.py Fri Jan 24 18:40:45 2014 -0800 @@ -11,6 +11,8 @@ # ln -s /home/jhammel/web/sync.ini /home/jhammel/.silvermirror # - handle cases where config is autogenerated BUT you still want # to have some base (e.g. .gkrellm2/user_config) +# - scp k0s.org:~/web/sync.ini ~/.silvermirror +# - make idempotent # imports import imp @@ -23,13 +25,21 @@ SRC = 'http://k0s.org/hg/config' # config repository HOME = os.environ['HOME'] # home directory + ### standalone functions +def class_mapping(_type): + """returns a dict of (name, class) for objects in the current globals() of _type""" + return {name:cls for name, cls in globals().items() if cls.issubclass(_type)} + + def execute(*commands, **kwargs): """execute a series of commands""" for command in commands: - print (subprocess.list2cmdline(' '.join(command)) + print (subprocess.list2cmdline(' '.join(command))) code = subprocess.call(command, **kwargs) + if code: + raise subprocess.CalledProcessError(code, command) def install_develop(package): """install k0s.ware for development""" @@ -46,10 +56,9 @@ execute(command) os.chdir(old_directory) + ### generic step framework - - class Step(object): @classmethod def check(cls): @@ -171,6 +180,12 @@ dest='list_steps', action='store_true', default=False, help="list steps to be run and exit") + parser.add_option('--all', dest='all', + action='store_true', default=False, + help="list all actions") + parser.add_option('--run', dest='run', + action='append', + help="run particular actions, in order") options, args = parser.parse_args() # plan steps @@ -184,6 +199,11 @@ print(step.name()) parser.exit() + if options.all: + # list available steps + for sorted([]): + raise NotImplementedError("TODO") + # execute steps for step in steps: instance = step()