Enable zypper-log reading lzma (.xz) compressed logs.
authorMichael Andres <ma@suse.de>
Mon, 10 Sep 2012 12:29:05 +0000 (14:29 +0200)
committerMichael Andres <ma@suse.de>
Mon, 10 Sep 2012 12:29:05 +0000 (14:29 +0200)
doc/zypper-log.8
tools/zypper-log
zypper.spec.cmake

index 60927c1..98a044e 100644 (file)
@@ -6,7 +6,7 @@ zypper-log \- Zypper logfile reader
 .SH SYNOPSIS
 \fBzypper-log\fP [\fIoptions\fP] [\fIpid\fP]
 .SH DESCRIPTION
-zypper-log can read zypper's logfiles. It can also handle rotated logfiles, and will open plain, gz and bz2-compressed files.
+zypper-log can read zypper's logfiles. It can also handle rotated logfiles, and will open plain, xz, gz and bz2-compressed files.
 .sp
 By default zypper.log will be read in.
 .sp
index 890ece2..710ebae 100755 (executable)
@@ -6,6 +6,7 @@
 # Author: Dominik Heidler <dheidler@suse.de>
 
 import os, string, re, bz2, zlib, sys, time, argparse, errno
+import subprocess
 
 filenamelen = 0
 pidlen = 0
@@ -35,7 +36,9 @@ def readFile(logfile):
     print >> sys.stderr, "\rIOError: %s: '%s'" % (e.strerror, e.filename)
     sys.exit(1)
   fext = logfile.split('.')[-1]
-  if fext == 'bz2':
+  if fext == 'xz':
+    logtxt = subprocess.Popen(['xzcat',logfile], stdout=subprocess.PIPE).stdout.read()
+  elif fext == 'bz2':
     logtxt = bz2.decompress(logtxt)
   elif fext == 'gz':
     logtxt = zlib.decompress(logtxt)
index c03c294..19a8b41 100644 (file)
@@ -64,6 +64,7 @@ Requires:       python-argparse
 %else
 Requires:       python >= 2.7
 %endif
+Requires:      xz
 BuildArch:      noarch
 Summary:        CLI for accessing the zypper logfile
 License:        GPL-2.0+