update unicable stuff (by adenin)
[enigma2.git] / lib / python / Components / About.py
index 24bfb2b0c211e43c7dcac9e17d04be6a67f696fd..8e332e3381c85b8b5d565fc33caa92230e404e45 100644 (file)
@@ -1,17 +1,46 @@
-from Tools.Directories import *
+from Tools.Directories import resolveFilename, SCOPE_SYSETC
+from enigma import getEnigmaVersionString
 
 class About:
        def __init__(self):
                pass
-       
+
        def getVersionString(self):
-               file = open(resolveFilename(SCOPE_SYSETC, 'image-version'), 'r')
-               lines = file.readlines()
-               for x in lines:
-                       splitted = x.split('=')
-                       if splitted[0] == "version":
-                               return "2.0-" + str(splitted[1])
-               file.close()
-               return "2.0b"
-       
-about = About()
\ No newline at end of file
+               return self.getImageVersionString()
+
+       def getImageVersionString(self):
+               try:
+                       file = open(resolveFilename(SCOPE_SYSETC, 'image-version'), 'r')
+                       lines = file.readlines()
+                       for x in lines:
+                               splitted = x.split('=')
+                               if splitted[0] == "version":
+                                       #     YYYY MM DD hh mm
+                                       #0120 2005 11 29 01 16
+                                       #0123 4567 89 01 23 45
+                                       version = splitted[1]
+                                       image_type = version[0] # 0 = release, 1 = experimental
+                                       major = version[1]
+                                       minor = version[2]
+                                       revision = version[3]
+                                       year = version[4:8]
+                                       month = version[8:10]
+                                       day = version[10:12]
+                                       date = '-'.join((year, month, day))
+                                       if image_type == '0':
+                                               image_type = "Release"
+                                               version = '.'.join((major, minor, revision))
+                                               return ' '.join((image_type, version, date))
+                                       else:
+                                               image_type = "Experimental"
+                                               return ' '.join((image_type, date))
+                       file.close()
+               except IOError:
+                       pass
+
+               return "unavailable"
+
+       def getEnigmaVersionString(self):
+               return getEnigmaVersionString()
+
+about = About()