eric6/Globals/__init__.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 8126
e7278bf7168f
child 8142
43248bafe9b2
child 8240
93b8a353c4bf
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

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
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7907
diff changeset
3 # Copyright (c) 2006 - 2021 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
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 import sys
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
6474
72c063cc730b Globals.__init__: fixed an issue that caused startup issues on Windows if both _eric6 and .eric6 were existing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6366
diff changeset
17 import shutil
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
7253
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
19 from PyQt5.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
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
23 from eric6config import getConfig
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
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
26 settingsNameOrganization = "Eric6"
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
27 settingsNameGlobal = "eric6"
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
28 settingsNameRecent = "eric6recent"
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"
1221
291dc0a51947 Added code to the cooperation functions to support IPv6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1162
diff changeset
35 recentNameHosts = "Hosts6"
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"
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
39 configDir = None
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
40
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
41
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 def isWindowsPlatform():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 Function to check, if this is a Windows platform.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 @return flag indicating Windows platform (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 """
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
48 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
49
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
50
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
51 def isMacPlatform():
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
52 """
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
53 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
54
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
55 @return flag indicating Mac platform (boolean)
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
56 """
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
57 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
58
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
59
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
60 def isLinuxPlatform():
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
61 """
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
62 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
63
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
64 @return flag indicating Linux platform (boolean)
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
65 """
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
66 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
67
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
68
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
69 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
70 """
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
71 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
72 (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
73
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
74 @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
75 @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
76 """
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 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
78 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
79
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 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
81 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
82 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
83
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 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
85 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
86 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
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("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
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
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
92 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
93 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
94 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
95
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
96 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
97 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
98 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
99
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("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
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
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
104 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
105
f481df37413c Extended the error report to send the desktop environment in use (Linux only).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
106
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
107 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
108 """
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 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
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 @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
112 @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
113 """
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 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
115 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
116
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
117 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
118
7253
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
119 desktop = (
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
120 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
121 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
122 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
123 )
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
124 if 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
125 isKDE = "kde" in desktop or "plasma" in 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
126 else:
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 isKDE = bool(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
128
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 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
130
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
131
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
132 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
133 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
134 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
135
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
136 @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
137 @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
138 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
139 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
140 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
141
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 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
143
7253
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
144 desktop = (
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
145 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
146 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
147 os.environ.get("GDMSESSION", "").lower()
7253
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
148 )
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
149 if 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
150 isGnome = "gnome" in 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
151 else:
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 isGnome = bool(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
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 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
155
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
156
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
157 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
158 """
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 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
160
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
161 @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
162 @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
163 """
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
164 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
165 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
166
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
167 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
168 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
169 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
170 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
171 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
172
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 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
174 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
175 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
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 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
178
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
5ae038f273c4 Snapshot: refactored the SnapWidget to prepare for implementing snapshot functionality for Wayland desktops.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6682
diff changeset
180 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
181 """
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 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
183
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 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
185 @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
186 """
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 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
188
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
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
190 def getConfigDir():
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
191 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
192 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
193
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
194 @return directory name of the config dir (string)
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
195 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
196 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
197 hp = configDir
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
198 else:
6303
ec9ebaf206fb Got rid of the Windows "DotNet"-Hack (i.e. using _ instead of . as first character of special directories).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6289
diff changeset
199 cdn = ".eric6"
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
200 if isWindowsPlatform():
6303
ec9ebaf206fb Got rid of the Windows "DotNet"-Hack (i.e. using _ instead of . as first character of special directories).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6289
diff changeset
201 # migrate the old config directory (< v18.06)
ec9ebaf206fb Got rid of the Windows "DotNet"-Hack (i.e. using _ instead of . as first character of special directories).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6289
diff changeset
202 cdnOld = "_eric6"
ec9ebaf206fb Got rid of the Windows "DotNet"-Hack (i.e. using _ instead of . as first character of special directories).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6289
diff changeset
203 hpOld = os.path.join(os.path.expanduser("~"), cdnOld)
ec9ebaf206fb Got rid of the Windows "DotNet"-Hack (i.e. using _ instead of . as first character of special directories).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6289
diff changeset
204 if os.path.exists(hpOld):
ec9ebaf206fb Got rid of the Windows "DotNet"-Hack (i.e. using _ instead of . as first character of special directories).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6289
diff changeset
205 hpNew = os.path.join(os.path.expanduser("~"), cdn)
6474
72c063cc730b Globals.__init__: fixed an issue that caused startup issues on Windows if both _eric6 and .eric6 were existing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6366
diff changeset
206 if os.path.exists(hpNew):
72c063cc730b Globals.__init__: fixed an issue that caused startup issues on Windows if both _eric6 and .eric6 were existing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6366
diff changeset
207 # simply delete the old config directory
6530
25b9dcfd6fcc Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6474
diff changeset
208 shutil.rmtree(hpOld, True)
6474
72c063cc730b Globals.__init__: fixed an issue that caused startup issues on Windows if both _eric6 and .eric6 were existing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6366
diff changeset
209 else:
72c063cc730b Globals.__init__: fixed an issue that caused startup issues on Windows if both _eric6 and .eric6 were existing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6366
diff changeset
210 os.rename(hpOld, hpNew)
6303
ec9ebaf206fb Got rid of the Windows "DotNet"-Hack (i.e. using _ instead of . as first character of special directories).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6289
diff changeset
211
5823
70dfe6a4aa03 Fixed an issue getting the home directory during uninstallation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
212 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
213 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
214 os.mkdir(hp)
70dfe6a4aa03 Fixed an issue getting the home directory during uninstallation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5736
diff changeset
215 return hp
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
216
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
217
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
218 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
219 """
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 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
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 @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
223 @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
224 """
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 filename = "eric6install.{0}.json".format(
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 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
227 .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
228 .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
229 .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
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 .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
232 )
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 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
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
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
236 def setConfigDir(d):
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
237 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
238 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
239
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
240 @param d name of an existing directory (string)
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
241 """
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
242 global configDir
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
243 configDir = os.path.expanduser(d)
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
2608
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
246 def getPythonModulesDirectory():
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
247 """
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
248 Function to determine the path to Python's modules directory.
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
249
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
250 @return path to the Python modules directory (string)
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
251 """
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
252 import distutils.sysconfig
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
253 return distutils.sysconfig.get_python_lib(True)
2614
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
254
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
255
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
256 def getPyQt5ModulesDirectory():
2614
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
257 """
7198
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7196
diff changeset
258 Function to determine the path to PyQt5 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
259
7198
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7196
diff changeset
260 @return path to the PyQt5 modules directory (string)
2614
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
261 """
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
262 import distutils.sysconfig
7198
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7196
diff changeset
263
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7196
diff changeset
264 pyqtPath = os.path.join(distutils.sysconfig.get_python_lib(True), "PyQt5")
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7196
diff changeset
265 if os.path.exists(pyqtPath):
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7196
diff changeset
266 return pyqtPath
3807
91fc2089c401 Added some more PyQt4 compatibility code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
267
91fc2089c401 Added some more PyQt4 compatibility code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3778
diff changeset
268 return ""
2608
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
269
01118174a2f5 Changed code to be compatible with latest PyQt4 Windows installers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
270
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
271 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
272 """
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
273 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
274
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
275 @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
276 @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
277 @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
278 @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
279 """
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
280 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
281
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
282 path = ""
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
283
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
284 # 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
285 if version == 5:
7991ea245c20 Added support for PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7861
diff changeset
286 path = Preferences.getQt("PyQtToolsDir")
7991ea245c20 Added support for PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7861
diff changeset
287 elif version == 6:
7991ea245c20 Added support for PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7861
diff changeset
288 path = 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
289
7907
7991ea245c20 Added support for PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7861
diff changeset
290 # step 2: determine from used Python interpreter (pylupdate is test object)
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 if not path:
7907
7991ea245c20 Added support for PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7861
diff changeset
292 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
293 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
294 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
295 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
296 if os.path.exists(os.path.join(dirName, program)):
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 path = dirName
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 elif os.path.exists(os.path.join(dirName, "Scripts", program)):
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 path = os.path.join(dirName, "Scripts")
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 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
301 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
302 if os.path.exists(os.path.join(dirName, program)):
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 path = dirName
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
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
305 return path
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
306
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
307
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
308 def getQtBinariesPath():
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
309 """
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
310 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
311
7741
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
312 @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
313 @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
314 """
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
315 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
316
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
317 path = ""
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
318
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
319 # step 1: check, if the user has configured a tools path
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
320 path = Preferences.getQt("QtToolsDir")
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
321
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
322 # step 2: try the qt5_applications package
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
323 if not path:
7861
3d48094ba8e1 Globals: fixed a severe bug.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7835
diff changeset
324 try:
3d48094ba8e1 Globals: fixed a severe bug.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7835
diff changeset
325 import qt5_applications
3d48094ba8e1 Globals: fixed a severe bug.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7835
diff changeset
326 path = os.path.join(os.path.dirname(qt5_applications.__file__),
3d48094ba8e1 Globals: fixed a severe bug.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7835
diff changeset
327 "Qt", "bin")
3d48094ba8e1 Globals: fixed a severe bug.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7835
diff changeset
328 except ImportError:
3d48094ba8e1 Globals: fixed a severe bug.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7835
diff changeset
329 # qt5-applications is not installed; just go to the next step
3d48094ba8e1 Globals: fixed a severe bug.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7835
diff changeset
330 pass
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
331
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
332 # step 3: determine from used Python interpreter (designer is test object)
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
333 if not path:
7741
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
334 program = "designer"
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
335 if isWindowsPlatform():
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
336 program += ".exe"
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
337 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
338 if os.path.exists(os.path.join(dirName, program)):
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
339 path = dirName
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
340 elif os.path.exists(os.path.join(dirName, "Scripts", program)):
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
341 path = os.path.join(dirName, "Scripts")
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
342 else:
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
343 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
344 if os.path.exists(os.path.join(dirName, program)):
6ead5f865f72 Updated the way the path to Qt tools is determined.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7673
diff changeset
345 path = 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
346
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
347 return QDir.toNativeSeparators(path)
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
348
bdc9b4659826 Added a method to determine the Qt binaries path to the Globals package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
349
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
350 ###############################################################################
5848
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
351 ## 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
352 ###############################################################################
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
353
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
354
7641
21ea4fd50b0a PipPackagesWidget: made the cache actions dependent on pip version of selected environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
355 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
356 """
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
357 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
358
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
359 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
360 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
361 decimal.
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
362
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
363 @param version version string
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
364 @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
365 @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
366 @type int
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
367 @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
368 @rtype tuple of int
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
369 """
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
370 versionParts = []
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
371
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
372 # step 1: extract suffix
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
373 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
374 for part in version.split("."):
7673
f0309b9483b1 Globals: added some error checking to 'versionToTuple'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7641
diff changeset
375 try:
f0309b9483b1 Globals: added some error checking to 'versionToTuple'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7641
diff changeset
376 versionParts.append(int(part.strip()))
f0309b9483b1 Globals: added some error checking to 'versionToTuple'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7641
diff changeset
377 except ValueError:
f0309b9483b1 Globals: added some error checking to 'versionToTuple'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7641
diff changeset
378 # skip non-integer parts
f0309b9483b1 Globals: added some error checking to 'versionToTuple'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7641
diff changeset
379 pass
7641
21ea4fd50b0a PipPackagesWidget: made the cache actions dependent on pip version of selected environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
380 versionParts.extend([0] * length)
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
381
7641
21ea4fd50b0a PipPackagesWidget: made the cache actions dependent on pip version of selected environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
382 return tuple(versionParts[:length])
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
383
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
384
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
385 def qVersionTuple():
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
386 """
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
387 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
388
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
389 @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
390 @rtype tuple of int
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
391 """
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
392 return (
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
393 (QT_VERSION & 0xff0000) >> 16,
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
394 (QT_VERSION & 0xff00) >> 8,
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
395 QT_VERSION & 0xff,
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
396 )
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
397
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 ###############################################################################
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
400 ## functions for extended string handling
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
401 ###############################################################################
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
402
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5735
diff changeset
403
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
404 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
405 """
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
406 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
407 separator.
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
408
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
409 @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
410 @type str
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
411 @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
412 @type str
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
413 @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
414 @type int
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
415 @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
416 @rtype str
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
417 """
4724
682f009d086d Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4695
diff changeset
418 groups = []
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
419
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
420 while len(txt) // groupLen != 0:
4724
682f009d086d Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4695
diff changeset
421 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
422 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
423 if len(txt) > 0:
4724
682f009d086d Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4695
diff changeset
424 groups.insert(0, txt)
682f009d086d Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4695
diff changeset
425 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
426
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
427
5848
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
428 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
429 """
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
430 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
431
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
432 @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
433 @type str, bytes, bytearray
5859
28282fa0df7b Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5848
diff changeset
434 @return converted QByteArray
28282fa0df7b Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5848
diff changeset
435 @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
436 """
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7085
diff changeset
437 if isinstance(txt, str):
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7085
diff changeset
438 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
439
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
440 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
441
56388f41b1e6 Fixed an issue sending input to the mercurial and subversion processes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5823
diff changeset
442
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
443 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
444 """
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
445 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
446
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
447 @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
448 @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
449 @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
450 @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
451 """
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
452 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
453 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
454 "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
455 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
456 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
457 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
458 "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
459 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
460 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
461 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
462 "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
463 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
464 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
465 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
466 "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
467 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
468 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
469 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
470 "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
471
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
472
4686
5f8a5c568230 Improved the display of addresses and sizes in the hex editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
473 ###############################################################################
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
474 ## 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
475 ###############################################################################
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
476
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
477
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
478 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
479 """
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
480 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
481
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
482 @param value value to be converted
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
483 @return converted data
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
484 """
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
485 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
486 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
487 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
488 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
489 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
490 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
491
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
492
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
493 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
494 """
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
495 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
496
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
497 @param value value to be converted
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
498 @return converted data
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
499 """
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
500 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
501 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
502 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
503 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
504 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
505 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
506
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
507
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
508 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
509 """
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
510 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
511
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
512 @param value value to be converted
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 @return converted data
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 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
516 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
517 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
518 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
519
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 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
522 """
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 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
524
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 @param value value to be converted
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 @return converted data
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 """
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 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
529 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
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 value
4566
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4343
diff changeset
532
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
533
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
534 ###############################################################################
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
535 ## 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
536 ###############################################################################
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
537
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
538
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
539 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
540 """
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
541 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
542
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
543 @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
544 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
545 @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
546 """
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
547 from eric6config import getConfig
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
548 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
549 "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
550 proc = QProcess()
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
551 proc.start(sys.executable, [scriptPath, qVersion()])
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
552 if proc.waitForFinished(10000):
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
553 variant = str(proc.readAllStandardOutput(), "utf-8", 'replace').strip()
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
554 else:
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
555 variant = "None"
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
556 return variant
4566
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4343
diff changeset
557 #
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4343
diff changeset
558 # eflag: noqa = M801

eric ide

mercurial