From 27b4b9cd039f30ad71f7533da79f195c82c1fbdc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 26 Sep 2011 11:53:09 +0200 Subject: [PATCH] also move out install and cleanup library path code Signed-off-by: Nico Schottelius --- bin/cdist | 16 ++++++---------- lib/cdist/install.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 10 deletions(-) create mode 100755 lib/cdist/install.py diff --git a/bin/cdist b/bin/cdist index 4dd4f971..5e1b96bf 100755 --- a/bin/cdist +++ b/bin/cdist @@ -33,17 +33,13 @@ import sys import tempfile log = logging.getLogger(__name__) -real_me = os.path.dirname(os.path.realpath(__file__)) -cdist_lib = os.path.abspath(os.path.join(real_me, '../lib')) -sys.path.insert(0, cdist_lib) +# Ensure our /lib/ is included into PYTHON_PATH +sys.path.insert(0, os.path.abspath( + os.path.join(os.path.dirname(os.path.realpath(__file__)), '../lib')) +) TYPE_PREFIX = "__" -CODE_HEADER = "#!/bin/sh -e\n" - -def install(args): - """Install remote system""" - process = {} def commandline(): """Parse command line""" @@ -91,7 +87,7 @@ def commandline(): # Install parser['install'] = parser['sub'].add_parser('install', parents=[parser['most'], parser['configinstall']]) - parser['install'].set_defaults(func=install) + parser['install'].set_defaults(func=cdist.install.install) for p in parser: parser[p].epilog = "Get cdist at http://www.nico.schottelius.org/software/cdist/" @@ -106,7 +102,6 @@ def commandline(): args.func(args) - if __name__ == "__main__": try: logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s') @@ -119,6 +114,7 @@ if __name__ == "__main__": import cdist.banner import cdist.config import cdist.exec + import cdist.install import cdist.path commandline() diff --git a/lib/cdist/install.py b/lib/cdist/install.py new file mode 100755 index 00000000..98b388ec --- /dev/null +++ b/lib/cdist/install.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# + +import logging + +log = logging.getLogger(__name__) + +def install(args): + """Install remote system""" + process = {} +