eric7/Globals/__init__.py

Fri, 01 Jul 2022 11:02:32 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 01 Jul 2022 11:02:32 +0200
branch
eric7-maintenance
changeset 9192
a763d57e23bc
parent 9111
4ac66b6c33a4
parent 9154
e8ca7b41a7d8
permissions
-rw-r--r--

Merged with branch "eric7" to prepare a new release.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
8881
54e42bc2437a Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8549
diff changeset
3 # Copyright (c) 2006 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module defining common data to be used by all modules.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
4343
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4241
diff changeset
10 #
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4241
diff changeset
11 # Note: Do not import any eric stuff in here!!!!!!!
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4241
diff changeset
12 #
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4241
diff changeset
13
8501
7b5f10581c35 Removed the support for the deprecated distutils package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8468
diff changeset
14 import contextlib
1162
ab292b7f4f8a Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
15 import os
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
16 import re
8501
7b5f10581c35 Removed the support for the deprecated distutils package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8468
diff changeset
17 import sys
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8314
diff changeset
19 from PyQt6.QtCore import (
7742
38ad1351688c Globals: removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7741
diff changeset
20 QDir, QByteArray, QCoreApplication, QT_VERSION, QProcess, qVersion
7253
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
21 )
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
22
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
23 from eric7config import getConfig
7804
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
24
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 # names of the various settings objects
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8314
diff changeset
26 settingsNameOrganization = "Eric7"
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
27 settingsNameGlobal = "eric7"
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
28 settingsNameRecent = "eric7recent"
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 # key names of the various recent entries
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 recentNameMultiProject = "MultiProjects"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 recentNameProject = "Projects"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 recentNameFiles = "Files"
4695
9dc08852de25 Added a 'Recent Files' menu to the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4686
diff changeset
34 recentNameHexFiles = "HexFiles"
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8314
diff changeset
35 recentNameHosts = "Hosts"
6034
4f88f70d2cd4 Added the capability to remember the most recently used file names and conditions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5859
diff changeset
36 recentNameBreakpointFiles = "BreakPointFiles"
4f88f70d2cd4 Added the capability to remember the most recently used file names and conditions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5859
diff changeset
37 recentNameBreakpointConditions = "BreakPointConditions"
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
38 recentNameTestDiscoverHistory = "UTDiscoverHistory"
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
39 recentNameTestFileHistory = "UTFileHistory"
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
40 recentNameTestNameHistory = "UTTestnameHistory"
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
41 recentNameTestFramework = "UTTestFramework"
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
42 recentNameTestEnvironment = "UTEnvironmentName"
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
44 configDir = None
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
45
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
46
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 def isWindowsPlatform():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 Function to check, if this is a Windows platform.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
51 @return flag indicating Windows platform
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
52 @rtype bool
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 """
6289
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
54 return sys.platform.startswith(("win", "cygwin"))
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
55
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
56
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
57 def isMacPlatform():
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
58 """
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
59 Function to check, if this is a Mac platform.
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
60
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
61 @return flag indicating Mac platform
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
62 @rtype bool
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
63 """
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
64 return sys.platform == "darwin"
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
65
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
66
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
67 def isLinuxPlatform():
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
68 """
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
69 Function to check, if this is a Linux platform.
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
70
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
71 @return flag indicating Linux platform
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
72 @rtype bool
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
73 """
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
74 return sys.platform.startswith("linux")
1162
ab292b7f4f8a Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
75
ab292b7f4f8a Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
76
6289
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
77 def desktopName():
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
78 """
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
79 Function to determine the name of the desktop environment used
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
80 (Linux only).
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
81
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
82 @return name of the desktop environment
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
83 @rtype str
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
84 """
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
85 if not isLinuxPlatform():
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
86 return ""
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
87
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
88 currDesktop = os.environ.get("XDG_CURRENT_DESKTOP", "")
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
89 if currDesktop:
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
90 return currDesktop
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
91
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
92 currDesktop = os.environ.get("XDG_SESSION_DESKTOP", "")
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
93 if currDesktop:
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
94 return currDesktop
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
95
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
96 currDesktop = os.environ.get("GDMSESSION", "")
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
97 if currDesktop:
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
98 return currDesktop
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
99
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
100 currDesktop = os.environ.get("GNOME_DESKTOP_SESSION_ID", "")
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
101 if currDesktop:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
102 return currDesktop
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
103
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
104 currDesktop = os.environ.get("KDE_FULL_SESSION", "")
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
105 if currDesktop:
8958
ba80dceeb560 Extended the version information to include the desktop and session type (although these are not versions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
106 if currDesktop == "true":
ba80dceeb560 Extended the version information to include the desktop and session type (although these are not versions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
107 return "KDE"
ba80dceeb560 Extended the version information to include the desktop and session type (although these are not versions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8881
diff changeset
108
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
109 return currDesktop
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
110
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
111 currDesktop = os.environ.get("DESKTOP_SESSION", "")
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
112 if currDesktop:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
113 return currDesktop
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
114
6289
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
115 return ""
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
116
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
117
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
118 def isKdeDesktop():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
119 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
120 Function to check, if the current session is a KDE desktop (Linux only).
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
121
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
122 @return flag indicating a KDE desktop
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
123 @rtype bool
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
124 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
125 if not isLinuxPlatform():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
126 return False
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
127
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
128 isKDE = False
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
129
7253
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
130 desktop = (
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
131 os.environ.get("XDG_CURRENT_DESKTOP", "").lower() or
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
132 os.environ.get("XDG_SESSION_DESKTOP", "").lower() or
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
133 os.environ.get("DESKTOP_SESSION", "").lower()
7253
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
134 )
8257
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
135 isKDE = (
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
136 "kde" in desktop or "plasma" in desktop
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
137 if desktop else
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
138 bool(os.environ.get("KDE_FULL_SESSION", ""))
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
139 )
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
140
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
141 return isKDE
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
142
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
143
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
144 def isGnomeDesktop():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
145 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
146 Function to check, if the current session is a Gnome desktop (Linux only).
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
147
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
148 @return flag indicating a Gnome desktop
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
149 @rtype bool
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
150 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
151 if not isLinuxPlatform():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
152 return False
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
153
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
154 isGnome = False
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
155
7253
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
156 desktop = (
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
157 os.environ.get("XDG_CURRENT_DESKTOP", "").lower() or
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
158 os.environ.get("XDG_SESSION_DESKTOP", "").lower() or
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
159 os.environ.get("GDMSESSION", "").lower()
7253
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
160 )
8257
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
161 isGnome = (
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
162 "gnome" in desktop
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
163 if desktop else
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
164 bool(os.environ.get("GNOME_DESKTOP_SESSION_ID", ""))
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
165 )
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
166
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
167 return isGnome
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
168
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
169
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
170 def sessionType():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
171 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
172 Function to determine the name of the running session (Linux only).
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
173
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
174 @return name of the desktop environment
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
175 @rtype str
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
176 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
177 if not isLinuxPlatform():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
178 return ""
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
179
8126
e7278bf7168f Globals: fixed an issue causing an exception when some environment variables are not defined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
180 sessionType = os.environ.get("XDG_SESSION_TYPE", "").lower()
6914
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
181 if "x11" in sessionType:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
182 return "X11"
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
183 elif "wayland" in sessionType:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
184 return "Wayland"
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
185
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
186 sessionType = os.environ.get("WAYLAND_DISPLAY", "").lower()
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
187 if "wayland" in sessionType:
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
188 return "Wayland"
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
189
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
190 return ""
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
191
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
192
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
193 def isWaylandSession():
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
194 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
195 Function to check, if the current session is a wayland session.
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
196
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
197 @return flag indicating a wayland session
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
198 @rtype bool
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
199 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
200 return sessionType() == "Wayland"
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
201
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
202
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
203 def getConfigDir():
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
204 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
205 Module function to get the name of the directory storing the config data.
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
206
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
207 @return directory name of the config dir
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
208 @rtype str
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
209 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
210 if configDir is not None and os.path.exists(configDir):
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
211 hp = configDir
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
212 else:
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
213 cdn = ".eric7"
5823
70dfe6a4aa03 Fixed an issue getting the home directory during uninstallation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
214 hp = os.path.join(os.path.expanduser("~"), cdn)
70dfe6a4aa03 Fixed an issue getting the home directory during uninstallation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
215 if not os.path.exists(hp):
70dfe6a4aa03 Fixed an issue getting the home directory during uninstallation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
216 os.mkdir(hp)
70dfe6a4aa03 Fixed an issue getting the home directory during uninstallation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
217 return hp
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
218
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
219
7804
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
220 def getInstallInfoFilePath():
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
221 """
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
222 Public method to get the path name of the install info file.
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
223
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
224 @return file path of the install info file
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
225 @rtype str
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
226 """
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
227 filename = "eric7install.{0}.json".format(
7804
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
228 getConfig("ericDir")
7805
3cad282e8409 Globals: fixed an issue calculating the install info file path on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7804
diff changeset
229 .replace(":", "_")
7804
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
230 .replace("\\", "_")
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
231 .replace("/", "_")
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
232 .replace(" ", "_")
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
233 .strip("_")
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
234 )
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
235 return os.path.join(getConfigDir(), filename)
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
236
1cbc27e34ec6 Implementing code to record and/or guess some information about the installation process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
237
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
238 def setConfigDir(d):
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
239 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
240 Module function to set the name of the directory storing the config data.
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
241
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
242 @param d name of an existing directory
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
243 @type str
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
244 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
245 global configDir
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
246 configDir = os.path.expanduser(d)
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
247
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
248
9016
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
249 def getPythonExecutable():
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
250 """
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
251 Function to determine the path of the (non-windowed) Python executable.
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
252
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
253 @return path of the Python executable
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
254 @rtype str
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
255 """
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
256 if sys.platform.startswith("linux"):
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
257 return sys.executable
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
258 elif sys.platform == "darwin":
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
259 return sys.executable.replace("pythonw", "python")
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
260 else:
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
261 return sys.executable.replace("pythonw.exe", "python.exe")
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
262
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
263
8306
2bfd53096b5f Renamed Globals.getPythonModulesDirectory() to Globals.getPythonLibraryDirectory() because that name is clearer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
264 def getPythonLibraryDirectory():
2608
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
265 """
8306
2bfd53096b5f Renamed Globals.getPythonModulesDirectory() to Globals.getPythonLibraryDirectory() because that name is clearer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
266 Function to determine the path to Python's library directory.
2608
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
267
8306
2bfd53096b5f Renamed Globals.getPythonModulesDirectory() to Globals.getPythonLibraryDirectory() because that name is clearer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
268 @return path to the Python library directory
2bfd53096b5f Renamed Globals.getPythonModulesDirectory() to Globals.getPythonLibraryDirectory() because that name is clearer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
269 @rtype str
2608
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
270 """
8501
7b5f10581c35 Removed the support for the deprecated distutils package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8468
diff changeset
271 import sysconfig
7b5f10581c35 Removed the support for the deprecated distutils package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8468
diff changeset
272 return sysconfig.get_path('platlib')
2614
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
273
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
274
8459
0ae07748dbe8 Changed quite a few PyQt5 references to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8346
diff changeset
275 def getPyQt6ModulesDirectory():
2614
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
276 """
8459
0ae07748dbe8 Changed quite a few PyQt5 references to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8346
diff changeset
277 Function to determine the path to PyQt6 modules directory.
2614
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
278
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
279 @return path to the PyQt6 modules directory
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
280 @rtype str
2614
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
281 """
8501
7b5f10581c35 Removed the support for the deprecated distutils package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8468
diff changeset
282 import sysconfig
7198
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7196
diff changeset
283
8501
7b5f10581c35 Removed the support for the deprecated distutils package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8468
diff changeset
284 pyqtPath = os.path.join(sysconfig.get_path('platlib'), "PyQt6")
7198
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7196
diff changeset
285 if os.path.exists(pyqtPath):
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7196
diff changeset
286 return pyqtPath
3807
91fc2089c401 Added some more PyQt4 compatibility code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
287
91fc2089c401 Added some more PyQt4 compatibility code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
288 return ""
2608
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
289
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
290
5696
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
291 def getPyQtToolsPath(version=5):
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
292 """
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
293 Module function to get the path of the PyQt tools.
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
294
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
295 @param version PyQt major version
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
296 @type int
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
297 @return path to the PyQt tools
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
298 @rtype str
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
299 """
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
300 import Preferences
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
301
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
302 toolsPath = ""
5696
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
303
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
304 # step 1: check, if the user has configured a tools path
7907
7991ea245c20 Added support for PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7861
diff changeset
305 if version == 5:
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
306 toolsPath = Preferences.getQt("PyQtToolsDir")
7907
7991ea245c20 Added support for PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7861
diff changeset
307 elif version == 6:
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
308 toolsPath = Preferences.getQt("PyQt6ToolsDir")
5696
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
309
7907
7991ea245c20 Added support for PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7861
diff changeset
310 # step 2: determine from used Python interpreter (pylupdate is test object)
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
311 if not toolsPath:
7907
7991ea245c20 Added support for PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7861
diff changeset
312 program = "pylupdate{0}".format(version)
5696
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
313 if isWindowsPlatform():
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
314 program += ".exe"
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
315 dirName = os.path.dirname(sys.executable)
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
316 if os.path.exists(os.path.join(dirName, program)):
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
317 toolsPath = dirName
5696
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
318 elif os.path.exists(os.path.join(dirName, "Scripts", program)):
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
319 toolsPath = os.path.join(dirName, "Scripts")
5696
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
320 else:
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
321 dirName = os.path.dirname(sys.executable)
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
322 if os.path.exists(os.path.join(dirName, program)):
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
323 toolsPath = dirName
5696
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
324
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
325 return toolsPath
5696
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
326
68af0e9c57ad Started implementing the capability to configure the path to the PyQt tools or determine it based on the current Python interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5401
diff changeset
327
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
328 def getQtBinariesPath(libexec=False):
2615
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
329 """
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
330 Module function to get the path of the Qt binaries.
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
331
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
332 @param libexec flag indicating to get the path of the executable library
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
333 (defaults to False)
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
334 @type bool (optional)
7741
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
335 @return path of the Qt binaries
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
336 @rtype str
2615
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
337 """
5070
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4828
diff changeset
338 import Preferences
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4828
diff changeset
339
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
340 binPath = ""
5070
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4828
diff changeset
341
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4828
diff changeset
342 # step 1: check, if the user has configured a tools path
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
343 qtToolsDir = Preferences.getQt("QtToolsDir")
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
344 if qtToolsDir:
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
345 if libexec:
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
346 binPath = os.path.join(qtToolsDir, "..", "libexec")
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
347 if not os.path.exists(binPath):
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
348 binPath = qtToolsDir
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
349 else:
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
350 binPath = Preferences.getQt("QtToolsDir")
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
351 if not os.path.exists(binPath):
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
352 binPath = ""
5070
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4828
diff changeset
353
8327
666c2b81cbb7 Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
354 # step 2: try the qt6_applications package
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
355 if not binPath:
8243
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8240
diff changeset
356 with contextlib.suppress(ImportError):
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
357 # if qt6-applications is not installed just go to the next step
8327
666c2b81cbb7 Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
358 import qt6_applications
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
359 if libexec:
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
360 binPath = os.path.join(
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
361 os.path.dirname(qt6_applications.__file__),
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
362 "Qt", "libexec")
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
363 if not os.path.exists(binPath):
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
364 binPath = os.path.join(
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
365 os.path.dirname(qt6_applications.__file__),
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
366 "Qt", "bin")
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
367 else:
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
368 binPath = os.path.join(
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
369 os.path.dirname(qt6_applications.__file__),
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
370 "Qt", "bin")
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
371 if not os.path.exists(binPath):
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
372 binPath = ""
7835
0835ed67714b Changed code slightly to work with the upcoming qt5-applications package done by Kyle Altendorf.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7805
diff changeset
373
0835ed67714b Changed code slightly to work with the upcoming qt5-applications package done by Kyle Altendorf.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7805
diff changeset
374 # step 3: determine from used Python interpreter (designer is test object)
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
375 if not binPath:
7741
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
376 program = "designer"
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
377 if isWindowsPlatform():
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
378 program += ".exe"
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
379 dirName = os.path.dirname(sys.executable)
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
380 if os.path.exists(os.path.join(dirName, program)):
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
381 binPath = dirName
7741
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
382 elif os.path.exists(os.path.join(dirName, "Scripts", program)):
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
383 binPath = os.path.join(dirName, "Scripts")
7741
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
384 else:
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
385 dirName = os.path.dirname(sys.executable)
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
386 if os.path.exists(os.path.join(dirName, program)):
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
387 binPath = dirName
2615
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
388
9154
e8ca7b41a7d8 Changed the path to search for for the "qhelpgenerator" tool because that was moved to the 'libexec' directory on Linux and maxOS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
389 return QDir.toNativeSeparators(binPath)
2615
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
390
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
391
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
392 ###############################################################################
5848
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
393 ## functions for version handling
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
394 ###############################################################################
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
395
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
396
7641
21ea4fd50b0a PipPackagesWidget: made the cache actions dependent on pip version of selected environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
397 def versionToTuple(version, length=3):
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
398 """
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
399 Module function to convert a version string into a tuple.
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
400
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
401 Note: A version string consists of non-negative decimals separated by "."
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
402 optionally followed by a suffix. Suffix is everything after the last
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
403 decimal.
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
404
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
405 @param version version string
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
406 @type str
7641
21ea4fd50b0a PipPackagesWidget: made the cache actions dependent on pip version of selected environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
407 @param length desired length of the version tuple
21ea4fd50b0a PipPackagesWidget: made the cache actions dependent on pip version of selected environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
408 @type int
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
409 @return version tuple without the suffix
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
410 @rtype tuple of int
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
411 """
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
412 versionParts = []
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
413
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
414 # step 1: extract suffix
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
415 version = re.split(r"[^\d.]", version)[0]
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
416 for part in version.split("."):
8240
93b8a353c4bf Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8126
diff changeset
417 with contextlib.suppress(ValueError):
7673
f0309b9483b1 Globals: added some error checking to 'versionToTuple'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7641
diff changeset
418 versionParts.append(int(part.strip()))
7641
21ea4fd50b0a PipPackagesWidget: made the cache actions dependent on pip version of selected environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
419 versionParts.extend([0] * length)
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
420
7641
21ea4fd50b0a PipPackagesWidget: made the cache actions dependent on pip version of selected environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
421 return tuple(versionParts[:length])
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
422
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
423
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
424 def qVersionTuple():
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
425 """
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
426 Module function to get the Qt version as a tuple.
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
427
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
428 @return Qt version as a tuple
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
429 @rtype tuple of int
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
430 """
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
431 return (
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
432 (QT_VERSION & 0xff0000) >> 16,
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
433 (QT_VERSION & 0xff00) >> 8,
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
434 QT_VERSION & 0xff,
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
435 )
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
436
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
437
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
438 ###############################################################################
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
439 ## functions for extended string handling
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
440 ###############################################################################
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
441
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
442
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
443 def strGroup(txt, sep, groupLen=4):
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
444 """
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
445 Module function to group a string into sub-strings separated by a
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
446 separator.
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
447
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
448 @param txt text to be grouped
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
449 @type str
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
450 @param sep separator string
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
451 @type str
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
452 @param groupLen length of each group
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
453 @type int
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
454 @return result string
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
455 @rtype str
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
456 """
4724
682f009d086d Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4695
diff changeset
457 groups = []
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
458
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
459 while len(txt) // groupLen != 0:
4724
682f009d086d Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4695
diff changeset
460 groups.insert(0, txt[-groupLen:])
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
461 txt = txt[:-groupLen]
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
462 if len(txt) > 0:
4724
682f009d086d Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4695
diff changeset
463 groups.insert(0, txt)
682f009d086d Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4695
diff changeset
464 return sep.join(groups)
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
465
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
466
5848
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
467 def strToQByteArray(txt):
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
468 """
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
469 Module function to convert a Python string into a QByteArray.
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
470
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
471 @param txt Python string to be converted
7639
422fd05e9c91 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
472 @type str, bytes, bytearray
5859
28282fa0df7b Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5848
diff changeset
473 @return converted QByteArray
28282fa0df7b Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5848
diff changeset
474 @rtype QByteArray
5848
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
475 """
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7085
diff changeset
476 if isinstance(txt, str):
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7085
diff changeset
477 txt = txt.encode("utf-8")
5848
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
478
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
479 return QByteArray(txt)
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
480
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
481
6682
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
482 def dataString(size):
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
483 """
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
484 Module function to generate a formatted size string.
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
485
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
486 @param size size to be formatted
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
487 @type int
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
488 @return formatted data string
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
489 @rtype str
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
490 """
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
491 if size < 1024:
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
492 return QCoreApplication.translate(
7085
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
493 "Globals", "{0:4.2f} Bytes").format(size)
6682
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
494 elif size < 1024 * 1024:
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
495 size /= 1024
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
496 return QCoreApplication.translate(
7085
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
497 "Globals", "{0:4.2f} KiB").format(size)
6682
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
498 elif size < 1024 * 1024 * 1024:
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
499 size /= 1024 * 1024
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
500 return QCoreApplication.translate(
7085
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
501 "Globals", "{0:4.2f} MiB").format(size)
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
502 elif size < 1024 * 1024 * 1024 * 1024:
6682
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
503 size /= 1024 * 1024 * 1024
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
504 return QCoreApplication.translate(
7085
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
505 "Globals", "{0:4.2f} GiB").format(size)
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
506 else:
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
507 size /= 1024 * 1024 * 1024 * 1024
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
508 return QCoreApplication.translate(
328f0f44aa95 Globals: changed format of the data size output and added branch for TiB.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
509 "Globals", "{0:4.2f} TiB").format(size)
6682
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
510
4326e802ff56 Globals: added the dataString() function to format a size into a human readable string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
511
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
512 ###############################################################################
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
513 ## functions for converting QSetting return types to valid types
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
514 ###############################################################################
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
515
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
516
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
517 def toBool(value):
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
518 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
519 Module function to convert a value to bool.
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
520
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
521 @param value value to be converted
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
522 @type str
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
523 @return converted data
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
524 @rtype bool
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
525 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
526 if value in ["true", "1", "True"]:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
527 return True
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
528 elif value in ["false", "0", "False"]:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
529 return False
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
530 else:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
531 return bool(value)
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
532
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
533
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
534 def toList(value):
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
535 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
536 Module function to convert a value to a list.
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
537
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
538 @param value value to be converted
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
539 @type None, list or Any
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
540 @return converted data
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
541 @rtype list
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
542 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
543 if value is None:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
544 return []
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
545 elif not isinstance(value, list):
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
546 return [value]
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
547 else:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
548 return value
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
549
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
550
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
551 def toByteArray(value):
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
552 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
553 Module function to convert a value to a byte array.
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
554
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
555 @param value value to be converted
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
556 @type QByteArray or None
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
557 @return converted data
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
558 @rtype QByteArray
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
559 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
560 if value is None:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
561 return QByteArray()
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
562 else:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
563 return value
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
564
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
565
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
566 def toDict(value):
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
567 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
568 Module function to convert a value to a dictionary.
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
569
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
570 @param value value to be converted
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
571 @type dict or None
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
572 @return converted data
8467
bccf0a3fa67c Removed an obsolete TODO comment and updated the source code docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8459
diff changeset
573 @rtype dict
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
574 """
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
575 if value is None:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
576 return {}
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
577 else:
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
578 return value
4566
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4343
diff changeset
579
6630
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
580
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
581 ###############################################################################
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
582 ## functions for web browser variant detection
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
583 ###############################################################################
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
584
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
585
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
586 def getWebBrowserSupport():
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
587 """
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
588 Module function to determine the supported web browser variant.
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
589
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
590 @return string indicating the supported web browser variant ("QtWebEngine",
7196
ab0a91b82b37 Removed support for QtWebKit and the old web rowser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7192
diff changeset
591 or "None")
6630
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
592 @rtype str
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
593 """
8314
e3642a6a1e71 Finished renaming eric6 to eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
594 from eric7config import getConfig
6630
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
595 scriptPath = os.path.join(getConfig("ericDir"), "Tools",
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
596 "webBrowserSupport.py")
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
597 proc = QProcess()
9016
6f079c524e99 Changed occurrences of sys.executable with a method to get rid of the "w" on Windows and macOS systems (i.e. change pythonw to python).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8958
diff changeset
598 proc.start(getPythonExecutable(), [scriptPath, qVersion()])
8257
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
599 variant = (
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
600 str(proc.readAllStandardOutput(), "utf-8", 'replace').strip()
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
601 if proc.waitForFinished(10000) else
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
602 "None"
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
603 )
6630
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6589
diff changeset
604 return variant
4566
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4343
diff changeset
605 #
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4343
diff changeset
606 # eflag: noqa = M801

eric ide

mercurial