Webinterface: check fullpath in getMovieSubdirs
[enigma2-plugins.git] / emailclient / src / __init__.py
1 '''
2 Common functions for EmailClient
3 '''
4 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
5 from Components.config import config
6 import os, time
7
8 def initLog():
9         try:
10                 os.remove("/tmp/EmailClient.log")
11         except OSError:
12                 pass
13
14 def debug(message):
15         if config.plugins.emailimap.debug.value:
16                 try:
17                         deb = open("/tmp/EmailClient.log", "aw")
18                         deb.write(time.ctime() + ': ' + message + "\n")
19                         deb.close()
20                 except Exception, e:
21                         debug("%s (retried debug: %s)" %(repr(message), str(e)))
22
23 from enigma import getDesktop
24 DESKTOP_WIDTH = getDesktop(0).size().width()
25 DESKTOP_HEIGHT = getDesktop(0).size().height()
26 def scaleH(y2, y1):
27         if y2 == -1:
28                 y2 = y1*1280/720
29         elif y1 == -1:
30                 y1 = y2*720/1280
31         return scale(y2, y1, 1280, 720, DESKTOP_WIDTH)
32 def scaleV(y2, y1):
33         if y2 == -1:
34                 y2 = y1*720/576
35         elif y1 == -1:
36                 y1 = y2*576/720
37         return scale(y2, y1, 720, 576, DESKTOP_HEIGHT)
38 def scale(y2, y1, x2, x1, x):
39         return (y2 - y1) * (x - x1) / (x2 - x1) + y1