Sat, 26 Apr 2025 12:34:32 +0200
MicroPython
- Added a configuration option to disable the support for the no longer produced Pimoroni Pico Wireless Pack.
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
11090
f5f5f5803935
Updated copyright for 2025.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10791
diff
changeset
|
3 | # Copyright (c) 2022 - 2025 Detlev Offenbach <detlev@die-offenbachs.de> |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing Qt/PyQt/PySide related utility functions. |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | import contextlib |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | import os |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | import sys |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | import sysconfig |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | from PyQt6.QtCore import QT_VERSION, QDir, QLibraryInfo, QProcess |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | from eric7.EricWidgets.EricApplication import ericApp |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | from eric7.SystemUtilities import FileSystemUtilities, OSUtilities, PythonUtilities |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | try: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | from eric7.eric7config import getConfig |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | except ImportError: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | from eric7config import getConfig |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | ############################################################################### |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | ## Qt utility functions below |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | ############################################################################### |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | def qVersionTuple(): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | Module function to get the Qt version as a tuple. |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | @return Qt version as a tuple |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | @rtype tuple of int |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | return ( |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | (QT_VERSION & 0xFF0000) >> 16, |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | (QT_VERSION & 0xFF00) >> 8, |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | QT_VERSION & 0xFF, |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | ) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | def generateQtToolName(toolname): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | Module function to generate the executable name for a Qt tool like |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | designer. |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | |
10431
64157aeb0312
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10250
diff
changeset
|
49 | @param toolname base name of the tool |
64157aeb0312
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10250
diff
changeset
|
50 | @type str |
64157aeb0312
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10250
diff
changeset
|
51 | @return the Qt tool name without extension |
64157aeb0312
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10250
diff
changeset
|
52 | @rtype str |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | from eric7 import Preferences |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | return "{0}{1}{2}".format( |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | Preferences.getQt("QtToolsPrefix"), |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | toolname, |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | Preferences.getQt("QtToolsPostfix"), |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | ) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | def getQtBinariesPath(libexec=False): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | Module function to get the path of the Qt binaries. |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | @param libexec flag indicating to get the path of the executable library |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | (defaults to False) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | @type bool (optional) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | @return path of the Qt binaries |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | @rtype str |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | from eric7 import Preferences |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | binPath = "" |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | # step 1: check, if the user has configured a tools path |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | qtToolsDir = Preferences.getQt("QtToolsDir") |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | if qtToolsDir: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | if libexec: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | binPath = os.path.join(qtToolsDir, "..", "libexec") |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | if not os.path.exists(binPath): |
10249
77b4c59c76d9
QtUtilities.py
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10158
diff
changeset
|
83 | binPath = os.path.join(qtToolsDir, "libexec") |
77b4c59c76d9
QtUtilities.py
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10158
diff
changeset
|
84 | if not os.path.exists(binPath): |
77b4c59c76d9
QtUtilities.py
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10158
diff
changeset
|
85 | binPath = qtToolsDir |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | else: |
10250
09b42174e077
QtUtilities.py
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10249
diff
changeset
|
87 | binPath = os.path.join(qtToolsDir, "bin") |
09b42174e077
QtUtilities.py
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10249
diff
changeset
|
88 | if not os.path.exists(binPath): |
09b42174e077
QtUtilities.py
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10249
diff
changeset
|
89 | binPath = qtToolsDir |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | if not os.path.exists(binPath): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | binPath = "" |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | # step 2: try the qt6_applications package |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | if not binPath: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | with contextlib.suppress(ImportError): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | # if qt6-applications is not installed just go to the next step |
11148
15e30f0c76a8
Adjusted the code to the modified issue codes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11090
diff
changeset
|
97 | import qt6_applications # __IGNORE_WARNING_I-10__ |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | if libexec: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | binPath = os.path.join( |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | os.path.dirname(qt6_applications.__file__), "Qt", "libexec" |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | ) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | if not os.path.exists(binPath): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | binPath = os.path.join( |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | os.path.dirname(qt6_applications.__file__), "Qt", "bin" |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | ) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | else: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | binPath = os.path.join( |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | os.path.dirname(qt6_applications.__file__), "Qt", "bin" |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | ) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | if not os.path.exists(binPath): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | binPath = "" |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | # step3: determine via QLibraryInfo |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | if not binPath: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | binPath = ( |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | QLibraryInfo.path(QLibraryInfo.LibraryPath.LibraryExecutablesPath) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | if libexec |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | else QLibraryInfo.path(QLibraryInfo.LibraryPath.BinariesPath) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | ) |
10737
9600492ebfa7
Corrected an issue determining the path of the Qt tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10496
diff
changeset
|
121 | if not os.path.exists(binPath): |
9600492ebfa7
Corrected an issue determining the path of the Qt tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10496
diff
changeset
|
122 | binPath = "" |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | # step 4: determine from used Python interpreter (designer is test object) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | if not binPath: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | program = "designer" |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | if OSUtilities.isWindowsPlatform(): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | program += ".exe" |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | progPath = os.path.join(PythonUtilities.getPythonScriptsDirectory(), program) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | if os.path.exists(progPath): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | binPath = PythonUtilities.getPythonScriptsDirectory() |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | return QDir.toNativeSeparators(binPath) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
136 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
137 | def getQtMacBundle(toolname): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | Module function to determine the correct Mac OS X bundle name for Qt tools. |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | |
10431
64157aeb0312
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10250
diff
changeset
|
141 | @param toolname plain name of the tool (e.g. "designer") |
64157aeb0312
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10250
diff
changeset
|
142 | @type str |
64157aeb0312
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10250
diff
changeset
|
143 | @return bundle name of the Qt tool |
64157aeb0312
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10250
diff
changeset
|
144 | @rtype str |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | qtDir = getQtBinariesPath() |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | bundles = [ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | os.path.join(qtDir, "bin", generateQtToolName(toolname.capitalize())) + ".app", |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | os.path.join(qtDir, "bin", generateQtToolName(toolname)) + ".app", |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | os.path.join(qtDir, generateQtToolName(toolname.capitalize())) + ".app", |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | os.path.join(qtDir, generateQtToolName(toolname)) + ".app", |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | ] |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | if toolname == "designer": |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | # support the standalone Qt Designer installer from |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | # https://build-system.fman.io/qt-designer-download |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | designer = "Qt Designer.app" |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | bundles.extend( |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | [ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | os.path.join(qtDir, "bin", designer), |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | os.path.join(qtDir, designer), |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | ] |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | ) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | for bundle in bundles: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | if os.path.exists(bundle): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | return bundle |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | return "" |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
168 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
169 | def prepareQtMacBundle(toolname, args): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | Module function for starting Qt tools that are Mac OS X bundles. |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | @param toolname plain name of the tool (e.g. "designer") |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
174 | @type str |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | @param args name of input file for tool, if any |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | @type list of str |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | @return command-name and args for QProcess |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | @rtype tuple of (str, list of str) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | fullBundle = getQtMacBundle(toolname) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | if fullBundle == "": |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | return ("", []) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | newArgs = [] |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | newArgs.append("-a") |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | newArgs.append(fullBundle) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | if args: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | newArgs.append("--args") |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | newArgs += args |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
191 | return ("open", newArgs) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | |
10158
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
194 | def hasQtDesigner(): |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
195 | """ |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
196 | Function to check for the availabilility of Qt-Designer tool. |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
197 | |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
198 | @return flag indicating the availability of the Qt-Designer tool |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
199 | @rtype bool |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
200 | """ |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
201 | if OSUtilities.isWindowsPlatform(): |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
202 | designerExe = os.path.join( |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
203 | getQtBinariesPath(), |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
204 | "{0}.exe".format(generateQtToolName("designer")), |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
205 | ) |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
206 | elif OSUtilities.isMacPlatform(): |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
207 | designerExe = getQtMacBundle("designer") |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
208 | else: |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
209 | designerExe = os.path.join( |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
210 | getQtBinariesPath(), |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
211 | generateQtToolName("designer"), |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
212 | ) |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
213 | return os.path.exists(designerExe) |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
214 | |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
215 | |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
216 | def hasQtLinguist(): |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
217 | """ |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
218 | Function to check for the availabilility of Qt-Linguist tool. |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
219 | |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
220 | @return flag indicating the availability of the Qt-Linguist tool |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
221 | @rtype bool |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
222 | """ |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
223 | if OSUtilities.isWindowsPlatform(): |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
224 | linguistExe = os.path.join( |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
225 | getQtBinariesPath(), |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
226 | "{0}.exe".format(generateQtToolName("linguist")), |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
227 | ) |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
228 | elif OSUtilities.isMacPlatform(): |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
229 | linguistExe = getQtMacBundle("linguist") |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
230 | else: |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
231 | linguistExe = os.path.join( |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
232 | getQtBinariesPath(), |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
233 | generateQtToolName("linguist"), |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
234 | ) |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
235 | return os.path.exists(linguistExe) |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
236 | |
b5aadedf4214
Made the enabled state of the "Open in Qt-Designer" and "Open in Qt-Linguist" context menu entries dependent of the availability of these tools.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
237 | |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
238 | ############################################################################### |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
239 | ## PyQt utility functions below |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | ############################################################################### |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
241 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
242 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
243 | def getPyQt6ModulesDirectory(): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
244 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
245 | Function to determine the path to PyQt6 modules directory. |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
246 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
247 | @return path to the PyQt6 modules directory |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
248 | @rtype str |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
249 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
250 | pyqtPath = os.path.join(sysconfig.get_path("platlib"), "PyQt6") |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
251 | if os.path.exists(pyqtPath): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
252 | return pyqtPath |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
253 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
254 | return "" |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
255 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
256 | |
11217 | 257 | def getPyQtToolsPath(version=6): |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
258 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
259 | Module function to get the path of the PyQt tools. |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
260 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
261 | @param version PyQt major version |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
262 | @type int |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
263 | @return path to the PyQt tools |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
264 | @rtype str |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
265 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
266 | from eric7 import Preferences |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
267 | from eric7.EricWidgets.EricApplication import ericApp |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
268 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
269 | toolsPath = "" |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
270 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
271 | # step 1: check, if the user has configured a tools path |
11217 | 272 | if version == 6: |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
273 | toolsPath = Preferences.getQt("PyQt6ToolsDir") |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
274 | venvName = Preferences.getQt("PyQt6VenvName") |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
275 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
276 | # step 2: determine from used Python interpreter (pylupdate is test object) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
277 | if not toolsPath: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
278 | program = "pylupdate{0}".format(version) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
279 | if venvName: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
280 | venvManager = ericApp().getObject("VirtualEnvManager") |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
281 | dirName = venvManager.getVirtualenvDirectory(venvName) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
282 | else: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
283 | dirName = os.path.dirname(sys.executable) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
284 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
285 | if OSUtilities.isWindowsPlatform(): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
286 | program += ".exe" |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
287 | if os.path.exists(os.path.join(dirName, program)): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
288 | toolsPath = dirName |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
289 | elif os.path.exists(os.path.join(dirName, "Scripts", program)): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
290 | toolsPath = os.path.join(dirName, "Scripts") |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
291 | else: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
292 | if os.path.exists(os.path.join(dirName, program)): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
293 | toolsPath = dirName |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
294 | elif os.path.exists(os.path.join(dirName, "bin", program)): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
295 | toolsPath = os.path.join(dirName, "bin") |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
296 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
297 | return toolsPath |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
298 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
299 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
300 | def generatePyQtToolPath(toolname, alternatives=None): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
301 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
302 | Module function to generate the executable path for a PyQt tool. |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
303 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
304 | @param toolname base name of the tool |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
305 | @type str |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
306 | @param alternatives list of alternative tool names to try |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
307 | @type list of str |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
308 | @return executable path name of the tool |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
309 | @rtype str |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
310 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
311 | pyqtVariant = int(toolname[-1]) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
312 | pyqtToolsPath = getPyQtToolsPath(pyqtVariant) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
313 | if pyqtToolsPath: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
314 | exe = os.path.join(pyqtToolsPath, toolname) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
315 | if OSUtilities.isWindowsPlatform(): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
316 | exe += ".exe" |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
317 | else: |
10791
ca9ece290f71
Changed some code to use 'shutil.which()'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10737
diff
changeset
|
318 | exe = toolname |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
319 | |
10791
ca9ece290f71
Changed some code to use 'shutil.which()'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10737
diff
changeset
|
320 | exePath = FileSystemUtilities.getExecutablePath(exe) |
ca9ece290f71
Changed some code to use 'shutil.which()'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10737
diff
changeset
|
321 | if not exePath and alternatives: |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
322 | ex_ = generatePyQtToolPath(alternatives[0], alternatives[1:]) |
10791
ca9ece290f71
Changed some code to use 'shutil.which()'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10737
diff
changeset
|
323 | exePath = FileSystemUtilities.getExecutablePath(ex_) |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
324 | |
10791
ca9ece290f71
Changed some code to use 'shutil.which()'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10737
diff
changeset
|
325 | return exePath |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
326 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
327 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
328 | ############################################################################### |
11216 | 329 | ## PySide utility functions below |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
330 | ############################################################################### |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
331 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
332 | |
11216 | 333 | def generatePySideToolPath(toolname, variant=6): |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
334 | """ |
11216 | 335 | Module function to generate the executable path for a PySide tool. |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
336 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
337 | @param toolname base name of the tool |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
338 | @type str |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
339 | @param variant indicator for the PySide variant |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
340 | @type int or str |
11216 | 341 | @return the PySide tool path with extension |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
342 | @rtype str |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
343 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
344 | from eric7 import Preferences |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
345 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
346 | if OSUtilities.isWindowsPlatform(): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
347 | hasPyside = checkPyside(variant) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
348 | if not hasPyside: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
349 | return "" |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
350 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
351 | venvName = Preferences.getQt("PySide{0}VenvName".format(variant)) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
352 | if not venvName: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
353 | venvName = Preferences.getDebugger("Python3VirtualEnv") |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
354 | interpreter = ( |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
355 | ericApp().getObject("VirtualEnvManager").getVirtualenvInterpreter(venvName) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
356 | ) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
357 | if interpreter == "" or not FileSystemUtilities.isinpath(interpreter): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
358 | interpreter = PythonUtilities.getPythonExecutable() |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
359 | prefix = os.path.dirname(interpreter) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
360 | if not prefix.endswith("Scripts"): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
361 | prefix = os.path.join(prefix, "Scripts") |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
362 | return os.path.join(prefix, toolname + ".exe") |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
363 | else: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
364 | # step 1: check, if the user has configured a tools path |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
365 | path = Preferences.getQt("PySide{0}ToolsDir".format(variant)) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
366 | if path: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
367 | return os.path.join(path, toolname) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
368 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
369 | # step 2: determine from used Python interpreter |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
370 | dirName = os.path.dirname(sys.executable) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
371 | if os.path.exists(os.path.join(dirName, toolname)): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
372 | return os.path.join(dirName, toolname) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
373 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
374 | return toolname |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
375 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
376 | |
11216 | 377 | def checkPyside(variant=6): |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
378 | """ |
11216 | 379 | Module function to check the presence of PySide. |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
380 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
381 | @param variant indicator for the PySide variant |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
382 | @type int or str |
11216 | 383 | @return flags indicating the presence of PySide |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
384 | @rtype bool |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
385 | """ |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
386 | from eric7 import Preferences |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
387 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
388 | venvName = Preferences.getQt("PySide{0}VenvName".format(variant)) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
389 | if not venvName: |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
390 | venvName = Preferences.getDebugger("Python3VirtualEnv") |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
391 | interpreter = ( |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
392 | ericApp().getObject("VirtualEnvManager").getVirtualenvInterpreter(venvName) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
393 | ) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
394 | if interpreter == "" or not FileSystemUtilities.isinpath(interpreter): |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
395 | interpreter = PythonUtilities.getPythonExecutable() |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
396 | |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
397 | checker = os.path.join(getConfig("ericDir"), "SystemUtilities", "PySideImporter.py") |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
398 | args = [checker, "--variant={0}".format(variant)] |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
399 | proc = QProcess() |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
400 | proc.setProcessChannelMode(QProcess.ProcessChannelMode.MergedChannels) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
401 | proc.start(interpreter, args) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
402 | finished = proc.waitForFinished(30000) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
403 | return finished and proc.exitCode() == 0 |