sources for repevent.py [rev. unknown]
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
""" Reporter classes for showing asynchronous and synchronous status events
"""
import py
import time
def basic_report(msg_type, message):
    print msg_type, message
#def report(msg_type, message):
#    pass
##def report_error(excinfo):
##    if isinstance(excinfo, py.test.collect.Item.Skipped):
##        # we need to dispatch this info
##        report(Skipped(excinfo))
##    else:
##        report("itererror", excinfo)
def wrapcall(reporter, func, *args, **kwargs):
    reporter(CallStart(func, args, kwargs))
    try:
        retval = func(*args, **kwargs)
    except:
        reporter(CallException(func, args, kwargs))
        raise
    else:
        reporter(CallFinish(func, args, kwargs))
        return retval
# ----------------------------------------------------------------------
# Reporting Events 
# ----------------------------------------------------------------------
class ReportEvent(object):
    def __repr__(self):
        l = ["%s=%s" %(key, value)
           for key, value in self.__dict__.items()]
        return "<%s %s>" %(self.__class__.__name__, " ".join(l),)
class SendItem(ReportEvent):
    def __init__(self, channel, item):
        self.item = item
        self.channel = channel
        if channel:
            self.host = channel.gateway.host
class ReceivedItemOutcome(ReportEvent):
    def __init__(self, channel, item, outcome):
        self.channel = channel
        if channel:
            self.host = channel.gateway.host
        self.item = item
        self.outcome = outcome
class CallEvent(ReportEvent):
    def __init__(self, func, args, kwargs):
        self.func = func
        self.args = args
        self.kwargs = kwargs
    
    def __repr__(self):
        call = "%s args=%s, kwargs=%s" %(self.func.__name__, 
                                         self.args, self.kwargs)
        return '<%s %s>' %(self.__class__.__name__, call)
class CallStart(CallEvent):
    pass
class CallException(CallEvent):
    pass
class CallFinish(CallEvent):
    pass
class HostRSyncing(ReportEvent):
    def __init__(self, host, root, remotepath, synced):
        self.host = host
        self.root = root
        self.remotepath = remotepath
        self.synced = synced
class HostGatewayReady(ReportEvent):
    def __init__(self, host, roots):
        self.host = host
        self.roots = roots
class HostRSyncRootReady(ReportEvent):
    def __init__(self, host, root):
        self.host = host
        self.root = root
class TestStarted(ReportEvent):
    def __init__(self, hosts, topdir, roots):
        self.hosts = hosts
        self.topdir = topdir
        self.roots = roots
        self.timestart = time.time()
class TestFinished(ReportEvent):
    def __init__(self):
        self.timeend = time.time()
class Nodes(ReportEvent):
    def __init__(self, nodes):
        self.nodes = nodes
class SkippedTryiter(ReportEvent):
    def __init__(self, excinfo, item):
        self.excinfo = excinfo
        self.item = item
class FailedTryiter(ReportEvent):
    def __init__(self, excinfo, item):
        self.excinfo = excinfo
        self.item = item
class ItemStart(ReportEvent):
    """ This class shows most of the start stuff, like directory, module, class
    can be used for containers
    """
    def __init__(self, item):
        self.item = item
class RsyncFinished(ReportEvent):
    def __init__(self):
        self.time = time.time()
class ImmediateFailure(ReportEvent):
    def __init__(self, item, outcome):
        self.item = item
        self.outcome = outcome
class PongReceived(ReportEvent):
    def __init__(self, hostid, result):
        self.hostid = hostid
        self.result = result
class InterruptedExecution(ReportEvent):
    def __init__(self):
        self.timeend = time.time()
class CrashedExecution(ReportEvent):
    def __init__(self):
        self.timeend = time.time()