From 9ff5897eee94fdeeaaa1b72d3687f31d6ae578e2 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 10 Feb 2015 12:05:23 -0800 Subject: [PATCH] Get the log directory from the configfile In the lorax script create it if missing and override it with the path of --logfile --- src/pylorax/__init__.py | 3 ++- src/sbin/lorax | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py index 8a46c069..fc489c61 100644 --- a/src/pylorax/__init__.py +++ b/src/pylorax/__init__.py @@ -87,6 +87,7 @@ class Lorax(BaseLoraxClass): self.conf.add_section("lorax") self.conf.set("lorax", "debug", "1") self.conf.set("lorax", "sharedir", "/usr/share/lorax") + self.conf.set("lorax", "logdir", "/var/log/lorax") self.conf.add_section("output") self.conf.set("output", "colors", "1") @@ -179,7 +180,7 @@ class Lorax(BaseLoraxClass): os.makedirs(self.workdir) # set up log directory - logdir = '/var/log/lorax' + logdir = self.conf.get("lorax", "logdir") if not os.path.isdir(logdir): os.makedirs(logdir) diff --git a/src/sbin/lorax b/src/sbin/lorax index 1e9c20ae..55871dbf 100755 --- a/src/sbin/lorax +++ b/src/sbin/lorax @@ -171,6 +171,8 @@ def main(args): parser.error("output directory %s should not exist." % outputdir) opts.logfile = os.path.abspath(opts.logfile) + if not os.path.exists(os.path.dirname(opts.logfile)): + os.makedirs(os.path.dirname(opts.logfile)) if opts.cachedir: opts.cachedir = os.path.abspath(opts.cachedir) if opts.workdir: @@ -214,6 +216,7 @@ def main(args): # run lorax lorax = pylorax.Lorax() lorax.configure(conf_file=opts.config) + lorax.conf.set("lorax", "logdir", os.path.dirname(opts.logfile)) lorax.run(dnfbase, opts.product, opts.version, opts.release, opts.variant, opts.bugurl, opts.isfinal, workdir=tempdir, outputdir=outputdir, buildarch=opts.buildarch,