Bug 692819

Summary: journal tracebacks on colorized output when WARN is printed
Product: [Fedora] Fedora Reporter: Karel Srot <ksrot>
Component: beakerlibAssignee: Petr Muller <pmuller>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: bpeck, dcallagh, jhutar, mcsontos, mvadkert, ohudlick, pmuller, psplicha, rmancy, stl
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-07-25 13:54:32 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Karel Srot 2011-04-01 09:58:01 UTC
Description of problem:


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: Cleanup
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   PASS   ] :: Running 'ausearch -m AVC -ts 04/01/2011 05:43:51 > /tmp/tmp.bxhS77B2fB'
:: [   PASS   ] :: Running 'cat /tmp/tmp.bxhS77B2fB'
:: [   FAIL   ] :: number of lines in /tmp/tmp.bxhS77B2fB should be 0 (Assert: expected 0, got 4)
:: [   PASS   ] :: Running 'semodule -r testpolicy'
:: [   PASS   ] :: Running 'rm -f testpolicy.pp'
:: [   LOG    ] :: Duration: 41s
:: [   LOG    ] :: Assertions: 4 good, 1 bad
Traceback (most recent call last):
  File "/usr/bin/beakerlib-journalling", line 468, in <module>
    createLog(options.testid, options.severity)
  File "/usr/bin/beakerlib-journalling", line 181, in createLog
    printPhaseLog(nod,severity)
  File "/usr/bin/beakerlib-journalling", line 123, in printPhaseLog
    printLog("RESULT: %s" % phaseName, phaseResult)
  File "/usr/bin/beakerlib-journalling", line 70, in printLog
    color = termColors[prefix]
KeyError: u'WARN'
:: [05:44:42] ::  JOURNAL XML: /tmp/beakerlib-ogTVleP/journal.xml
:: [05:44:42] ::  JOURNAL TXT: /tmp/beakerlib-ogTVleP/journal.txt


Version-Release number of selected component (if applicable):
[root@ibm-z10-28 bz543941-running-vhostmd]# rpm -qa | grep beaker
beaker-distribution-install-1.10-12.noarch
beakerlib-redhat-1-4.el6.noarch
beaker-distribution-reservesys-2.0-48.noarch
beakerlib-1.3-6.el6.noarch


How reproducible:
manually executed a test /CoreOS/selinux-policy/Regression/bz543941-running-vhostmd on a reserved s390x RHEL6.0 machine

Comment 1 Petr Muller 2011-04-01 14:54:29 UTC
This is a nice python programming (and reviewing) bug :)

>>> "WARN" in "WARNING"
True

and so I pushed the following patch. Thanks for the report.

--- a/src/python/journalling.py
+++ b/src/python/journalling.py
@@ -66,7 +66,7 @@ def printPurpose(message):
 
 def printLog(message, prefix="LOG"):
   color = uncolor = ""
-  if sys.stdout.isatty() and prefix in "PASS FAIL INFO WARNING":
+  if sys.stdout.isatty() and prefix in ("PASS", "FAIL", "INFO", "WARNING"):
     color = termColors[prefix]
     uncolor = "\033[0m"
   for line in message.split("\n"):
--

Comment 2 Petr Muller 2011-04-06 10:57:40 UTC
*** Bug 693997 has been marked as a duplicate of this bug. ***

Comment 3 Petr Muller 2011-04-07 10:38:54 UTC
*** Bug 694392 has been marked as a duplicate of this bug. ***

Comment 4 Petr Muller 2011-04-07 10:40:08 UTC
We also probably want to add WARN coloring as well

Comment 6 Petr Muller 2012-07-25 13:54:32 UTC
Closing, this should be in for a long time.