author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Mon, 14 Aug 2017 21:31:01 +0300 | |
changeset 1733 | dea107dce0c4 |
parent 1732 | 94ffe74e6895 |
child 1734 | 750eeb7230a1 |
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 |
|
1732
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1572
diff
changeset
|
25 |
import os |
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1572
diff
changeset
|
26 |
import wx |
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1572
diff
changeset
|
27 |
|
814 | 28 |
|
29 |
readerexepath = None |
|
30 |
||
31 |
def get_acroversion(): |
|
32 |
" Return version of Adobe Acrobat executable or None" |
|
33 |
import _winreg |
|
34 |
adobesoft = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r'Software\Adobe') |
|
35 |
for index in range(_winreg.QueryInfoKey(adobesoft)[0]): |
|
36 |
key = _winreg.EnumKey(adobesoft, index) |
|
37 |
if "acrobat" in key.lower(): |
|
38 |
acrokey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Adobe\\%s' % key) |
|
39 |
for index in range(_winreg.QueryInfoKey(acrokey)[0]): |
|
40 |
numver = _winreg.EnumKey(acrokey, index) |
|
41 |
try: |
|
42 |
res = _winreg.QueryValue(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Adobe\\%s\\%s\\InstallPath' % (key, numver)) |
|
43 |
return res |
|
44 |
except: |
|
45 |
pass |
|
46 |
return None |
|
47 |
||
48 |
def open_win_pdf(readerexepath, pdffile, pagenum = None): |
|
49 |
if pagenum != None : |
|
50 |
os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", "/A", "page=%d=OpenActions" % pagenum, '"%s"'%pdffile) |
|
51 |
else: |
|
52 |
os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", '"%s"'%pdffile) |
|
53 |
||
54 |
def open_lin_pdf(readerexepath, pdffile, pagenum = None): |
|
55 |
if pagenum == None : |
|
56 |
os.system("%s -remote DS301 %s &"%(readerexepath, pdffile)) |
|
57 |
else: |
|
1572
078c760620d7
fix inconsistent whitespace
ctbenergy <ewald.weinahndl@gmail.com>
parents:
1571
diff
changeset
|
58 |
print "Open pdf %s at page %d"%(pdffile, pagenum) |
814 | 59 |
os.system("%s -remote DS301 %s %d &"%(readerexepath, pdffile, pagenum)) |
60 |
||
61 |
def open_pdf(pdffile, pagenum = None): |
|
62 |
if wx.Platform == '__WXMSW__' : |
|
63 |
try: |
|
64 |
readerpath = get_acroversion() |
|
65 |
except: |
|
66 |
wx.MessageBox("Acrobat Reader is not found or installed !") |
|
67 |
return None |
|
68 |
||
69 |
readerexepath = os.path.join(readerpath, "AcroRd32.exe") |
|
70 |
if(os.path.isfile(readerexepath)): |
|
71 |
open_win_pdf(readerexepath, pdffile, pagenum) |
|
72 |
else: |
|
73 |
return None |
|
74 |
else: |
|
75 |
readerexepath = os.path.join("/usr/bin","xpdf") |
|
76 |
if(os.path.isfile(readerexepath)): |
|
77 |
open_lin_pdf(readerexepath, pdffile, pagenum) |
|
78 |
else: |
|
79 |
wx.MessageBox("xpdf is not found or installed !") |
|
80 |
return None |