summaryrefslogtreecommitdiff
path: root/tests/enigma.py
blob: c1f3bf6d5050a74c1716c9170c8cb2d2e1b0ac37 (plain)
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
# fake-enigma

import fake_time

class slot:
	def __init__(self):
		self.list = [ ]

	def get(self):
		return self.list

	def __call__(self):
		for x in self.list:
			x()

timers = set()

import time

from events import eventfnc

##################### ENIGMA BASE

class eTimer:
	def __init__(self):
		self.timeout = slot()
		self.next_activation = None
	
	def start(self, msec, singleshot = False):
		self.next_activation = time.time() + msec / 1000.0
		self.msec = msec
		self.singleshot = singleshot
		timers.add(self)
	
	def stop(self):
		timers.remove(self)

	def __repr__(self):
		return "<eTimer timeout=%s next_activation=%s singleshot=%s>" % (repr(self.timeout), repr(self.next_activation), repr(self.singleshot))

	def do(self):
		if self.singleshot:
			self.stop()
		self.next_activation += self.msec / 1000.0
		self.timeout()

def runIteration():
	running_timers = list(timers)
	assert len(running_timers), "no running timers, so nothing will ever happen!"
	running_timers.sort(key=lambda x: x.next_activation)
	
	next_timer = running_timers[0]

	now = time.time()
	delay = next_timer.next_activation - now 
	
	if delay > 0:
		time.sleep(delay)
		now += delay

	while len(running_timers) and running_timers[0].next_activation <= now:
		running_timers[0].do()
		running_timers = running_timers[1:]

stopped = False

def stop():
	global stopped
	stopped = True

def run(duration = 1000):
	stoptimer = eTimer()
	stoptimer.start(duration * 1000.0)
	stoptimer.timeout.get().append(stop)
	while not stopped:
		runIteration()


##################### ENIGMA GUI

eSize = None
ePoint = None
gFont = None
eWindow = None
eLabel = None
ePixmap = None
eWindowStyleManager = None
loadPNG = None
addFont = None
gRGB = None
eWindowStyleSkinned = None
eButton = None
eListboxPythonStringContent = None
eListbox = None

class eEPGCache:
	@classmethod
	def getInstance(self):
		return self.instance

	instance = None

	def __init__(self):
		eEPGCache.instance = self

	def lookupEventTime(self, ref, query):
		return None

eEPGCache()

getBestPlayableServiceReference = None

class pNavigation:
	def __init__(self):
		self.m_event = slot()
		self.m_record_event = slot()

	@eventfnc
	def recordService(self, service):
		return iRecordableService(service)

	@eventfnc
	def stopRecordService(self, service):
		service.stop()

	@eventfnc
	def playService(self, service):
		return None

eRCInput = None
getPrevAsciiCode = None

class eServiceReference:

	isDirectory=1
	mustDescent=2
	canDescent=4
	flagDirectory=isDirectory|mustDescent|canDescent
	shouldSort=8
	hasSortKey=16
	sort1=32
	isMarker=64
	isGroup=128

	def __init__(self, ref):
		self.ref = ref
		self.flags = 0

	def toString(self):
		return self.ref

	def __repr__(self):
		return self.toString()

class iRecordableService:
	def __init__(self, ref):
		self.ref = ref

	@eventfnc
	def prepare(self, filename, begin, end, event_id):
		return 0
	
	@eventfnc
	def start(self):
		return 0

	@eventfnc
	def stop(self):
		return 0
	
	def __repr__(self):
		return "iRecordableService(%s)" % repr(self.ref)

quitMainloop = None

class eAVSwitch:
	@classmethod
	def getInstance(self):
		return self.instance

	instance = None

	def __init__(self):
		eAVSwitch.instance = self

	def setColorFormat(self, value):
		print "[eAVSwitch] color format set to %d" % value

	def setAspectRatio(self, value):
		print "[eAVSwitch] aspect ratio set to %d" % value

	def setWSS(self, value):
		print "[eAVSwitch] wss set to %d" % value

	def setSlowblank(self, value):
		print "[eAVSwitch] wss set to %d" % value

	def setVideomode(self, value):
		print "[eAVSwitch] wss set to %d" % value

	def setInput(self, value):
		print "[eAVSwitch] wss set to %d" % value

eAVSwitch()

eDVBVolumecontrol = None

class eRFmod:
	@classmethod
	def getInstance(self):
		return self.instance

	instance = None

	def __init__(self):
		eRFmod.instance = self

	def setFunction(self, value):
		print "[eRFmod] set function to %d" % value

	def setTestmode(self, value):
		print "[eRFmod] set testmode to %d" % value

	def setSoundFunction(self, value):
		print "[eRFmod] set sound function to %d" % value

	def setSoundCarrier(self, value):
		print "[eRFmod] set sound carrier to %d" % value

	def setChannel(self, value):
		print "[eRFmod] set channel to %d" % value

	def setFinetune(self, value):
		print "[eRFmod] set finetune to %d" % value

eRFmod()


class eDBoxLCD:
	@classmethod
	def getInstance(self):
		return self.instance
	
	instance = None
	
	def __init__(self):
		eDBoxLCD.instance = self

	def setLCDBrightness(self, value):
		print "[eDBoxLCD] set brightness to %d" % value

	def setLCDContrast(self, value):
		print "[eDBoxLCD] set contrast to %d" % value

	def setInverted(self, value):
		print "[eDBoxLCD] set inverted to %d" % value

eDBoxLCD();

Misc_Options = None

class eServiceCenter:
	@classmethod
	def getInstance(self):
		return self.instance

	instance = None

	def __init__(self):
		eServiceCenter.instance = self

	def info(self, ref):
		return None

eServiceCenter()

##################### ENIGMA CHROOT

import Tools.Directories

chroot="."

for (x, (y, z)) in Tools.Directories.defaultPaths.items():
	Tools.Directories.defaultPaths[x] = (chroot + y, z)

Tools.Directories.defaultPaths[Tools.Directories.SCOPE_SKIN] = ("../data/", Tools.Directories.PATH_DONTCREATE)
Tools.Directories.defaultPaths[Tools.Directories.SCOPE_CONFIG] = ("/etc/enigma2/", Tools.Directories.PATH_DONTCREATE)

##################### ENIGMA CONFIG

import Components.config

my_config = [
"config.skin.primary_skin=None\n"
]

Components.config.config.unpickle(my_config)

##################### ENIGMA ACTIONS

class eActionMap:
	def __init__(self):
		pass


##################### ENIGMA STARTUP:

def init_nav():
	import Navigation, NavigationInstance
	NavigationInstance.instance = Navigation.Navigation()

def init_record_config():
	import Components.RecordingConfig
	Components.RecordingConfig.InitRecordingConfig()

def init_parental_control():
	from Components.ParentalControl import InitParentalControl
	InitParentalControl()

def init_all():
	# this is stuff from mytest.py
	init_nav()
	
	init_record_config()
	init_parental_control()
	
	import Components.InputDevice
	Components.InputDevice.InitInputDevices()

	import Components.AVSwitch
	Components.AVSwitch.InitAVSwitch()

	import Components.UsageConfig
	Components.UsageConfig.InitUsageConfig()

	import Components.Network
	Components.Network.InitNetwork()

	import Components.Lcd
	Components.Lcd.InitLcd()

	import Components.SetupDevices
	Components.SetupDevices.InitSetupDevices()

	import Components.RFmod
	Components.RFmod.InitRFmod()

	import Components.NimManager

	import Screens.Ci
	Screens.Ci.InitCiConfig()