diff options
author | Yaakov M. Nemoy <loupgaroublond@gmail.com> | 2009-01-05 00:51:58 -0500 |
---|---|---|
committer | Yaakov M. Nemoy <loupgaroublond@gmail.com> | 2009-01-05 00:51:58 -0500 |
commit | 6de41224c5133ced1124521ea0b212d1f6f2c2c4 (patch) | |
tree | a8c9f95d158c81d19a4f0aa7bce32beda2d511bb | |
parent | 30fe0400ab1bb17b892235ae96c5e704204d4fc2 (diff) | |
download | fedora-devshell-6de41224c5133ced1124521ea0b212d1f6f2c2c4.tar.gz fedora-devshell-6de41224c5133ced1124521ea0b212d1f6f2c2c4.tar.xz fedora-devshell-6de41224c5133ced1124521ea0b212d1f6f2c2c4.zip |
Adds headers and footers to log files
-rw-r--r-- | base/util.py | 9 | ||||
-rw-r--r-- | modules/cabal.py | 10 |
2 files changed, 14 insertions, 5 deletions
diff --git a/base/util.py b/base/util.py index d4a6475..ec72594 100644 --- a/base/util.py +++ b/base/util.py @@ -19,6 +19,7 @@ from __future__ import with_statement from contextlib import contextmanager +from datetime import datetime from os import chdir, getcwd, remove from os import symlink as sym from os.path import abspath, lexists, isdir, islink, isfile @@ -37,6 +38,14 @@ def pwd(dir): log.debug('changing dir to %s' % old_dir) chdir(old_dir) +@contextmanager +def log_file(fname): + with file(fname, 'a') as fout: + fout.write("-- Beginning log of %s at %s --\n" % (fname, datetime.now().isoformat(' '))) + fout.flush() + yield fout + fout.write("-- Ending log of %s at %s --\n" % (fname, datetime.now().isoformat(' '))) + def rm(tgt): if isdir(tgt): rmtree(tgt) diff --git a/modules/cabal.py b/modules/cabal.py index cc82db7..db5a636 100644 --- a/modules/cabal.py +++ b/modules/cabal.py @@ -29,7 +29,7 @@ from urllib import urlopen, urlretrieve from base.base import log from base.module import Module from base.exceptions import ExecutionException -from base.util import pwd, one +from base.util import pwd, one, log_file from base.vars import orig_src_dir, haskell_compiler from modules.dirfactory import DirFactory @@ -59,7 +59,7 @@ class Cabal(Module): def compile_setup(self, orig=''): log.debug('code_dir is ' + self.package.code_dir) with pwd(self.package.code_dir): - with file('ghc.log', 'a') as ghc_out: + with log_file('ghc.log') as ghc_out: log.debug('ghc.log file is ' + str(ghc_out)) log.debug('source_dir is ' + self.package.source_dir(orig)) with pwd(self.package.source_dir(orig)): @@ -73,7 +73,7 @@ class Cabal(Module): user = True if target == 'home' else False self.compile_setup(orig) with pwd(self.package.code_dir): - with file('cabal.log', 'a') as cabal_out: + with log_file('cabal.log') as cabal_out: log.debug('source_dir is ' + self.package.source_dir(orig)) with pwd(self.package.source_dir(orig)): args = [abspath('Setup'), 'configure'] + \ @@ -86,7 +86,7 @@ class Cabal(Module): '''This is not safe to run on an unconfigured source dir''' self.compile_setup(orig) with pwd(self.package.code_dir): - with file('cabal.log', 'a') as cabal_out: + with log_file('cabal.log') as cabal_out: with pwd(self.package.source_dir(orig)): args = [abspath('Setup'), 'build'] p = Popen(args, stdout=cabal_out, stderr=cabal_out) @@ -97,7 +97,7 @@ class Cabal(Module): '''This is not safe to run on an unconfigured source dir''' self.compile_setup(orig) with pwd(self.package.code_dir): - with file('cabal.log', 'a') as cabal_out: + with log_file('cabal.log') as cabal_out: with pwd(self.package.source_dir(orig)): args = [abspath('Setup'), 'install'] p = Popen(args, stdout=cabal_out, stderr=cabal_out) |