1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """
23 ETL transition.
24
25 Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
26 GNU General Public License.
27 """
28 from signal import signal
29 import datetime
31 """
32 Base class of ETL transition.
33 """
34 - def __init__(self, source, destination, channel_source='main', channel_destination='main', type='data', trigger=None):
35 super(transition, self).__init__()
36 self.type = type
37 self.trigger = trigger
38 self.source = source
39 self.destination = destination
40 self.channel_source = channel_source
41 self.channel_destination = channel_destination
42 self.destination.trans_in.append((channel_destination, self))
43 self.source.trans_out.append((channel_source, self))
44 self.status = 'open'
45
47 return "<Transition source='%s' destination='%s' channel_source='%s' channel_destination='%s' type='%s' trigger='%s' status='%s'>" \
48 %(self.source.name, self.destination.name, self.type, self.channel_source, self.channel_destination, self.trigger, self.status)
49
51 res = transition(self.source, self.destination, self.channel_source, self.channel_destination, self.type)
52 return res
53
56
59
62
64 self.status = 'stop'
65 self.signal('stop')
66
68 self.status = 'end'
69 self.signal('end', {'date': datetime.datetime.today()})
70
72 self.status = 'start'
73 self.signal('start', {'date': datetime.datetime.today()})
74
76 self.status = 'pause'
77 self.signal('pause')
78
80 self.status = 'start'
81 self.signal('restart')
82