Commits

Wang Dingwei committed 871f43a

python 2.5 support

  • Participants
  • Parent commits 7df4e9e

Comments (0)

Files changed (3)

 
     # Parsing arguments
     opts = optparse.OptionParser(usage=USAGE, version=VERSION)
-    opts.add_option('-d', '--dump-data', action="store_true",
-            dest='DUMP_DATA')
+    opts.add_option('-d', '--debug', action="store_true",
+            dest='DEBUG')
     opts.add_option('-v', '--verbose', action="store_true",
             dest='VERBOSE')
 
     except Exception, e:
         res.result = 'NG'
         res.msg.append(e)
+        if options.DEBUG:
+            raise
 
     if options.VERBOSE:
         print "Result:", res.result
         print "PO:", res.po
         print "OS Type:", res.os_type_str
         print "SDR Type:", res.sdr_type_str
-        print "OS Languages:", res.os_langs_str()
-        print "OS Language:", res.os_lang_str()
-        print "SDR languages:", res.sdr_langs_str()
-        print "SDR language:", res.sdr_lang_str()
+        print "OS Languages:", res.os_langs_str
+        print "OS Language:", res.os_lang_str
+        print "SDR languages:", res.sdr_langs_str
+        print "SDR language:", res.sdr_lang_str
 
-    if options.DUMP_DATA:
+    if options.DEBUG:
         output = open('dump', 'wb')
         pickle.dump(res, output)
         output.close()
 "Model for storing SDR data and OS data, and compare between them. "
 
-from wistron import ostype, sdrparse
+from wistron import ostype, sdrparser
 from constants import SDR_PATH
 
 def lang_matched(sdr_lang, os_lang):
         arch_ = li[3]
         return 'Windows ' + os_ + ' ' + sub_ + sp_ + arch_
 
-    def os_langs_str(self):
+    def get_os_langs_str(self):
         lang_strs = []
         for lang in self.os_langs:
             try:
             lang_strs.append(lang[0] + region) 
         return lang_strs
 
-    def os_lang_str(self):
+    def get_os_lang_str(self):
         if self.os_lang[1]:
             region = '(' + self.os_lang[1] + ')'
         else:
             region = ''
         return self.os_lang[0] + region
 
-    def sdr_lang_str(self):
+    def get_sdr_lang_str(self):
         if self.sdrobj.is_mui():
             return ''
 
             region = ''
         return self.sdr_lang[0] + region
 
-    def sdr_langs_str(self):
+    def get_sdr_langs_str(self):
         lang_strs = []
         for lang in self.sdr_langs:
             if lang[1]:
             self.os_lang = ostype.GetWindowsLanguage()
             self.os_langs = ostype.GetWindowsMUI()
             self.os_type_str = self.os_string(self.os_type)
-            self.os_lang_str = self.os_lang_str()
-            self.os_langs_str = self.os_langs_str()
+            self.os_lang_str = self.get_os_lang_str()
+            self.os_langs_str = self.get_os_langs_str()
         except Exception, e:
             self.result = 'NG'
             self.msg.append(e)
+            raise
 
     def get_sdr_info(self):
         try:
-            self.sdrobj = sdrparse.SDR(SDR_PATH)
+            self.sdrobj = sdrparser.SDR(SDR_PATH)
         except Exception, e:
             self.result = 'NG'
             self.msg.append(e)
+            raise
 
         try:
             self.sdr_type = self.sdrobj.os_type()
             self.sdr_lang = self.sdrobj.os_lang()
+            self.sdr_langs = self.sdrobj.mui_langs()
             self.po = self.sdrobj.get_po()
             self.sdr_type_str = self.os_string(self.sdr_type)
-            self.sdr_lang_str = self.sdr_lang_str()
-            self.sdr_langs_str = self.sdr_langs_str()
+            self.sdr_lang_str = self.get_sdr_lang_str()
+            self.sdr_langs_str = self.get_sdr_langs_str()
         except Exception, e:
             self.result = 'NG'
             self.msg.append(e)
+            raise
 
     def compare(self):
         if self.sdrobj.is_mui():
             self.msg.append("This is MUI order.")
-            self.sdr_langs = self.sdrobj.sdr_mui()
+            self.sdr_langs = self.sdrobj.mui_langs()
             self.result = 'OK' if self.os_langs == self.sdr_langs else 'NG'
         else:
             if (self.os_type == self.sdr_type and 
                 self.result = 'OK'
             else:
                 self.result = 'NG'
-
+        
+from __future__ import with_statement
+
 import os
 import tempfile
 import webbrowser