[rhel7/master] Use low level file i/o for rpm callback logging (#1035745)
David Shea
dshea at redhat.com
Fri Aug 8 21:28:36 UTC 2014
On 08/08/2014 05:17 PM, Brian C. Lane wrote:
> Mixing the python file object with the low level fd as used by rpm
> resulted in mixed output. This switches to using a fd for logging from
> the callback so that its output and the script output will be
> synchronized.
> ---
> scripts/anaconda-yum | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/scripts/anaconda-yum b/scripts/anaconda-yum
> index f214d0a..e6752fd 100755
> --- a/scripts/anaconda-yum
> +++ b/scripts/anaconda-yum
> @@ -152,8 +152,8 @@ def run_yum_transaction(release, arch, yum_conf, install_root, ts_file, script_l
> yb.ts.clean()
>
> # Write scriptlet output to a file to be logged later
> - logfile = open(script_log, "w")
> - yb.ts.ts.scriptFd = logfile.fileno()
> + logfile = os.open(script_log, os.O_WRONLY|os.O_CREAT)
> + yb.ts.ts.scriptFd = logfile
> rpm.setLogFile(logfile)
>
> # create the install callback
> @@ -179,7 +179,7 @@ def run_yum_transaction(release, arch, yum_conf, install_root, ts_file, script_l
> print("INFO: transaction complete")
> finally:
> yb.ts.close()
> - logfile.close()
> + os.close(logfile)
> except Exception as e:
> print("ERROR: transaction error: %s" % e)
> finally:
> @@ -210,14 +210,14 @@ class RPMCallback(object):
> def __init__(self, yb, arch, log, debug=False):
> """ :param yb: YumBase object
> :type yb: YumBase
> - :param log: script logfile
> - :type log: string
> + :param log: file-descriptor of script logfile
> + :type log: int
> :param statusQ: status communication back to other process
> :type statusQ: Queue
> """
> self.yb = yb # yum.YumBase
> self.base_arch = arch
> - self.install_log = log # logfile for yum script logs
> + self.install_log = log # fd of logfile for yum script logs
> self.debug = debug
>
> self.package_file = None # file instance (package file management)
> @@ -273,7 +273,7 @@ class RPMCallback(object):
> log_msg = msg_format % (txmbr.po,
> self.completed_actions,
> self.total_actions)
> - self.install_log.write(log_msg+"\n")
> + os.write(self.install_log, log_msg+"\n")
> print("PROGRESS_INSTALL: %s" % progress_msg)
>
> try:
Ack.
More information about the anaconda-patches
mailing list