author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Tue, 06 Jun 2017 13:13:57 +0300 | |
changeset 1691 | 9a42f12a973e |
parent 1572 | 078c760620d7 |
child 1732 | 94ffe74e6895 |
permissions | -rw-r--r-- |
814 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
814
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
814
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
814 | 6 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
814
diff
changeset
|
7 |
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
814 | 8 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
814
diff
changeset
|
9 |
# See COPYING file for copyrights details. |
814 | 10 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
814
diff
changeset
|
11 |
# This program is free software; you can redistribute it and/or |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
814
diff
changeset
|
12 |
# modify it under the terms of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
814
diff
changeset
|
13 |
# as published by the Free Software Foundation; either version 2 |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
814
diff
changeset
|
14 |
# of the License, or (at your option) any later version. |
814 | 15 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
814
diff
changeset
|
16 |
# This program is distributed in the hope that it will be useful, |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
814
diff
changeset
|
17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
814
diff
changeset
|
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
814
diff
changeset
|
19 |
# GNU General Public License for more details. |
814 | 20 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
814
diff
changeset
|
21 |
# You should have received a copy of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
814
diff
changeset
|
22 |
# along with this program; if not, write to the Free Software |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
814
diff
changeset
|
23 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
814 | 24 |
|
25 |
import wx, os |
|
26 |
||
27 |
readerexepath = None |
|
28 |
||
29 |
def get_acroversion(): |
|
30 |
" Return version of Adobe Acrobat executable or None" |
|
31 |
import _winreg |
|
32 |
adobesoft = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r'Software\Adobe') |
|
33 |
for index in range(_winreg.QueryInfoKey(adobesoft)[0]): |
|
34 |
key = _winreg.EnumKey(adobesoft, index) |
|
35 |
if "acrobat" in key.lower(): |
|
36 |
acrokey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Adobe\\%s' % key) |
|
37 |
for index in range(_winreg.QueryInfoKey(acrokey)[0]): |
|
38 |
numver = _winreg.EnumKey(acrokey, index) |
|
39 |
try: |
|
40 |
res = _winreg.QueryValue(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Adobe\\%s\\%s\\InstallPath' % (key, numver)) |
|
41 |
return res |
|
42 |
except: |
|
43 |
pass |
|
44 |
return None |
|
45 |
||
46 |
def open_win_pdf(readerexepath, pdffile, pagenum = None): |
|
47 |
if pagenum != None : |
|
48 |
os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", "/A", "page=%d=OpenActions" % pagenum, '"%s"'%pdffile) |
|
49 |
else: |
|
50 |
os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", '"%s"'%pdffile) |
|
51 |
||
52 |
def open_lin_pdf(readerexepath, pdffile, pagenum = None): |
|
53 |
if pagenum == None : |
|
54 |
os.system("%s -remote DS301 %s &"%(readerexepath, pdffile)) |
|
55 |
else: |
|
1572
078c760620d7
fix inconsistent whitespace
ctbenergy <ewald.weinahndl@gmail.com>
parents:
1571
diff
changeset
|
56 |
print "Open pdf %s at page %d"%(pdffile, pagenum) |
814 | 57 |
os.system("%s -remote DS301 %s %d &"%(readerexepath, pdffile, pagenum)) |
58 |
||
59 |
def open_pdf(pdffile, pagenum = None): |
|
60 |
if wx.Platform == '__WXMSW__' : |
|
61 |
try: |
|
62 |
readerpath = get_acroversion() |
|
63 |
except: |
|
64 |
wx.MessageBox("Acrobat Reader is not found or installed !") |
|
65 |
return None |
|
66 |
||
67 |
readerexepath = os.path.join(readerpath, "AcroRd32.exe") |
|
68 |
if(os.path.isfile(readerexepath)): |
|
69 |
open_win_pdf(readerexepath, pdffile, pagenum) |
|
70 |
else: |
|
71 |
return None |
|
72 |
else: |
|
73 |
readerexepath = os.path.join("/usr/bin","xpdf") |
|
74 |
if(os.path.isfile(readerexepath)): |
|
75 |
open_lin_pdf(readerexepath, pdffile, pagenum) |
|
76 |
else: |
|
77 |
wx.MessageBox("xpdf is not found or installed !") |
|
78 |
return None |