eric6/Utilities/BackgroundService.py

Wed, 12 May 2021 19:50:20 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 12 May 2021 19:50:20 +0200
changeset 8307
01a323d3d4d7
parent 8264
f95dde35d0ab
child 8309
10aa9235b817
permissions
-rw-r--r--

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.

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
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
28 class BackgroundService(QTcpServer):
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
29 """
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
30 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: 5691
diff changeset
31
e1dbd217214a Fixed a few source docu issues (forgotten signals and exceptions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5691
diff changeset
32 @signal serviceNotAvailable(function, language, filename, message)
e1dbd217214a Fixed a few source docu issues (forgotten signals and exceptions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5691
diff changeset
33 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: 5691
diff changeset
34 (str, str, str, str)
e1dbd217214a Fixed a few source docu issues (forgotten signals and exceptions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5691
diff changeset
35 @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: 5691
diff changeset
36 a batch job (str, str)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
37 """
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
38 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
39 batchJobDone = pyqtSignal(str, str)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
40
8173
b2f9cda5cc0e Change code to give BackgroundService a 'parent'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
41 def __init__(self, parent=None):
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
42 """
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
43 Constructor
8173
b2f9cda5cc0e Change code to give BackgroundService a 'parent'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
44
b2f9cda5cc0e Change code to give BackgroundService a 'parent'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
45 @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
46 @type QObject
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
47 """
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
48 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
49 self.connections = {}
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3173
diff changeset
50 self.isWorking = None
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
51 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
52 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
53 self.services = {}
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
54
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
55 super().__init__(parent)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
56
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
57 networkInterface = Preferences.getDebugger("NetworkInterface")
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
58 if networkInterface == "all" or '.' in networkInterface:
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
59 self.hostAddress = '127.0.0.1'
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
60 else:
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
61 self.hostAddress = '::1'
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
62 self.listen(QHostAddress(self.hostAddress))
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
63
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
64 self.newConnection.connect(self.on_newConnection)
3417
5a93c6cdc989 Exception handling for client side implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
65
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
66 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
67 ## 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
68 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
69 # __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
70 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
71 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
72 "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
73 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
74 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
75 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
76 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
77 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
78 self.processes['Python3'] = process, interpreter
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
79
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
80 def __startExternalClient(self, interpreter, port):
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
81 """
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
82 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
83
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
84 @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
85 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
86 @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
87 @type int
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
88 @return the process object
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
89 @rtype QProcess or None
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
90 """
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
91 if interpreter == "" or not Utilities.isinpath(interpreter):
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
92 return None
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
93
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
94 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
95 os.path.dirname(__file__), "BackgroundClient.py")
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
96 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
97 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
98 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
99 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
100 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
101 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
102 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
103 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
104 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
105 ]
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
106 proc.start(interpreter, args)
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
107 if not proc.waitForStarted(10000):
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
108 proc = None
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
109 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
110
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 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
112 """
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 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
114 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
115 """
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3173
diff changeset
116 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
117 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
118 self.isWorking = lang
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
119 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
120 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
121
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
122 def __send(self, fx, lang, fn, data):
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
123 """
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
124 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
125
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
126 @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
127 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
128 @param lang language to connect to
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
129 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
130 @param fn filename for identification
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
131 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
132 @param data function argument(s)
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
133 @type any basic datatype
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
134 """
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
135 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
136 connection = self.connections.get(lang)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
137 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
138 if fx != 'INIT':
7335
07ed3d73bf58 Syntax Checker:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7259
diff changeset
139 # 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
140 # exception
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
141 QTimer.singleShot(
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
142 0,
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
143 lambda: self.serviceNotAvailable.emit(
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
144 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
145 '{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
146 # 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
147 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
148 self.__processQueue()
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
149 else:
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
150 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
151 packedData = bytes(packedData, 'utf-8')
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
152 header = struct.pack(
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
153 b'!II', len(packedData), adler32(packedData) & 0xffffffff)
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
154 connection.write(header)
4221
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
155 connection.write(b'JOB ') # 6 character message type
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
156 connection.write(packedData)
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
157
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
158 def __receive(self, lang):
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
159 """
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
160 Private method to receive the response from the clients.
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
161
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
162 @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
163 @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
164 @exception RuntimeError raised if hashes don't match
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
165 """
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
166 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
167 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
168 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
169 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
170 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
171
4221
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
172 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
173 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
174
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 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
176 while len(packedData) < length:
5875
3052fb9cf357 Some more speed adjustments for the background service.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5874
diff changeset
177 maxSize = length - len(packedData)
3052fb9cf357 Some more speed adjustments for the background service.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5874
diff changeset
178 if connection.bytesAvailable() < maxSize:
3052fb9cf357 Some more speed adjustments for the background service.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5874
diff changeset
179 connection.waitForReadyRead(50)
3052fb9cf357 Some more speed adjustments for the background service.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5874
diff changeset
180 packedData += connection.read(maxSize)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
181
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
182 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
183 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
184 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
185 # "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
186 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
187
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
188 if fx == 'INIT':
8264
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
189 if data != "ok":
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
190 E5MessageBox.critical(
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
191 None,
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
192 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
193 self.tr(
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
194 "<p>Initialization of Background Service"
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
195 " <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
196 .format(fn, data)
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
197 )
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
198 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
199 # 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
200 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
201 # 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
202 # 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
203 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
204 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
205 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
206 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
207 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
208 "<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
209 " 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
210 " 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
211 "<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
212 "<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
213 "<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
214 " 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
215 "<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
216 " 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
217 "<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
218 "</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
219 "<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
220 " 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
221 "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
222 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
223 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
224
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 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
226 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
227 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
228 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
229 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
230 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
231 "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
232 " 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
233 )
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
234 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
235 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
236 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
237 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
238 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
239 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
240 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
241 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
242 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
243 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
244 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
245 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
246 if callback:
5691
372ac1c1c228 Introduced some code to improve defensive programming in the BackgroundService class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
247 if isinstance(data, (list, tuple)):
372ac1c1c228 Introduced some code to improve defensive programming in the BackgroundService class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
248 callback[2](fn, *data)
372ac1c1c228 Introduced some code to improve defensive programming in the BackgroundService class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
249 elif isinstance(data, str):
372ac1c1c228 Introduced some code to improve defensive programming in the BackgroundService class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5616
diff changeset
250 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
251 if data == 'Unknown batch service.':
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
252 self.batchJobDone.emit(fx, lang)
f95dde35d0ab Background Service: added code to signal initialization errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
253 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
254 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
255 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
256 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
257 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
258 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
259 callback[2](fn, *data)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
260
3209
c5432abceb25 CodeStyleChecker moved to background service and done a little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3173
diff changeset
261 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
262 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
263
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
264 def preferencesOrProjectChanged(self):
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
265 """
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
266 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
267 """
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
268 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
269 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
270 "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
271 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
272 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
273
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
274 # 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
275 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
276 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
277
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7630
diff changeset
278 self.restartService('Python3')
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
279
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
280 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
281 """
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
282 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
283
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
284 @param language to restart
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
285 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
286 @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
287 @type bool
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
288 """
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
289 try:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
290 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
291 except KeyError:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
292 return
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
293
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
294 # 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
295 if not forceKill:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
296 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
297 QApplication.processEvents()
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
298
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
299 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
300 if conn:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
301 conn.blockSignals(True)
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
302 conn.close()
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
303 if proc:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
304 proc.close()
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
305
6367
7bc6fc02d981 Fixed a few bugs caused by using the new virtual environment manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6348
diff changeset
306 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
307 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
308 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
309 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
310 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
311
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
312 def enqueueRequest(self, fx, lang, fn, data):
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
313 """
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
314 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
315
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
316 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
317 starving of the services.
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
318
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
319 @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
320 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
321 @param lang language to connect to
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
322 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
323 @param fn filename for identification
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
324 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
325 @param data function argument(s)
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
326 @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
327 """
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
328 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
329 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
330 self.__queue.insert(0, args)
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
331 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
332 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
333 # 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
334 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
335 # 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
336 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
337 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
338 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
339 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
340 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
341
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
342 def requestCancel(self, fx, lang):
4221
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
343 """
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
344 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
345
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
346 @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
347 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
348 @param lang language to connect to
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
349 @type str
4221
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
350 """
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
351 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
352
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 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
354 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
355 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
356 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
357 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
358 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
359
4221
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
360 connection = self.connections.get(lang)
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
361 if connection is None:
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
362 return
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
363 else:
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
364 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
365 connection.write(header)
c9fdc07753a7 Implemented the Cancel logic for batch checks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4218
diff changeset
366 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
367
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
368 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
369 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
370 onErrorCallback=None, onBatchDone=None):
3159
02cb2adb4868 First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
371 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3581
diff changeset
372 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
373 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
374
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
375 @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
376 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
377 @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
378 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
379 @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
380 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
381 @param module name to import
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
382 @type str
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
383 @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
384 @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
385 @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
386 (function)
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
387 @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
388 @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
389 """
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
390 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
391 modulepath, module, callback, onErrorCallback
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
392 )
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
393 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
394 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
395 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
396 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
397 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
398
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
399 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
400 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3581
diff changeset
401 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
402
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
403 @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
404 @type function
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
405 @param lang language of the service
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
406 @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
407 """
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
408 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
409 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
410 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
411
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 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
413 """
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
414 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
415 """
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
416 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
417 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
418 return
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
419 lang = connection.read(64)
7192
a22eee00b052 Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
420 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
421 # 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
422 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
423 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
424 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
425 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
426 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
427 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
428 lambda x=lang: self.__receive(x))
3417
5a93c6cdc989 Exception handling for client side implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
429 connection.disconnected.connect(
5a93c6cdc989 Exception handling for client side implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
430 lambda x=lang: self.on_disconnectSocket(x))
5a93c6cdc989 Exception handling for client side implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
431
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3209
diff changeset
432 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
433 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
434 # 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
435 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
436
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
437 # 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
438 try:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
439 vm = e5App().getObject("ViewManager")
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
440 except KeyError:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
441 return
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
442 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
443 if editor.getLanguage() == lang:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
444 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
445
3417
5a93c6cdc989 Exception handling for client side implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
446 def on_disconnectSocket(self, lang):
5a93c6cdc989 Exception handling for client side implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
447 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3581
diff changeset
448 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
449
7965
48fbf9149d16 BackgroundService and -Client: fixed a few typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
450 @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
451 @type str
3417
5a93c6cdc989 Exception handling for client side implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
452 """
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
453 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
454 if conn:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
455 conn.close()
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
456 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
457 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
458 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
459 "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
460 " unknown reason.")
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
461 )
3417
5a93c6cdc989 Exception handling for client side implemented.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
462 self.isWorking = None
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
463
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
464 res = E5MessageBox.yesNo(
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
465 None,
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
466 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
467 self.tr(
4997
6dfb9119c85b Fixed a typo.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
468 '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
469 ' 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
470 ).format(lang),
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
471 yesDefault=True)
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
472 if res:
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
473 self.restartService(lang)
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
474
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
475 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
476 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3581
diff changeset
477 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
478 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
479 """
6321
f85288918089 BackgroundService: Little change to close the service when shutting down.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
480 self.close()
f85288918089 BackgroundService: Little change to close the service when shutting down.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6188
diff changeset
481
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
482 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
483 # 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
484 connection.blockSignals(True)
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3538
diff changeset
485 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
486
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
487 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
488 process.close()
7630
4010cc7e9c0b BackgroundService: improved the shutdown method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
489 if not process.waitForFinished(10000):
4010cc7e9c0b BackgroundService: improved the shutdown method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
490 process.kill()
3505
84e7cee47d10 Start the background client always as external process.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3484
diff changeset
491 process = None

eric ide

mercurial