File: atheist-gui.py

package info (click to toggle)
atheist 0.20110402-3
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 1,348 kB
  • sloc: python: 4,764; xml: 626; makefile: 113; cpp: 54; ansic: 5; sh: 5
file content (77 lines) | stat: -rwxr-xr-x 1,990 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/python -u
# -*- mode: python; coding: utf-8 -*-

import sys
import gtk

import atheist
from atheist.const import *
from atheist.manager import Manager
from atheist.utils import relpath
import pyarco.UI

pyarco.UI.get_ostream().color = False



def pretty(value):

    RESULT_STR = {\
        FAIL:      ('#f77', 'FAIL'),
        OK:        ('green',   'OK'),
        NOEXEC:    ('#fff',  '--'),
        ERROR:     ('#f00',  '!!'),
        UNKNOWN:   ('#ccc' , '??'),
        TODO:      ('#fbf',  'ToDo'),
        mild_FAIL: ('#fcc',  'fail')}

    return RESULT_STR[value]


class AtheistGui:

    def __init__(self):
        gui = gtk.Builder()
        gui.add_from_file('gui.xml')

        window = gui.get_object('window')
        window.connect('delete-event', gtk.main_quit)
        window.show_all()

        mng = Manager(sys.argv[1:])
        mng.reload()
        i = 0

        self.store = gui.get_object('tasks')

        for case in mng.itercases():
            bgcolor, result = pretty(case.result)

            iter_ = self.store.append(None)
            self.store.set(iter_,
                           1, relpath(case.fname),
                           2, "Case",
                           4, result,
                           5, bgcolor,
                           6, False)

            for task in case.tasks:
                cmd_desc = task.cmd if hasattr(task, 'cmd') else task.desc

                bgcolor, result = pretty(i)
                if i < 6: i += 1

                child_iter = self.store.append(iter_)
                self.store.set(child_iter,
                               0, task.indx,
                               1, pyarco.UI.ellipsis(cmd_desc),
                               2, task.acro,
                               3, cmd_desc.replace('\n', '\n\t') + '\n---\n' + task.desc,
                               4, result,
                               5, bgcolor,
                               6, False)



AtheistGui()
gtk.main()