Commits

Wang Dingwei  committed 7df4e9e

not commentable

  • Participants
  • Parent commits c24d3d3

Comments (0)

Files changed (4)

 # Author: Joel Wang <Joel_Wang@wistron.com>
 #
 # History:
-# 2010-10-12, V4.1, uses MVC.
+# 2010-10-12, V4.2, uses MVC. Fixed MUI ordering caused false positive.
 # 2010-09-17, V4.0, output as html, opens in browser instead of cmd
 # 2010-08-25, V3.0, colorful output
 # 2010-06-19, V2.1, fixed MUI logic. Added py2exe support.

File constants.py

 "Constants for other modules."
 
-VERSION = 4.1
+VERSION = 4.2
 SDR_PATH = 'C:\\dell.sdr'
 
     else:
         return False
 
-def mui_matched(os_mui, sdr_mui):
+def mui_matched(sdr_mui, os_mui):
     "Compares all mui parts with registry info, return True if OK."
-    if len(os_mui) == len(sdr_mui):
-        zipped = zip(sdr_mui, os_mui)
-        for (sdr_lang, os_lang) in zipped:
-            if not lang_matched(sdr_lang, os_lang):
-                return False
-        return True
-    else:
+    if len(os_mui) != len(sdr_mui):
         return False
+    match_count = 0
+    for o in os_mui:
+        for s in sdr_mui:
+            if lang_matched(s, o):
+                match_count += 1
+                break
+    return match_count == len(sdr_mui)
+
 
 class Result(object):
     "OS and SDR comparison result."
         self.msg = []           # Custom messages
         self.os_type_str = ''   # OS info, e.g., "Windows 7 Professional, 32bit"
         self.sdr_type_str = ''  # same as above, but from SDR
-        self.os_langs = []      # OS MUI languages
-        self.sdr_langs = []     # SDR MUI languages
-        self.os_lang = ''       # Installed language
-        self.sdr_lang = ''      # SDR language
+        self.os_langs_str = []      # OS MUI languages
+        self.sdr_langs_str = []     # SDR MUI languages
+        self.os_lang_str = ''       # Installed language
+        self.sdr_lang_str = ''      # SDR language
         self.po = ''            # PO number
 
     def os_string(self, li):
             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()
         except Exception, e:
             self.result = 'NG'
             self.msg.append(e)
             self.sdr_type = self.sdrobj.os_type()
             self.sdr_lang = self.sdrobj.os_lang()
             self.po = self.sdrobj.get_po()
-            self.sdr_type_str = self.os_string(self.sdr_type)        
+            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()
         except Exception, e:
             self.result = 'NG'
             self.msg.append(e)
 
 <hr>
 
-% if len(res.os_langs_str()) > 1:
+% if len(res.os_langs_str) > 1:
     <b>Installed languages:</b>
     <br>
     <ul>
-    % for lang in res.os_langs_str():
+    % for lang in res.os_langs_str:
         <li>${lang}</li>
     % endfor
     </ul>
 % else:
-    <b>Installed language: </b>${res.os_lang_str()}
+    <b>Installed language: </b>${res.os_lang_str}
     <br>
 % endif
 
-% if len(res.sdr_langs_str()) > 1:
+% if len(res.sdr_langs_str) > 1:
     <b>Required languages:</b><br>
     <ul>
-    % for lang in res.sdr_langs_str():
+    % for lang in res.sdr_langs_str:
         <li>${lang}</li>
     % endfor
     </ul>
 % else:
-    <b>Required language: </b>${res.sdr_lang_str()}
+    <b>Required language: </b>${res.sdr_lang_str}
     <br>
 % endif
 </body></html>'''
     with open(html, 'w') as f:
         f.write(templ.render(version=VERSION, res=res))
     webbrowser.open(html)
+