@@ -7,12 +7,16 @@ from six.moves.tkinter import *
7
7
from six .moves import tkinter_scrolledtext as ScrolledText
8
8
from six .moves import tkinter_font as tkFont
9
9
from six .moves import urllib
10
- import os
11
10
import re
12
- import subprocess
13
11
import sys
14
12
15
13
14
+ OK_FAIL_COMMAND_PATTERNS = [
15
+ # These commands don't get highlighted if they return nonzero
16
+ "rpm --query" ,
17
+ "systemctl is-active" ,
18
+ r"service\s+\S+\s+status"
19
+ ]
16
20
17
21
18
22
class Section (object ):
@@ -63,10 +67,10 @@ def load_logdata_from_handle(handle):
63
67
current_test = match .group ('test' )
64
68
65
69
retcode , _ , _ = match .group ('result' ).split ()
66
- if int ( retcode ) != 0 and 'rpm --query' not in match . group ( 'command' ):
67
- color = "red"
68
- else :
69
- color = "black "
70
+ color = "black"
71
+ if int ( retcode ) != 0 :
72
+ if not any ( re . search ( pattern , match . group ( 'command' )) for pattern in OK_FAIL_COMMAND_PATTERNS ) :
73
+ color = "red "
70
74
section = Section (' ' + match .group ('lineno' ) + ':' + match .group ('command' ), color = color )
71
75
else :
72
76
section = Section (match .group (1 ))
@@ -91,8 +95,11 @@ def load_logdata_from_url(url):
91
95
try :
92
96
urlhandle = urllib .request .urlopen (url )
93
97
return load_logdata_from_handle (urlhandle )
94
- except urllib .error as e :
95
- print ("Error reading URL %s: %s" % (url , e .strerror ), file = sys .stderr )
98
+ except urllib .error .HTTPError as e :
99
+ print ("HTTP error code %d reading URL %s: %s" % (e .code , url , e .reason ), file = sys .stderr )
100
+ sys .exit (1 )
101
+ except urllib .error .URLError as e :
102
+ print ("Error reading URL %s: %s" % (url , e .reason ), file = sys .stderr )
96
103
sys .exit (1 )
97
104
98
105
@@ -187,7 +194,7 @@ def main():
187
194
logdata = load_logdata_from_url (logpath )
188
195
root = Tk ()
189
196
root .wm_title ("osg-test log viewer: " + logpath )
190
- app = Application (root , logpath , logdata )
197
+ Application (root , logpath , logdata )
191
198
root .mainloop ()
192
199
193
200
if __name__ == '__main__' :
0 commit comments