objdictgen/doc_index/DS301_index.py
changeset 386 0f56a144ba5f
parent 341 7ff01f109bbc
child 408 f85552acc2bf
equal deleted inserted replaced
385:fff25f16c923 386:0f56a144ba5f
     2 # -*- coding: utf-8 -*-
     2 # -*- coding: utf-8 -*-
     3 
     3 
     4 import os,wx
     4 import os,wx
     5 
     5 
     6 DS301_PDF_INDEX = {0x1000: 86, 0x1001: 87, 0x1002: 87, 0x1003: 88, 0x1005: 89, 0x1006: 90, 0x1007: 90, 0x1008: 91, 0x1009: 91, 0x100A: 91, 0x100C: 92, 0x100D: 92, 0x1010: 92, 0x1011: 94, 0x1012: 97, 0x1013: 98, 0x1014: 98, 0x1015: 99, 0x1016: 100, 0x1017: 101, 0x1018: 101, 0x1020: 117, 0x1200: 103, 0x1201: 103, 0x1280: 105, 0x1400: 106, 0x1600: 109, 0x1800: 111, 0x1A00: 112}
     6 DS301_PDF_INDEX = {0x1000: 86, 0x1001: 87, 0x1002: 87, 0x1003: 88, 0x1005: 89, 0x1006: 90, 0x1007: 90, 0x1008: 91, 0x1009: 91, 0x100A: 91, 0x100C: 92, 0x100D: 92, 0x1010: 92, 0x1011: 94, 0x1012: 97, 0x1013: 98, 0x1014: 98, 0x1015: 99, 0x1016: 100, 0x1017: 101, 0x1018: 101, 0x1020: 117, 0x1200: 103, 0x1201: 103, 0x1280: 105, 0x1400: 106, 0x1600: 109, 0x1800: 111, 0x1A00: 112}
       
     7 
       
     8 def get_acroversion():
       
     9     " Return version of Adobe Acrobat executable or None"
       
    10     import _winreg
       
    11     adobesoft = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r'Software\Adobe')
       
    12     for index in range(_winreg.QueryInfoKey(adobesoft)[0]):
       
    13         key = _winreg.EnumKey(adobesoft, index)
       
    14         if "acrobat" in key.lower():
       
    15             acrokey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Adobe\\%s' % key)
       
    16             for index in range(_winreg.QueryInfoKey(acrokey)[0]):
       
    17                 numver = _winreg.EnumKey(acrokey, index)
       
    18                 try:
       
    19                     res = _winreg.QueryValue(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Adobe\\%s\\%s\\InstallPath' % (key, numver))
       
    20                     return res
       
    21                 except:
       
    22                     pass
       
    23     return None
     7 
    24 
     8 def OpenPDFDocIndex(index, cwd):
    25 def OpenPDFDocIndex(index, cwd):
     9     if not os.path.isfile(os.path.join(cwd, "doc","301_v04000201.pdf")):
    26     if not os.path.isfile(os.path.join(cwd, "doc","301_v04000201.pdf")):
    10         return """No documentation file available.
    27         return """No documentation file available.
    11 Please read can festival documentation to know how to obtain one."""
    28 Please read can festival documentation to know how to obtain one."""
    12     try:
    29     try:
    13         if index in DS301_PDF_INDEX:
    30         if index in DS301_PDF_INDEX:
    14             if wx.Platform == '__WXMSW__':
    31             if wx.Platform == '__WXMSW__':
    15                 os.system("Reader %s -n %d &"%(os.path.join(cwd, "doc","301_v04000201.pdf"), DS301_PDF_INDEX[index]))
    32                 readerpath = get_acroversion()
       
    33                 readerexepath = os.path.join(readerpath,"AcroRd32.exe")
       
    34                 if(os.path.isfile(readerexepath)):
       
    35                     os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", "/A", "page=%d=OpenActions" % DS301_PDF_INDEX[index], os.path.join(cwd, "doc","301_v04000201.pdf"))
    16             else:
    36             else:
    17                 os.system("xpdf -remote DS301 %s %d &"%(os.path.join(cwd, "doc","301_v04000201.pdf"), DS301_PDF_INDEX[index]))
    37                 os.system("xpdf -remote DS301 %s %d &"%(os.path.join(cwd, "doc","301_v04000201.pdf"), DS301_PDF_INDEX[index]))
    18         else:
    38         else:
    19             if wx.Platform == '__WXMSW__':
    39             if wx.Platform == '__WXMSW__':
    20                 os.system("Reader %s &"%os.path.join(cwd, "doc","301_v04000201.pdf"))
    40                 readerpath = get_acroversion()
       
    41                 readerexepath = os.path.join(readerpath,"AcroRd32.exe")
       
    42                 if(os.path.isfile(readerexepath)):
       
    43                     os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", os.path.join(cwd, "doc","301_v04000201.pdf"))
    21             else:
    44             else:
    22                 os.system("xpdf -remote DS301 %s &"%os.path.join(cwd, "doc","301_v04000201.pdf"))
    45                 os.system("xpdf -remote DS301 %s &"%os.path.join(cwd, "doc","301_v04000201.pdf"))
    23         return True
    46         return True
    24     except:
    47     except:
    25         return """Check if xpdf is correctly installed on your computer"""
    48         return """Check if xpdf is correctly installed on your computer"""