center screens
[enigma2-plugins.git] / rsdownloader / src / RSLog.py
1 ##\r
2 ## RS Downloader\r
3 ## by AliAbdul\r
4 ##
5 from Components.ActionMap import ActionMap
6 from Components.ScrollLabel import ScrollLabel\r
7 from RSConfig import config
8 from RSTranslation import TitleScreen\r
9 from time import strftime, time, localtime\r
10 \r
11 ##############################################################################\r
12 \r
13 def writeLog(message):\r
14         mayWrite = config.plugins.RSDownloader.write_log.value\r
15         \r
16         if mayWrite:\r
17                 log_file = "/tmp/rapidshare.log"\r
18                 \r
19                 try:\r
20                         f = open(log_file, "r")\r
21                         log = f.read()\r
22                         f.close()\r
23                 except:\r
24                         log = ""\r
25                 \r
26                 log = log + strftime("%c", localtime(time())) + " - " + message + "\n"\r
27                 \r
28                 try:\r
29                         f = open(log_file, "w")\r
30                         f.write(log)\r
31                         f.close()\r
32                 except:\r
33                         pass\r
34 ##############################################################################
35
36 class RSLogScreen(TitleScreen):
37         skin = """
38                 <screen position="center,center" size="520,400" title="RS Downloader" >
39                         <widget name="label" position="0,0" size="520,400" font="Regular;20" />
40                 </screen>"""
41
42         def __init__(self, session):
43                 TitleScreen.__init__(self, session)
44                 
45                 try:
46                         f = open("/tmp/rapidshare.log")
47                         log = f.read()
48                         f.close()
49                 except:
50                         log = ""
51                 self["label"] = ScrollLabel(log)
52                 
53                 self["actions"] = ActionMap(["WizardActions"],
54                         {
55                                 "ok": self.close,
56                                 "back": self.close,
57                                 "up": self["label"].pageUp,
58                                 "down": self["label"].pageDown,
59                                 "left": self["label"].pageUp,
60                                 "right": self["label"].pageDown
61                         }, -1)