aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Dolbec <brian.dolbec@gmail.com>2010-07-06 18:08:46 -0700
committerBrian Dolbec <brian.dolbec@gmail.com>2010-07-06 18:08:46 -0700
commit39a9e454c603fd5c2b960354ee09b39c6ecb5e6a (patch)
tree4f03b3868aa8145a4f72f923581c00f5dee93e47
parentAdd an output parameter to Message class and change the prints that weren't a... (diff)
downloadoverlord-39a9e454c603fd5c2b960354ee09b39c6ecb5e6a.tar.gz
overlord-39a9e454c603fd5c2b960354ee09b39c6ecb5e6a.tar.bz2
overlord-39a9e454c603fd5c2b960354ee09b39c6ecb5e6a.zip
Change the remaining modules to use teh config['output'] variable so re-direction is possible for all output.
-rw-r--r--layman/overlays/overlay.py10
-rw-r--r--layman/overlays/source.py16
-rw-r--r--layman/overlays/tar.py6
3 files changed, 21 insertions, 11 deletions
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 2333d72..4036458 100644
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -35,7 +35,7 @@ import xml.etree.ElementTree as ET # Python 2.5
from layman.utils import ensure_unicode
-from layman.debug import OUT
+#from layman.debug import OUT
from layman.overlays.bzr import BzrOverlay
from layman.overlays.darcs import DarcsOverlay
@@ -100,6 +100,8 @@ class Overlay(object):
False
'''
+ self.output = config['output']
+
def strip_text(node):
res = node.text
if res is None:
@@ -161,7 +163,7 @@ class Overlay(object):
raise Exception('Overlay "' + self.name + '" is missing a '
'"owner.email" entry!')
elif ignore == 1:
- OUT.warn('Overlay "' + self.name + '" is missing a '
+ self.output.warn('Overlay "' + self.name + '" is missing a '
'"owner.email" entry!', 4)
@@ -176,7 +178,7 @@ class Overlay(object):
raise Exception('Overlay "' + self.name + '" is missing a '
'"description" entry!')
elif ignore == 1:
- OUT.warn('Overlay "' + self.name + '" is missing a '
+ self.output.warn('Overlay "' + self.name + '" is missing a '
'"description" entry!', 4)
if 'status' in xml.attrib:
@@ -279,7 +281,7 @@ class Overlay(object):
self.sources = [s]
break
except Exception, error:
- OUT.warn(str(error), 4)
+ self.output.warn(str(error), 4)
return res
def sync(self, base, quiet = False):
diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index 5ff2b15..8d41bf4 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -17,7 +17,7 @@ import os
import sys
import shutil
import subprocess
-from layman.debug import OUT
+#from layman.debug import OUT
from layman.utils import path
@@ -52,6 +52,7 @@ class OverlaySource(object):
self.config = config
self.ignore = ignore
self.quiet = quiet
+ self.output = config['output']
def __eq__(self, other):
return self.src == other.src
@@ -79,10 +80,10 @@ class OverlaySource(object):
mdir = path([base, self.parent.name])
if not os.path.exists(mdir):
- OUT.warn('Directory ' + mdir + ' did not exist, no files deleted.')
+ self.output.warn('Directory ' + mdir + ' did not exist, no files deleted.')
return
- OUT.info('Deleting directory "%s"' % mdir, 2)
+ self.output.info('Deleting directory "%s"' % mdir, 2)
shutil.rmtree(mdir)
def supported(self):
@@ -104,7 +105,7 @@ class OverlaySource(object):
def cmd(self, command):
'''Run a command.'''
- OUT.info('Running command "' + command + '"...', 2)
+ self.output.info('Running command "' + command + '"...', 2)
if hasattr(sys.stdout,'encoding'):
enc = sys.stdout.encoding or sys.getfilesystemencoding()
@@ -112,7 +113,12 @@ class OverlaySource(object):
command = command.encode(enc)
if not self.quiet:
- return os.system(command)
+ cmd = subprocess.Popen([command], shell = True,
+ stdout = self.config['stdout'],
+ stderr = self.config['stderr'],
+ close_fds = True)
+ result = cmd.wait()
+ return result
else:
cmd = subprocess.Popen([command], shell = True,
stdout = subprocess.PIPE,
diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 71369a6..d0b78cc 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -28,7 +28,7 @@ import os, os.path, sys, urllib2, shutil, tempfile
import xml.etree.ElementTree as ET # Python 2.5
from layman.utils import path, ensure_unicode
-from layman.debug import OUT
+#from layman.debug import OUT
from layman.overlays.source import OverlaySource, require_supported
#===============================================================================
@@ -85,6 +85,8 @@ class TarOverlay(OverlaySource):
else:
self.subpath = ''
+ self.output = config['output']
+
def __eq__(self, other):
res = super(TarOverlay, self).__eq__(other) \
and self.subpath == other.subpath
@@ -138,7 +140,7 @@ class TarOverlay(OverlaySource):
return
try:
- OUT.info('Deleting directory "%s"' % folder, 2)
+ self.output.info('Deleting directory "%s"' % folder, 2)
shutil.rmtree(folder)
except Exception, error:
raise Exception('Failed to remove unnecessary tar structure "'