intial commit of autotimer, epgrefresh and werbezapper to enigma2-plugins
[enigma2-plugins.git] / autotimer / src / AutoPoller.py
1 # Timer
2 from enigma import eTimer
3
4 # Config
5 from Components.config import config
6
7 class AutoPoller:
8         """Automatically Poll AutoTimer"""
9
10         def __init__(self):
11                 # Keep track if we were launched before
12                 self.shouldRun = False
13
14                 # Init Timer
15                 self.timer = eTimer()
16                 self.timer.timeout.get().append(self.query)
17
18         def shouldRun(self):
19                 return config.plugins.autotimer.autopoll.value
20
21         def start(self, autotimer, initial = True):
22                 self.autotimer = autotimer
23                 if initial:
24                         delay = 2
25                 else:
26                         delay = config.plugins.autotimer.interval.value*3600
27                 self.timer.startLongTimer(delay)
28
29         def stop(self):
30                 self.timer.stop()
31
32         def query(self):
33                 # Ignore any exceptions
34                 try:
35                         self.autotimer.parseEPG()
36                 except:
37                         # Dump error to stdout
38                         import traceback, sys
39                         traceback.print_exc(file=sys.stdout)
40
41                 self.timer.startLongTimer(config.plugins.autotimer.interval.value*3600)
42
43 autopoller = AutoPoller()