eric6/Utilities/BackgroundService.py

Thu, 03 Jun 2021 11:39:23 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 03 Jun 2021 11:39:23 +0200
branch
maintenance
changeset 8400
b3eefd7e58d1
parent 8273
698ae46f40a4
parent 8309
10aa9235b817
child 8576
fe1957c69854
permissions
-rw-r--r--

Merged with default branch to prepare release 21.6.

3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7900
diff changeset
3 # Copyright (c) 2013 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
4 #
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
5
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
6 """
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
7 Module implementing a background service for the various checkers and other
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
8 Python interpreter dependent functions.
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
9 """
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
10
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
11 import json
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
12 import os
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
13 import struct
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
14 import sys
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
15 from zlib import adler32
8243
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
16 import contextlib
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
17
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
18 from PyQt5.QtCore import QProcess, pyqtSignal, QTimer
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
19 from PyQt5.QtWidgets import QApplication
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
20 from PyQt5.QtNetwork import QTcpServer, QHostAddress
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
21
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
22 from E5Gui import E5MessageBox
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
23 from E5Gui.E5Application import e5App
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
24 import Preferences
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
25 import Utilities
8307
01a323d3d4d7 Background Server, Client: pass the path to the Python library of the eric (virtual) environment to the client to enable service plug-ins to load dependencies from there.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8264
diff changeset
26 import Globals
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
27
8309
10aa9235b817 Corrected a code style issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8307
diff changeset
28
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
29 class BackgroundService(QTcpServer):
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
30 """
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
31 Class implementing the main part of the background service.
5726
e1dbd217214a Fixed a few source docu issues (forgotten signals and exceptions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5688
diff changeset
32
e1dbd217214a Fixed a few source docu issues (forgotten signals and exceptions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5688
diff changeset
33 @signal serviceNotAvailable(function, language, filename, message)
e1dbd217214a Fixed a few source docu issues (forgotten signals and exceptions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5688
diff changeset
34 emitted to indicate the non-availability of a service function
e1dbd217214a Fixed a few source docu issues (forgotten signals and exceptions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5688
diff changeset
35 (str, str, str, str)
e1dbd217214a Fixed a few source docu issues (forgotten signals and exceptions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5688
diff changeset
36 @signal batchJobDone(function, language) emitted to indicate the end of
e1dbd217214a Fixed a few source docu issues (forgotten signals and exceptions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5688
diff changeset
37 a batch job (str, str)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
38 """
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
39 serviceNotAvailable = pyqtSignal(str, str, str, str)
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
40 batchJobDone = pyqtSignal(str, str)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
41
8173
b2f9cda5cc0e Change code to give BackgroundService a 'parent'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
42 def __init__(self, parent=None):
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
43 """
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
44 Constructor
8173
b2f9cda5cc0e Change code to give BackgroundService a 'parent'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
45
b2f9cda5cc0e Change code to give BackgroundService a 'parent'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
46 @param parent reference to the parent object
b2f9cda5cc0e Change code to give BackgroundService a 'parent'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
47 @type QObject
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
48 """
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
49 self.processes = {}
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
50 self.connections = {}
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3173
diff changeset
51 self.isWorking = None
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
52 self.runningJob = [None, None, None, None]
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
53 self.__queue = []
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
54 self.services = {}
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
55
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8173
diff changeset
56 super().__init__(parent)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
57
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
58 networkInterface = Preferences.getDebugger("NetworkInterface")
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
59 if networkInterface == "all" or '.' in networkInterface:
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
60 self.hostAddress = '127.0.0.1'
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
61 else:
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
62 self.hostAddress = '::1'
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
63 self.listen(QHostAddress(self.hostAddress))
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
64
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
65 self.newConnection.connect(self.on_newConnection)
3417
5a93c6cdc989 Exception handling for client side implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
66
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
67 port = self.serverPort()
3538
33a75660df08 Change a comment in the background service to avoid a clash with a NOTE task marker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3505
diff changeset
68 ## Note: Need the port if started external in debugger:
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
69 print('Background Service listening on: {0:d}'.format(port))
5616
adcffadf4962 Reworked some __IGNORE_WARNING__ comments to be more specific.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
70 # __IGNORE_WARNING__
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
71 venvName = Preferences.getDebugger("Python3VirtualEnv")
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
72 interpreter = e5App().getObject(
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
73 "VirtualEnvManager").getVirtualenvInterpreter(venvName)
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
74 if not interpreter:
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
75 interpreter = sys.executable.replace("w.exe", ".exe")
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
76 if interpreter:
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
77 process = self.__startExternalClient(interpreter, port)
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
78 if process:
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
79 self.processes['Python3'] = process, interpreter
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
80
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
81 def __startExternalClient(self, interpreter, port):
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
82 """
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
83 Private method to start the background client as external process.
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
84
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
85 @param interpreter path and name of the executable to start
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
86 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
87 @param port socket port to which the interpreter should connect
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
88 @type int
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
89 @return the process object
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
90 @rtype QProcess or None
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
91 """
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
92 if interpreter == "" or not Utilities.isinpath(interpreter):
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
93 return None
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
94
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
95 backgroundClient = os.path.join(
8307
01a323d3d4d7 Background Server, Client: pass the path to the Python library of the eric (virtual) environment to the client to enable service plug-ins to load dependencies from there.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8264
diff changeset
96 os.path.dirname(__file__), "BackgroundClient.py")
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
97 proc = QProcess()
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7965
diff changeset
98 proc.setProcessChannelMode(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7965
diff changeset
99 QProcess.ProcessChannelMode.ForwardedChannels)
8307
01a323d3d4d7 Background Server, Client: pass the path to the Python library of the eric (virtual) environment to the client to enable service plug-ins to load dependencies from there.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8264
diff changeset
100 args = [
01a323d3d4d7 Background Server, Client: pass the path to the Python library of the eric (virtual) environment to the client to enable service plug-ins to load dependencies from there.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8264
diff changeset
101 backgroundClient,
01a323d3d4d7 Background Server, Client: pass the path to the Python library of the eric (virtual) environment to the client to enable service plug-ins to load dependencies from there.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8264
diff changeset
102 self.hostAddress,
01a323d3d4d7 Background Server, Client: pass the path to the Python library of the eric (virtual) environment to the client to enable service plug-ins to load dependencies from there.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8264
diff changeset
103 str(port),
01a323d3d4d7 Background Server, Client: pass the path to the Python library of the eric (virtual) environment to the client to enable service plug-ins to load dependencies from there.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8264
diff changeset
104 str(Preferences.getUI("BackgroundServiceProcesses")),
01a323d3d4d7 Background Server, Client: pass the path to the Python library of the eric (virtual) environment to the client to enable service plug-ins to load dependencies from there.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8264
diff changeset
105 Globals.getPythonLibraryDirectory(),
01a323d3d4d7 Background Server, Client: pass the path to the Python library of the eric (virtual) environment to the client to enable service plug-ins to load dependencies from there.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8264
diff changeset
106 ]
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
107 proc.start(interpreter, args)
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
108 if not proc.waitForStarted(10000):
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
109 proc = None
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
110 return proc
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
111
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
112 def __processQueue(self):
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
113 """
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
114 Private method to take the next service request and send it to the
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
115 client.
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
116 """
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3173
diff changeset
117 if self.__queue and self.isWorking is None:
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
118 fx, lang, fn, data = self.__queue.pop(0)
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
119 self.isWorking = lang
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
120 self.runningJob = fx, lang, fn, data
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
121 self.__send(fx, lang, fn, data)
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
122
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
123 def __send(self, fx, lang, fn, data):
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
124 """
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
125 Private method to send a job request to one of the clients.
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
126
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
127 @param fx remote function name to execute
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
128 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
129 @param lang language to connect to
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
130 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
131 @param fn filename for identification
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
132 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
133 @param data function argument(s)
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
134 @type any basic datatype
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
135 """
4235
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4221
diff changeset
136 self.__cancelled = False
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
137 connection = self.connections.get(lang)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
138 if connection is None:
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
139 if fx != 'INIT':
7335
07ed3d73bf58 Syntax Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7259
diff changeset
140 # Avoid growing recursion depth which could itself result in an
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
141 # exception
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
142 QTimer.singleShot(
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
143 0,
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
144 lambda: self.serviceNotAvailable.emit(
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
145 fx, lang, fn, self.tr(
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
146 '{0} not configured.').format(lang)))
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
147 # Reset flag and continue processing queue
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3173
diff changeset
148 self.isWorking = None
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
149 self.__processQueue()
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
150 else:
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
151 packedData = json.dumps([fx, fn, data])
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
152 packedData = bytes(packedData, 'utf-8')
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
153 header = struct.pack(
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
154 b'!II', len(packedData), adler32(packedData) & 0xffffffff)
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
155 connection.write(header)
4221
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
156 connection.write(b'JOB ') # 6 character message type
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
157 connection.write(packedData)
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
158
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
159 def __receive(self, lang):
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
160 """
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
161 Private method to receive the response from the clients.
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
162
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
163 @param lang language of the incoming connection
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
164 @type str
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
165 @exception RuntimeError raised if hashes don't match
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
166 """
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
167 connection = self.connections[lang]
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
168 while connection.bytesAvailable():
4235
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4221
diff changeset
169 if self.__cancelled:
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4221
diff changeset
170 connection.readAll()
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4221
diff changeset
171 continue
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4221
diff changeset
172
4221
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
173 header = connection.read(struct.calcsize(b'!II'))
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
174 length, datahash = struct.unpack(b'!II', header)
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
175
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
176 packedData = b''
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
177 while len(packedData) < length:
5875
3052fb9cf357 Some more speed adjustments for the background service.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5874
diff changeset
178 maxSize = length - len(packedData)
3052fb9cf357 Some more speed adjustments for the background service.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5874
diff changeset
179 if connection.bytesAvailable() < maxSize:
3052fb9cf357 Some more speed adjustments for the background service.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5874
diff changeset
180 connection.waitForReadyRead(50)
3052fb9cf357 Some more speed adjustments for the background service.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5874
diff changeset
181 packedData += connection.read(maxSize)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
182
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
183 if adler32(packedData) & 0xffffffff != datahash:
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
184 raise RuntimeError('Hashes not equal')
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
185 packedData = packedData.decode('utf-8')
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
186 # "check" if is's a tuple of 3 values
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
187 fx, fn, data = json.loads(packedData)
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
188
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
189 if fx == 'INIT':
8264
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
190 if data != "ok":
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
191 E5MessageBox.critical(
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
192 None,
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
193 self.tr("Initialization of Background Service"),
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
194 self.tr(
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
195 "<p>Initialization of Background Service"
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
196 " <b>{0}</b> failed.</p><p>Reason: {1}</p>")
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
197 .format(fn, data)
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
198 )
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
199 elif fx == 'EXCEPTION':
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
200 # Remove connection because it'll close anyway
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
201 self.connections.pop(lang, None)
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
202 # Call sys.excepthook(type, value, traceback) to emulate the
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
203 # exception which was caught on the client
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
204 sys.excepthook(*data)
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
205 res = E5MessageBox.question(
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
206 None,
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
207 self.tr("Restart background client?"),
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
208 self.tr(
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
209 "<p>The background client for <b>{0}</b> has stopped"
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
210 " due to an exception. It's used by various plug-ins"
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
211 " like the different checkers.</p>"
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
212 "<p>Select"
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
213 "<ul>"
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
214 "<li><b>'Yes'</b> to restart the client, but abort the"
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
215 " last job</li>"
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
216 "<li><b>'Retry'</b> to restart the client and the last"
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
217 " job</li>"
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
218 "<li><b>'No'</b> to leave the client off.</li>"
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
219 "</ul></p>"
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
220 "<p>Note: The client can be restarted by opening and"
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
221 " accepting the preferences dialog or reloading/"
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
222 "changing the project.</p>").format(lang),
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
223 E5MessageBox.Yes | E5MessageBox.No | E5MessageBox.Retry,
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
224 E5MessageBox.Yes)
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
225
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
226 if res == E5MessageBox.Retry:
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
227 self.enqueueRequest(*self.runningJob)
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
228 else:
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
229 fx, lng, fn, data = self.runningJob
8243
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
230 with contextlib.suppress(KeyError, TypeError):
5741
ece3c72a24c3 Added some error handling to the Background service in case some errors are reported for an already deleted service.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5726
diff changeset
231 self.services[(fx, lng)][3](fx, lng, fn, self.tr(
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
232 "An error in Eric's background client stopped the"
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
233 " service.")
5741
ece3c72a24c3 Added some error handling to the Background service in case some errors are reported for an already deleted service.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5726
diff changeset
234 )
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
235 if res != E5MessageBox.No:
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
236 self.isWorking = None
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
237 self.restartService(lang, True)
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
238 return
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
239 elif data == 'Unknown service.':
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
240 callback = self.services.get((fx, lang))
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
241 if callback:
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
242 callback[3](fx, lang, fn, data)
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
243 elif fx.startswith("batch_"):
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
244 fx = fx.replace("batch_", "")
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
245 if data != "__DONE__":
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
246 callback = self.services.get((fx, lang))
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
247 if callback:
5688
76fc12e08e8f Introduced some code to improve defensive programming in the BackgroundService class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
248 if isinstance(data, (list, tuple)):
76fc12e08e8f Introduced some code to improve defensive programming in the BackgroundService class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
249 callback[2](fn, *data)
76fc12e08e8f Introduced some code to improve defensive programming in the BackgroundService class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
250 elif isinstance(data, str):
76fc12e08e8f Introduced some code to improve defensive programming in the BackgroundService class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
251 callback[3](fx, lang, fn, data)
8264
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
252 if data == 'Unknown batch service.':
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
253 self.batchJobDone.emit(fx, lang)
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
254 self.__cancelled = True
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
255 else:
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
256 self.batchJobDone.emit(fx, lang)
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
257 else:
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
258 callback = self.services.get((fx, lang))
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
259 if callback:
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
260 callback[2](fn, *data)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
261
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3173
diff changeset
262 self.isWorking = None
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
263 self.__processQueue()
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
264
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
265 def preferencesOrProjectChanged(self):
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
266 """
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
267 Public slot to restart the built in languages.
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
268 """
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
269 venvName = Preferences.getDebugger("Python3VirtualEnv")
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
270 interpreter = e5App().getObject(
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
271 "VirtualEnvManager").getVirtualenvInterpreter(venvName)
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
272 if not interpreter:
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
273 interpreter = sys.executable.replace("w.exe", ".exe")
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
274
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
275 # Tweak the processes list to reflect the changed interpreter
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
276 proc, inter = self.processes.pop('Python3', [None, None])
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
277 self.processes['Python3'] = proc, interpreter
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
278
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
279 self.restartService('Python3')
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
280
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
281 def restartService(self, language, forceKill=False):
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
282 """
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
283 Public method to restart a given language.
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
284
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
285 @param language to restart
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
286 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
287 @param forceKill flag to kill a running task
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
288 @type bool
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
289 """
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
290 try:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
291 proc, interpreter = self.processes.pop(language)
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
292 except KeyError:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
293 return
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
294
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
295 # Don't kill a process if it's still working
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
296 if not forceKill:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
297 while self.isWorking is not None:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
298 QApplication.processEvents()
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
299
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
300 conn = self.connections.pop(language, None)
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
301 if conn:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
302 conn.blockSignals(True)
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
303 conn.close()
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
304 if proc:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
305 proc.close()
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
306
6367
7bc6fc02d981 Fixed a few bugs caused by using the new virtual environment manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6348
diff changeset
307 if interpreter:
7bc6fc02d981 Fixed a few bugs caused by using the new virtual environment manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6348
diff changeset
308 port = self.serverPort()
7bc6fc02d981 Fixed a few bugs caused by using the new virtual environment manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6348
diff changeset
309 process = self.__startExternalClient(interpreter, port)
7bc6fc02d981 Fixed a few bugs caused by using the new virtual environment manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6348
diff changeset
310 if process:
7bc6fc02d981 Fixed a few bugs caused by using the new virtual environment manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6348
diff changeset
311 self.processes[language] = process, interpreter
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
312
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
313 def enqueueRequest(self, fx, lang, fn, data):
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
314 """
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
315 Public method implementing a queued processing of incoming events.
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
316
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
317 Duplicate service requests update an older request to avoid overrun or
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
318 starving of the services.
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
319
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
320 @param fx function name of the service
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
321 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
322 @param lang language to connect to
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
323 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
324 @param fn filename for identification
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
325 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
326 @param data function argument(s)
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
327 @type any basic datatype
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
328 """
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
329 args = [fx, lang, fn, data]
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
330 if fx == 'INIT':
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
331 self.__queue.insert(0, args)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
332 else:
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
333 for pendingArg in self.__queue:
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
334 # Check if it's the same service request (fx, lang, fn equal)
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
335 if pendingArg[:3] == args[:3]:
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
336 # Update the data
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
337 pendingArg[3] = args[3]
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
338 break
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
339 else:
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
340 self.__queue.append(args)
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
341 self.__processQueue()
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
342
4235
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4221
diff changeset
343 def requestCancel(self, fx, lang):
4221
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
344 """
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
345 Public method to ask a batch job to terminate.
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
346
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
347 @param fx function name of the service
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
348 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
349 @param lang language to connect to
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
350 @type str
4221
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
351 """
4235
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4221
diff changeset
352 self.__cancelled = True
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4221
diff changeset
353
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4221
diff changeset
354 entriesToRemove = []
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4221
diff changeset
355 for pendingArg in self.__queue:
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4221
diff changeset
356 if pendingArg[:2] == [fx, lang]:
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4221
diff changeset
357 entriesToRemove.append(pendingArg)
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4221
diff changeset
358 for entryToRemove in entriesToRemove:
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4221
diff changeset
359 self.__queue.remove(entryToRemove)
81278aff6af9 Fixed an issue in the batch checker cancel function leading to the function not working if the background jobs had finished already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4221
diff changeset
360
4221
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
361 connection = self.connections.get(lang)
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
362 if connection is None:
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
363 return
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
364 else:
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
365 header = struct.pack(b'!II', 0, 0)
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
366 connection.write(header)
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
367 connection.write(b'CANCEL') # 6 character message type
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
368
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
369 def serviceConnect(
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
370 self, fx, lang, modulepath, module, callback,
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
371 onErrorCallback=None, onBatchDone=None):
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
372 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3581
diff changeset
373 Public method to announce a new service to the background
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3581
diff changeset
374 service/client.
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
375
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
376 @param fx function name of the service
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
377 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
378 @param lang language of the new service
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
379 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
380 @param modulepath full path to the module
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
381 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
382 @param module name to import
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
383 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
384 @param callback function called on service response
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
385 @type function
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
386 @param onErrorCallback function called, if client isn't available
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
387 (function)
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
388 @param onBatchDone function called when a batch job is done
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
389 @type function
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
390 """
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
391 self.services[(fx, lang)] = (
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
392 modulepath, module, callback, onErrorCallback
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
393 )
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
394 self.enqueueRequest('INIT', lang, fx, [modulepath, module])
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
395 if onErrorCallback:
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
396 self.serviceNotAvailable.connect(onErrorCallback)
4218
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
397 if onBatchDone:
f542ad1f76c5 Added a batch mode to the code style checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
398 self.batchJobDone.connect(onBatchDone)
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
399
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
400 def serviceDisconnect(self, fx, lang):
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
401 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3581
diff changeset
402 Public method to remove the service from the service list.
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
403
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
404 @param fx function name of the service
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
405 @type function
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
406 @param lang language of the service
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
407 @type str
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
408 """
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
409 serviceArgs = self.services.pop((fx, lang), None)
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
410 if serviceArgs and serviceArgs[3]:
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
411 self.serviceNotAvailable.disconnect(serviceArgs[3])
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
412
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
413 def on_newConnection(self):
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
414 """
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
415 Private slot for new incoming connections from the clients.
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
416 """
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
417 connection = self.nextPendingConnection()
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
418 if not connection.waitForReadyRead(1000):
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
419 return
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
420 lang = connection.read(64)
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
421 lang = lang.decode('utf-8')
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3173
diff changeset
422 # Avoid hanging of eric on shutdown
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
423 if self.connections.get(lang):
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
424 self.connections[lang].close()
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
425 if self.isWorking == lang:
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3173
diff changeset
426 self.isWorking = None
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
427 self.connections[lang] = connection
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
428 connection.readyRead.connect(
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
429 lambda x=lang: self.__receive(x))
3417
5a93c6cdc989 Exception handling for client side implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
430 connection.disconnected.connect(
5a93c6cdc989 Exception handling for client side implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
431 lambda x=lang: self.on_disconnectSocket(x))
5a93c6cdc989 Exception handling for client side implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
432
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
433 for (fx, lng), args in self.services.items():
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
434 if lng == lang:
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
435 # Register service with modulepath and module
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
436 self.enqueueRequest('INIT', lng, fx, args[:2])
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
437
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
438 # Syntax check the open editors again
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
439 try:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
440 vm = e5App().getObject("ViewManager")
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
441 except KeyError:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
442 return
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
443 for editor in vm.getOpenEditors():
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
444 if editor.getLanguage() == lang:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
445 QTimer.singleShot(0, editor.checkSyntax)
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
446
3417
5a93c6cdc989 Exception handling for client side implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
447 def on_disconnectSocket(self, lang):
5a93c6cdc989 Exception handling for client side implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
448 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3581
diff changeset
449 Private slot called when connection to a client is lost.
3417
5a93c6cdc989 Exception handling for client side implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
450
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
451 @param lang client language which connection is lost
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
452 @type str
3417
5a93c6cdc989 Exception handling for client side implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
453 """
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
454 conn = self.connections.pop(lang, None)
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
455 if conn:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
456 conn.close()
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
457 fx, lng, fn, data = self.runningJob
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
458 if fx != 'INIT' and lng == lang:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
459 self.services[(fx, lng)][3](fx, lng, fn, self.tr(
6321
f85288918089 BackgroundService: Little change to close the service when shutting down.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
460 "Eric's background client disconnected because of an"
f85288918089 BackgroundService: Little change to close the service when shutting down.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
461 " unknown reason.")
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
462 )
3417
5a93c6cdc989 Exception handling for client side implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
463 self.isWorking = None
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
464
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
465 res = E5MessageBox.yesNo(
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
466 None,
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
467 self.tr('Background client disconnected.'),
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
468 self.tr(
4997
6dfb9119c85b Fixed a typo.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
469 'The background client for <b>{0}</b> disconnected because'
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
470 ' of an unknown reason.<br>Should it be restarted?'
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
471 ).format(lang),
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
472 yesDefault=True)
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
473 if res:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
474 self.restartService(lang)
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
475
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
476 def shutdown(self):
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
477 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3581
diff changeset
478 Public method to cleanup the connections and processes when eric is
6321
f85288918089 BackgroundService: Little change to close the service when shutting down.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
479 shutting down.
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
480 """
6321
f85288918089 BackgroundService: Little change to close the service when shutting down.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
481 self.close()
f85288918089 BackgroundService: Little change to close the service when shutting down.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
482
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
483 for connection in self.connections.values():
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
484 # Prevent calling of on_disconnectSocket
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
485 connection.blockSignals(True)
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
486 connection.close()
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3172
diff changeset
487
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
488 for process, _interpreter in self.processes.values():
3505
84e7cee47d10 Start the background client always as external process.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3484
diff changeset
489 process.close()
7630
4010cc7e9c0b BackgroundService: improved the shutdown method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
490 if not process.waitForFinished(10000):
4010cc7e9c0b BackgroundService: improved the shutdown method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
491 process.kill()
3505
84e7cee47d10 Start the background client always as external process.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3484
diff changeset
492 process = None

eric ide

mercurial