From c64b800618e594d089eb8e9ae68e99b95c937592 Mon Sep 17 00:00:00 2001 From: brent s Date: Sun, 7 May 2017 11:21:44 -0400 Subject: [PATCH] better log file --- aifclient.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/aifclient.py b/aifclient.py index 6e54033..c0d577f 100755 --- a/aifclient.py +++ b/aifclient.py @@ -16,6 +16,7 @@ try: except ImportError: import xml.etree.ElementTree as etree # https://docs.python.org/3/library/xml.etree.elementtree.html lxml_avail = False +import datetime import shlex import fileinput import os @@ -31,7 +32,7 @@ import urllib.response as urlresponse from ftplib import FTP_TLS from io import StringIO -logfile = '/root/log' +logfile = '/root/aif.log.{0}'.format(int(datetime.datetime.utcnow().timestamp())) class aif(object): @@ -881,6 +882,9 @@ class archInstall(object): scripts = self.scripts if not pkgcmds: pkgcmds = self.packagecmds() + # Switch in the log, and link. + os.rename(logfile, '{0}/{1}'.format(self.system['chrootpath'], logfile)) + os.symlink('{0}/{1}'.format(self.system['chrootpath'], logfile), logfile) self.pacmanSetup() # This needs to be done before the chroot # We don't need this currently, but we might down the road. #chrootscript = '#!/bin/bash\n# https://aif.square-r00t.net/\n\n' @@ -922,6 +926,9 @@ class archInstall(object): def unmount(self): with open(logfile, 'a') as log: subprocess.call(['umount', '-lR', self.system['chrootpath']], stdout = log, stderr = subprocess.STDOUT) + # We should also remove the (now dead) log symlink. + #Note that this does NOT delete the logfile on the installed system. + os.remove(logfile) return() def runInstall(confdict):