src/eric7/RemoteServerInterface/EricServerCoverageInterface.py

Fri, 16 Feb 2024 09:32:27 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 16 Feb 2024 09:32:27 +0100
branch
server
changeset 10575
abde60847db6
parent 10574
622e59b51640
child 10577
b9edebd77c91
permissions
-rw-r--r--

Adapted the editors 'Show coverage annotations' functionality to the eric-ide server.

10574
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2024 Detlev Offenbach <detlev@die-offenbachs.de>
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the code coverage interface to the eric-ide server.
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import contextlib
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt6.QtCore import QEventLoop, QObject
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from eric7.RemoteServer.EricRequestCategory import EricRequestCategory
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from eric7.SystemUtilities import FileSystemUtilities
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 class EricServerCoverageError(Exception):
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Class defining a substitute exception for coverage errors of the server.
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 pass
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 class EricServerCoverageInterface(QObject):
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 Class implementing the code coverage interface to the eric-ide server.
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 def __init__(self, serverInterface):
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 Constructor
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @param serverInterface reference to the eric-ide server interface
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 @type EricServerInterface
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 super().__init__(parent=serverInterface)
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.__serverInterface = serverInterface
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
10575
abde60847db6 Adapted the editors 'Show coverage annotations' functionality to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10574
diff changeset
42 def loadCoverageData(self, dataFile, excludePattern=""):
10574
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 Public method to tell the server to load the coverage data for a later analysis.
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 @param dataFile name of the data file to be loaded
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 @type str
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 @param excludePattern regular expression determining files to be excluded
10575
abde60847db6 Adapted the editors 'Show coverage annotations' functionality to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10574
diff changeset
49 (defaults to "")
abde60847db6 Adapted the editors 'Show coverage annotations' functionality to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10574
diff changeset
50 @type str (optional)
10574
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 @return tuple containing a success flag and an error message
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 @rtype tuple of (bool, str)
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 loop = QEventLoop()
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 ok = False
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 error = ""
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 def callback(reply, params):
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 Function to handle the server reply
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 @param reply name of the server reply
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 @type str
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 @param params dictionary containing the reply data
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 @type dict
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 nonlocal ok, error
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 if reply == "LoadData":
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 ok = params["ok"]
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 with contextlib.suppress(KeyError):
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 error = params["error"]
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 loop.quit()
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.__serverInterface.sendJson(
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 category=EricRequestCategory.Coverage,
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 request="LoadData",
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 params={
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 "data_file": FileSystemUtilities.plainFileName(dataFile),
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 "exclude": excludePattern,
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 },
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 callback=callback,
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 )
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 loop.exec()
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 return ok, error
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 def analyzeFile(self, filename):
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 Public method to analyze the code coverage of one file.
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 @param filename name of the file to be analyzed
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 @type str
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 @return list containing coverage result as reported by Coverage.analysis2()
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 @rtype list of [str, list of int, list of int, list of int, str]
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 @exception EricServerCoverageException raised to indicate a coverage exception
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 loop = QEventLoop()
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 ok = False
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 error = ""
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 result = None
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 def callback(reply, params):
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 Function to handle the server reply
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 @param reply name of the server reply
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 @type str
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 @param params dictionary containing the reply data
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 @type dict
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 nonlocal ok, error, result
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 if reply == "AnalyzeFile":
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 ok = params["ok"]
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 if ok:
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 result = params["result"]
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 else:
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 error = params["error"]
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 loop.quit()
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 self.__serverInterface.sendJson(
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 category=EricRequestCategory.Coverage,
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 request="AnalyzeFile",
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 params={"filename": FileSystemUtilities.plainFileName(filename)},
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 callback=callback,
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 )
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 loop.exec()
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 if not ok:
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 raise EricServerCoverageError(error)
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 return result
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 def analyzeFiles(self, filenames):
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 Public method to analyze the code coverage of a list of files.
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 @param filenames list of file names to be analyzed
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 @type str
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 @return lists containing coverage results as reported by Coverage.analysis2()
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 @rtype list of [list of [str, list of int, list of int, list of int, str]]
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 @exception EricServerCoverageException raised to indicate a coverage exception
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 loop = QEventLoop()
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 ok = False
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 error = ""
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 result = None
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 def callback(reply, params):
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 Function to handle the server reply
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 @param reply name of the server reply
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 @type str
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 @param params dictionary containing the reply data
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 @type dict
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 nonlocal ok, error, result
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 if reply == "AnalyzeFiles":
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 ok = params["ok"]
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 if ok:
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 result = params["results"]
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 else:
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 error = params["error"]
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 loop.quit()
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 self.__serverInterface.sendJson(
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 category=EricRequestCategory.Coverage,
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 request="AnalyzeFiles",
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 params={
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 "filenames": [FileSystemUtilities.plainFileName(f) for f in filenames]
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 },
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 callback=callback,
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 )
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 loop.exec()
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 if not ok:
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 raise EricServerCoverageError(error)
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 return result
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 def analyzeDirectory(self, directory):
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 Public method to analyze the code coverage of a directory.
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 @param directory directory name to be analyzed
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 @type str
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 @return lists containing coverage results as reported by Coverage.analysis2()
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 @rtype list of [list of [str, list of int, list of int, list of int, str]]
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 @exception EricServerCoverageException raised to indicate a coverage exception
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 loop = QEventLoop()
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 ok = False
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 error = ""
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 result = None
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 def callback(reply, params):
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 Function to handle the server reply
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 @param reply name of the server reply
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 @type str
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 @param params dictionary containing the reply data
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 @type dict
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 """
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 nonlocal ok, error, result
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 if reply == "AnalyzeDirectory":
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 ok = params["ok"]
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 if ok:
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 result = params["results"]
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 else:
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 error = params["error"]
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 loop.quit()
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 self.__serverInterface.sendJson(
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 category=EricRequestCategory.Coverage,
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 request="AnalyzeDirectory",
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 params={"directory": FileSystemUtilities.plainFileName(directory)},
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 callback=callback,
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 )
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 loop.exec()
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 if not ok:
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 raise EricServerCoverageError(error)
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228
622e59b51640 Implemented the profiling and code coverage interface of the dialogs to the eric-ide server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 return result

eric ide

mercurial