From 79173488ffd697ef89d8a387034eb3447cf3da61 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 23 Sep 2011 20:08:55 +0200 Subject: [PATCH] cdist runs with path module loaded (unusued though) Signed-off-by: Nico Schottelius --- bin/cdist | 13 ++++++++----- lib/cdist/path.py | 31 ++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/bin/cdist b/bin/cdist index 18e7845b..f6156825 100755 --- a/bin/cdist +++ b/bin/cdist @@ -32,11 +32,6 @@ import stat import sys import tempfile -# Add our own library path -sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), - '../lib'))) - -import cdist.path BANNER = """ .. . .x+=:. s @@ -788,11 +783,19 @@ def commandline(): args.func(args) + if __name__ == "__main__": try: if re.match(TYPE_PREFIX, os.path.basename(sys.argv[0])): emulator() else: + # Add our own library path + sys.path.insert(0, + os.path.abspath(os.path.join(os.path.dirname(__file__), + '../lib'))) + + import cdist.path + commandline() except KeyboardInterrupt: sys.exit(0) diff --git a/lib/cdist/path.py b/lib/cdist/path.py index 69bc5496..2050a1a3 100644 --- a/lib/cdist/path.py +++ b/lib/cdist/path.py @@ -1,3 +1,25 @@ +# -*- 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 import os import sys import tempfile @@ -13,6 +35,10 @@ CODE_HEADER = "#!/bin/sh -e\n" DOT_CDIST = ".cdist" TYPE_PREFIX = "__" +logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s') +log = logging.getLogger() + + def file_to_list(filename): """Return list from \n seperated file""" if os.path.isfile(filename): @@ -33,7 +59,10 @@ def file_to_list(filename): class Path: """Class that handles path related configurations""" - def __init__(self, target_host, base_dir=None): + def __init__(self, target_host, + initial_manifest=False, remote_user="root", + base_dir=None, debug=False): + # Base and Temp Base if base_dir: self.base_dir = base_dir