diff --git a/bin/cdist b/bin/cdist index 5e1b96bf..d21fda40 100755 --- a/bin/cdist +++ b/bin/cdist @@ -21,23 +21,16 @@ # import argparse -import datetime import logging -import multiprocessing import os import re -import subprocess -import shutil -import stat import sys -import tempfile log = logging.getLogger(__name__) # 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')) -) + os.path.join(os.path.dirname(os.path.realpath(__file__)), '../lib'))) TYPE_PREFIX = "__" diff --git a/bin/cdist-deploy-stdin-to b/bin/cdist-deploy-stdin-to deleted file mode 100755 index 391dd431..00000000 --- a/bin/cdist-deploy-stdin-to +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# -# 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 . -# -# -# Use stdin as the manifest to deploy on the given host. -# - -. cdist-config -[ $# -eq 1 ] || __cdist_usage "" -set -eu - -__cdist_target_host="$1" -shift - -cat >> "$__cdist_tmp_file" - -chmod +x "$__cdist_tmp_file" - -export __cdist_manifest_init="$__cdist_tmp_file" -cdist-deploy-to "$__cdist_target_host" diff --git a/doc/man/man1/cdist-deploy-stdin-to.text b/doc/man/man1/cdist-deploy-stdin-to.text deleted file mode 100644 index 14f19478..00000000 --- a/doc/man/man1/cdist-deploy-stdin-to.text +++ /dev/null @@ -1,30 +0,0 @@ -cdist-deploy-stdin-to(1) -======================== -Steven Armstrong - - -NAME ----- -cdist-deploy-stdin-to - Deploy the configuration given on stdin to host - - -SYNOPSIS --------- -echo "__file /tmp/whatever" | cdist-deploy-stdin-to HOSTNAME - - -DESCRIPTION ------------ -Use stdin as the manifest for cdist-deploy-to. - - -SEE ALSO --------- -- cdist(7) -- cdist-deploy-to(1) - - -COPYING -------- -Copyright \(C) 2011 Steven Armstrong. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/doc/man/man7/cdist-quickstart.text b/doc/man/man7/cdist-tutorial.text similarity index 100% rename from doc/man/man7/cdist-quickstart.text rename to doc/man/man7/cdist-tutorial.text diff --git a/lib/cdist/config.py b/lib/cdist/config.py old mode 100755 new mode 100644 diff --git a/lib/cdist/emulator.py b/lib/cdist/emulator.py old mode 100755 new mode 100644 diff --git a/lib/cdist/exec.py b/lib/cdist/exec.py index 09e4e8a4..f95ba941 100644 --- a/lib/cdist/exec.py +++ b/lib/cdist/exec.py @@ -24,6 +24,8 @@ import subprocess log = logging.getLogger(__name__) +import cdist + def shell_run_or_debug_fail(script, *args, **kargs): # Manually execute /bin/sh, because sh -e does what we want # and sh -c -e does not exit if /bin/false called @@ -50,11 +52,11 @@ def shell_run_or_debug_fail(script, *args, **kargs): print(script_fd.read()) script_fd.close() except IOError as error: - raise CdistError(str(error)) + raise cdist.Error(str(error)) - raise CdistError("Command failed (shell): " + " ".join(*args)) + raise cdist.Error("Command failed (shell): " + " ".join(*args)) except OSError as error: - raise CdistError(" ".join(*args) + ": " + error.args[1]) + raise cdist.Error(" ".join(*args) + ": " + error.args[1]) def run_or_fail(*args, **kargs): @@ -66,6 +68,6 @@ def run_or_fail(*args, **kargs): try: subprocess.check_call(*args, **kargs) except subprocess.CalledProcessError: - raise CdistError("Command failed: " + " ".join(*args)) + raise cdist.Error("Command failed: " + " ".join(*args)) except OSError as error: - raise CdistError(" ".join(*args) + ": " + error.args[1]) + raise cdist.Error(" ".join(*args) + ": " + error.args[1]) diff --git a/lib/cdist/install.py b/lib/cdist/install.py old mode 100755 new mode 100644 diff --git a/test.py b/test.py new file mode 100755 index 00000000..ad56df11 --- /dev/null +++ b/test.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# 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 os +import sys +import unittest + +sys.path.insert(0, os.path.abspath( + os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib'))) + +import cdist +import cdist.config +import cdist.exec + +class Exec(unittest.TestCase): + def test_local_success(self): + try: + cdist.exec.run_or_fail(["/bin/true"]) + except cdist.Error: + failed = True + else: + failed = False + + self.assertFalse(failed) + + def test_local_fail(self): + try: + cdist.exec.run_or_fail(["/bin/false"]) + except cdist.Error: + failed = True + else: + failed = False + + self.assertTrue(failed) + + + +if __name__ == '__main__': + unittest.main() diff --git a/test/cdist.py b/test/cdist.py deleted file mode 100644 index 3ccc69bc..00000000 --- a/test/cdist.py +++ /dev/null @@ -1,12 +0,0 @@ -import cdist -import unittest - - -class CdistGeneric(unittest.TestCase): - - def test_initial_manifest(self): - self.assertEqual(numeral, result) - - -if __name__ == '__main__': - unittest.main()