Merge remote-tracking branch 'telmich/master'

This commit is contained in:
Steven Armstrong 2011-10-07 17:51:25 +02:00
commit 129e47d0c1
9 changed files with 107 additions and 59 deletions

View file

@ -19,8 +19,23 @@
#
#
VERSION = "2.0.3"
BANNER = """
.. . .x+=:. s
dF @88> z` ^% :8
'88bu. %8P . <k .88
. '*88888bu . .@8Ned8" :888ooo
.udR88N ^"*8888N .@88u .@^%8888" -*8888888
<888'888k beWE "888L ''888E` x88: `)8b. 8888
9888 'Y" 888E 888E 888E 8888N=*8888 8888
9888 888E 888E 888E %8" R88 8888
9888 888E 888F 888E @8Wou 9% .8888Lu=
?8888u../ .888N..888 888& .888888P` ^%888*
"8888P' `"888*"" R888" ` ^"F 'Y"
"P' "" ""
"""
DOT_CDIST = ".cdist"
VERSION = "2.0.3"
import os

View file

@ -22,25 +22,11 @@
import logging
import sys
log = logging.getLogger(__name__)
import cdist
BANNER = """
.. . .x+=:. s
dF @88> z` ^% :8
'88bu. %8P . <k .88
. '*88888bu . .@8Ned8" :888ooo
.udR88N ^"*8888N .@88u .@^%8888" -*8888888
<888'888k beWE "888L ''888E` x88: `)8b. 8888
9888 'Y" 888E 888E 888E 8888N=*8888 8888
9888 888E 888E 888E %8" R88 8888
9888 888E 888F 888E @8Wou 9% .8888Lu=
?8888u../ .888N..888 888& .888888P` ^%888*
"8888P' `"888*"" R888" ` ^"F 'Y"
"P' "" ""
"""
log = logging.getLogger(__name__)
def banner(args):
"""Guess what :-)"""
print(BANNER)
sys.exit(0)
print(cdist.BANNER)

View file

@ -53,7 +53,7 @@ class ConfigInstall:
debug=debug)
def cleanup(self):
self.path.cleanup()
self.context.cleanup()
def run_initial_manifest(self):
"""Run the initial manifest"""
@ -163,10 +163,12 @@ class ConfigInstall:
cdist.exec.run_or_fail([code_local])
# code remote
local_remote_code = cdist_object.code_remote_path
remote_remote_code = cdist_object.remote_code_remote_path
local_remote_code = os.path.join(self.context.object_base_path,
cdist_object.code_remote_path)
remote_remote_code = os.path.join(self.context.remote_object_path,
cdist_object.code_remote_path)
if os.path.isfile(local_remote_code):
self.context.transfer_file(local_remote_code, remote_remote_code)
self.context.transfer_path(local_remote_code, remote_remote_code)
cdist.exec.run_or_fail([remote_remote_code], remote_prefix=True)
cdist_object.ran = True

View file

@ -99,11 +99,11 @@ class Context:
# "other globals referenced by the __del__() method may already have been deleted
# or in the process of being torn down (e.g. the import machinery shutting down)"
#
log.debug("Saving" + self.base_path + "to " + self.cache_path)
log.debug("Saving " + self.out_path + " to " + self.cache_path)
# Remove previous cache
if os.path.exists(self.cache_path):
shutil.rmtree(self.cache_path)
shutil.move(self.base_path, self.cache_path)
shutil.move(self.out_path, self.cache_path)
def __init_out_paths(self):
"""Initialise output directory structure"""

View file

@ -0,0 +1,42 @@
#!/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 <http://www.gnu.org/licenses/>.
#
#
import io
import sys
import unittest
import cdist
import cdist.banner
class Banner(unittest.TestCase):
def setUp(self):
self.banner = cdist.BANNER + "\n"
def test_banner_output(self):
"""Check that printed banner equals saved banner"""
output = io.StringIO()
sys.stdout = output
cdist.banner.banner(None)
self.assertEqual(output.getvalue(), self.banner)