[hbbtv] upgraded.
[vuplus_dvbapp] / lib / python / Plugins / Extensions / HbbTV / vbcfg.py
1 from time import strftime, localtime
2 from Tools.Directories import fileExists
3
4 g_main = None
5 g_browser = None
6 g_youtubetv_cfg = None
7 g_service = None
8 g_channel_info = None
9 g_position = None
10
11 need_restart = False
12
13 APPROOT = "/usr/local/hbb-browser"
14 APP_RUN = "run.sh"
15
16 PLUGINROOT = "/usr/lib/enigma2/python/Plugins/Extensions/HbbTV"
17 MANUALROOT = "/usr/local/manual"
18
19 SOCKETFILE  = None
20 CONTROLFILE = None
21
22 def getPosition():
23         if fileExists("/proc/stb/fb/dst_left"):
24                 try:
25                         file = open("/proc/stb/fb/dst_left", "r")
26                         dst_left = int(file.read().strip(), 16)
27                         file.close()
28                         file = open("/proc/stb/fb/dst_width", "r")
29                         dst_width = int(file.read().strip(), 16)
30                         file.close()
31                         file = open("/proc/stb/fb/dst_top", "r")
32                         dst_top = int(file.read().strip(), 16)
33                         file.close()
34                         file = open("/proc/stb/fb/dst_height", "r")
35                         dst_height = int(file.read().strip(), 16)
36                         file.close()
37                 except Exception, Err:
38                         ERR(Err)
39                         return None
40         return (dst_left, dst_width, dst_top, dst_height)
41
42 def setPosition(params):
43         if params is None:
44                 return
45         if params[0] + params[1] > 720 or params[2] + params[3] > 576 :
46                 return
47         else:
48                 try:
49                         file = open("/proc/stb/fb/dst_left", "w")
50                         file.write('%X' % params[0])
51                         file.close()
52                         file = open("/proc/stb/fb/dst_width", "w")
53                         file.write('%X' % params[1])
54                         file.close()
55                         file = open("/proc/stb/fb/dst_top", "w")
56                         file.write('%X' % params[2])
57                         file.close()
58                         file = open("/proc/stb/fb/dst_height", "w")
59                         file.write('%X' % params[3])
60                         file.close()
61                 except Exception, Err:
62                         ERR(Err)
63                         return
64
65 # for debug True
66 g_debug = False
67
68 def LogEntry(mode, string):
69         if g_debug:
70                 print strftime("%x %X", localtime()), "%5s [%12s]" % (mode, "Plugin"), string
71         elif mode != "DEBUG":
72                 print "[browser]", string
73
74 def DEBUG(string):
75         LogEntry("DEBUG", string)
76
77 def LOG(string):
78         LogEntry("LOG", string)
79
80 def WARN(string):
81         LogEntry("WARN", string)
82
83 def ERR(string):
84         LogEntry("ERROR", string)