33 # Start-of-Header |
33 # Start-of-Header |
34 name = "PyLint Plugin" |
34 name = "PyLint Plugin" |
35 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
35 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
36 autoactivate = True |
36 autoactivate = True |
37 deactivateable = True |
37 deactivateable = True |
38 version = "6.1.7" |
38 version = "6.1.8" |
39 className = "PyLintPlugin" |
39 className = "PyLintPlugin" |
40 packageName = "PyLint" |
40 packageName = "PyLint" |
41 shortDescription = "Show the PyLint dialogs." |
41 shortDescription = "Show the PyLint dialogs." |
42 longDescription = """This plug-in implements the PyLint dialogs.""" \ |
42 longDescription = """This plug-in implements the PyLint dialogs.""" \ |
43 """ PyLint is used to check Python source files according to various""" \ |
43 """ PyLint is used to check Python source files according to various""" \ |
151 exes.append(exe) |
151 exes.append(exe) |
152 except (WindowsError, OSError): # __IGNORE_WARNING__ |
152 except (WindowsError, OSError): # __IGNORE_WARNING__ |
153 pass |
153 pass |
154 return exes |
154 return exes |
155 |
155 |
|
156 versionSuffixes = ["", "-32", "-64"] |
156 for minorVersion in minorVersions: |
157 for minorVersion in minorVersions: |
157 versionStr = '{0}.{1}'.format(majorVersion, minorVersion) |
158 for versionSuffix in versionSuffixes: |
158 exePaths = getExePath( |
159 versionStr = '{0}.{1}{2}'.format(majorVersion, minorVersion, |
159 winreg.HKEY_CURRENT_USER, |
160 versionSuffix) |
160 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr) |
|
161 if exePaths: |
|
162 for exePath in exePaths: |
|
163 executables.add(exePath) |
|
164 |
|
165 exePaths = getExePath( |
|
166 winreg.HKEY_LOCAL_MACHINE, |
|
167 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr) |
|
168 if exePaths: |
|
169 for exePath in exePaths: |
|
170 executables.add(exePath) |
|
171 |
|
172 # Even on Intel 64-bit machines it's 'AMD64' |
|
173 if platform.machine() == 'AMD64': |
|
174 exePaths = getExePath( |
161 exePaths = getExePath( |
175 winreg.HKEY_CURRENT_USER, |
162 winreg.HKEY_CURRENT_USER, |
176 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr) |
163 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr) |
177 if exePaths: |
164 if exePaths: |
178 for exePath in exePaths: |
165 for exePath in exePaths: |
179 executables.add(exePath) |
166 executables.add(exePath) |
180 |
167 |
181 exePath = getExePath( |
168 exePaths = getExePath( |
182 winreg.HKEY_LOCAL_MACHINE, |
169 winreg.HKEY_LOCAL_MACHINE, |
183 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr) |
170 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr) |
184 if exePaths: |
171 if exePaths: |
185 for exePath in exePaths: |
172 for exePath in exePaths: |
186 executables.add(exePath) |
173 executables.add(exePath) |
|
174 |
|
175 # Even on Intel 64-bit machines it's 'AMD64' |
|
176 if platform.machine() == 'AMD64': |
|
177 exePaths = getExePath( |
|
178 winreg.HKEY_CURRENT_USER, |
|
179 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr) |
|
180 if exePaths: |
|
181 for exePath in exePaths: |
|
182 executables.add(exePath) |
|
183 |
|
184 exePath = getExePath( |
|
185 winreg.HKEY_LOCAL_MACHINE, |
|
186 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr) |
|
187 if exePaths: |
|
188 for exePath in exePaths: |
|
189 executables.add(exePath) |
187 else: |
190 else: |
188 # |
191 # |
189 # Linux, Unix ... |
192 # Linux, Unix ... |
190 pylintScript = 'pylint' |
193 pylintScript = 'pylint' |
191 scriptSuffixes = ["", |
194 scriptSuffixes = ["", |
208 exe = os.path.join(directory, pylintScript + suffix) |
211 exe = os.path.join(directory, pylintScript + suffix) |
209 if os.access(exe, os.X_OK): |
212 if os.access(exe, os.X_OK): |
210 exes.append(exe) |
213 exes.append(exe) |
211 |
214 |
212 # step 2: determine the Python variant |
215 # step 2: determine the Python variant |
213 if Utilities.isMacPlatform(): |
|
214 checkStrings = ["Python.framework/Versions/3".lower(), |
|
215 "python3", "python"] |
|
216 else: |
|
217 checkStrings = ["python3"] |
|
218 |
|
219 _exePy2 = set() |
216 _exePy2 = set() |
220 _exePy3 = set() |
217 _exePy3 = set() |
|
218 versionArgs = ["-c", "import sys; print(sys.version_info[0])"] |
221 for exe in exes: |
219 for exe in exes: |
222 try: |
220 try: |
223 f = open(exe, "r") |
221 f = open(exe, "r") |
224 line0 = f.readline() |
222 line0 = f.readline() |
225 for checkStr in checkStrings: |
223 program = line0.replace("#!", "").strip() |
226 if checkStr in line0.lower(): |
224 process = QProcess() |
227 _exePy3.add(exe) |
225 process.start(program, versionArgs) |
228 break |
226 process.waitForFinished(5000) |
|
227 # get a QByteArray of the output |
|
228 versionBytes = process.readAllStandardOutput() |
|
229 versionStr = str(versionBytes, encoding='utf-8').strip() |
|
230 if versionStr == "3": |
|
231 _exePy3.add(exe) |
229 else: |
232 else: |
230 _exePy2.add(exe) |
233 _exePy2.add(exe) |
231 finally: |
234 finally: |
232 f.close() |
235 f.close() |
233 |
236 |