author | greg |
Wed, 07 May 2008 16:59:50 +0200 | |
changeset 461 | 51cf26e3f352 |
parent 408 | f85552acc2bf |
child 569 | ecaac955c16a |
permissions | -rw-r--r-- |
0 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
341 | 4 |
import os,wx |
0 | 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} |
|
7 |
||
386
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
8 |
def get_acroversion(): |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
9 |
" Return version of Adobe Acrobat executable or None" |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
10 |
import _winreg |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
11 |
adobesoft = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r'Software\Adobe') |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
12 |
for index in range(_winreg.QueryInfoKey(adobesoft)[0]): |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
13 |
key = _winreg.EnumKey(adobesoft, index) |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
14 |
if "acrobat" in key.lower(): |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
15 |
acrokey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Adobe\\%s' % key) |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
16 |
for index in range(_winreg.QueryInfoKey(acrokey)[0]): |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
17 |
numver = _winreg.EnumKey(acrokey, index) |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
18 |
try: |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
19 |
res = _winreg.QueryValue(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Adobe\\%s\\%s\\InstallPath' % (key, numver)) |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
20 |
return res |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
21 |
except: |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
22 |
pass |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
23 |
return None |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
24 |
|
147 | 25 |
def OpenPDFDocIndex(index, cwd): |
341 | 26 |
if not os.path.isfile(os.path.join(cwd, "doc","301_v04000201.pdf")): |
0 | 27 |
return """No documentation file available. |
28 |
Please read can festival documentation to know how to obtain one.""" |
|
29 |
try: |
|
72
68524f7c58b5
Code for avoiding possible problem on Window while importing html module
lbessard
parents:
0
diff
changeset
|
30 |
if index in DS301_PDF_INDEX: |
341 | 31 |
if wx.Platform == '__WXMSW__': |
386
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
32 |
readerpath = get_acroversion() |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
33 |
readerexepath = os.path.join(readerpath,"AcroRd32.exe") |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
34 |
if(os.path.isfile(readerexepath)): |
408
f85552acc2bf
fixed bug to open pdf with acrobat reader on Win32 in objdictedit and networkedit
greg
parents:
386
diff
changeset
|
35 |
os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", "/A", "page=%d=OpenActions" % DS301_PDF_INDEX[index], '"%s"'%os.path.join(cwd, "doc","301_v04000201.pdf")) |
341 | 36 |
else: |
37 |
os.system("xpdf -remote DS301 %s %d &"%(os.path.join(cwd, "doc","301_v04000201.pdf"), DS301_PDF_INDEX[index])) |
|
72
68524f7c58b5
Code for avoiding possible problem on Window while importing html module
lbessard
parents:
0
diff
changeset
|
38 |
else: |
341 | 39 |
if wx.Platform == '__WXMSW__': |
386
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
40 |
readerpath = get_acroversion() |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
41 |
readerexepath = os.path.join(readerpath,"AcroRd32.exe") |
0f56a144ba5f
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents:
341
diff
changeset
|
42 |
if(os.path.isfile(readerexepath)): |
408
f85552acc2bf
fixed bug to open pdf with acrobat reader on Win32 in objdictedit and networkedit
greg
parents:
386
diff
changeset
|
43 |
os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", '"%s"'%os.path.join(cwd, "doc","301_v04000201.pdf")) |
341 | 44 |
else: |
45 |
os.system("xpdf -remote DS301 %s &"%os.path.join(cwd, "doc","301_v04000201.pdf")) |
|
0 | 46 |
return True |
47 |
except: |
|
48 |
return """Check if xpdf is correctly installed on your computer""" |
|
49 |