Lines 84-89
Link Here
|
84 |
curses.init_pair(ewarn, curses.COLOR_YELLOW, curses.COLOR_BLACK) |
84 |
curses.init_pair(ewarn, curses.COLOR_YELLOW, curses.COLOR_BLACK) |
85 |
curses.init_pair(eerror, curses.COLOR_RED, curses.COLOR_BLACK) |
85 |
curses.init_pair(eerror, curses.COLOR_RED, curses.COLOR_BLACK) |
86 |
curses.init_pair(elog, curses.COLOR_MAGENTA, curses.COLOR_BLACK) |
86 |
curses.init_pair(elog, curses.COLOR_MAGENTA, curses.COLOR_BLACK) |
|
|
87 |
|
88 |
# Character used to print the class of an elog |
89 |
self.class_char = "*" |
87 |
|
90 |
|
88 |
# This attributes are used to manage the scrolling of the list |
91 |
# This attributes are used to manage the scrolling of the list |
89 |
# of files |
92 |
# of files |
Lines 238-247
Link Here
|
238 |
else: |
241 |
else: |
239 |
self.usel += n |
242 |
self.usel += n |
240 |
|
243 |
|
241 |
self.file_pad.addstr(prev_usel,0, |
244 |
self.file_pad.addstr(prev_usel,1, |
|
|
245 |
self.class_char, |
246 |
self.classes[prev_usel]) |
247 |
self.file_pad.addstr(prev_usel,3, |
242 |
"%s - %s" % (self.packages[prev_usel],self.dates[prev_usel]), |
248 |
"%s - %s" % (self.packages[prev_usel],self.dates[prev_usel]), |
243 |
curses.color_pair(normal)) |
249 |
curses.color_pair(normal)) |
244 |
self.file_pad.addstr(self.usel,0, |
250 |
self.file_pad.addstr(self.usel,1, |
|
|
251 |
self.class_char, |
252 |
self.classes[self.usel]) |
253 |
self.file_pad.addstr(self.usel,3, |
245 |
"%s - %s" % (self.packages[self.usel],self.dates[self.usel]), |
254 |
"%s - %s" % (self.packages[self.usel],self.dates[self.usel]), |
246 |
curses.color_pair(selected)) |
255 |
curses.color_pair(selected)) |
247 |
|
256 |
|
Lines 315-320
Link Here
|
315 |
|
324 |
|
316 |
self.packages = [] |
325 |
self.packages = [] |
317 |
self.dates = [] |
326 |
self.dates = [] |
|
|
327 |
self.classes = [] |
318 |
self.file_pad = curses.newpad(len(self.file_list),self.width) |
328 |
self.file_pad = curses.newpad(len(self.file_list),self.width) |
319 |
self.file_pad.clear() |
329 |
self.file_pad.clear() |
320 |
|
330 |
|
Lines 322-327
Link Here
|
322 |
(category,package_name,other) = item.split(":") |
332 |
(category,package_name,other) = item.split(":") |
323 |
self.packages.append(category + "/" + package_name) |
333 |
self.packages.append(category + "/" + package_name) |
324 |
self.dates.append(other[:8]) |
334 |
self.dates.append(other[:8]) |
|
|
335 |
self.classes.append(self.get_class(item)) |
325 |
|
336 |
|
326 |
for i in range(0,len(self.file_list)): |
337 |
for i in range(0,len(self.file_list)): |
327 |
if i == self.usel: |
338 |
if i == self.usel: |
Lines 329-338
Link Here
|
329 |
else: |
340 |
else: |
330 |
cp = normal |
341 |
cp = normal |
331 |
|
342 |
|
332 |
self.file_pad.addstr(i,0, |
343 |
self.file_pad.addstr(i,1, |
|
|
344 |
self.class_char, |
345 |
self.classes[i]) |
346 |
self.file_pad.addstr(i,3, |
333 |
"%s - %s" % (self.packages[i],self.dates[i]), |
347 |
"%s - %s" % (self.packages[i],self.dates[i]), |
334 |
curses.color_pair(cp)) |
348 |
curses.color_pair(cp)) |
335 |
|
349 |
|
|
|
350 |
def get_class(self,item): |
351 |
""" |
352 |
Get the highest elog class in a file |
353 |
""" |
354 |
filepath = os.path.join(elogdir,item) |
355 |
f = file(filepath) |
356 |
file_class = 0; |
357 |
|
358 |
for line in f: |
359 |
if line.startswith('LOG:') and file_class < 1: |
360 |
file_class = 1 |
361 |
elif line.startswith('WARN:') and file_class < 2: |
362 |
file_class = 2 |
363 |
elif line.startswith('ERROR:') and file_class < 3: |
364 |
file_class = 3 |
365 |
|
366 |
f.close() |
367 |
|
368 |
if file_class == 0: |
369 |
return curses.color_pair(einfo) |
370 |
elif file_class == 1: |
371 |
return curses.color_pair(elog) |
372 |
elif file_class == 2: |
373 |
return curses.color_pair(ewarn) |
374 |
else: |
375 |
return curses.color_pair(eerror) |
376 |
|
336 |
def show_log(self): |
377 |
def show_log(self): |
337 |
""" |
378 |
""" |
338 |
Display the selected file, if the length of the file is bigger than |
379 |
Display the selected file, if the length of the file is bigger than |