20 QMenu, |
20 QMenu, |
21 QTreeWidgetItem, |
21 QTreeWidgetItem, |
22 ) |
22 ) |
23 |
23 |
24 from eric7.EricWidgets import EricMessageBox |
24 from eric7.EricWidgets import EricMessageBox |
25 from eric7.SystemUtilities import PythonUtilities |
25 from eric7.EricWidgets.EricApplication import ericApp |
|
26 from eric7.SystemUtilities import FileSystemUtilities, PythonUtilities |
26 |
27 |
27 from .Ui_PyProfileDialog import Ui_PyProfileDialog |
28 from .Ui_PyProfileDialog import Ui_PyProfileDialog |
28 |
29 |
29 |
30 |
30 class ProfileTreeWidgetItem(QTreeWidgetItem): |
31 class ProfileTreeWidgetItem(QTreeWidgetItem): |
101 self.__menu.addAction(self.tr("Erase All Infos"), self.__eraseAll) |
102 self.__menu.addAction(self.tr("Erase All Infos"), self.__eraseAll) |
102 self.resultList.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) |
103 self.resultList.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) |
103 self.resultList.customContextMenuRequested.connect(self.__showContextMenu) |
104 self.resultList.customContextMenuRequested.connect(self.__showContextMenu) |
104 self.summaryList.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) |
105 self.summaryList.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) |
105 self.summaryList.customContextMenuRequested.connect(self.__showContextMenu) |
106 self.summaryList.customContextMenuRequested.connect(self.__showContextMenu) |
|
107 |
|
108 # eric-ide server interface |
|
109 self.__serverFsInterface = ericApp().getObject( |
|
110 "EricServer" |
|
111 ).getServiceInterface("FileSystem") |
106 |
112 |
107 def __createResultItem( |
113 def __createResultItem( |
108 self, |
114 self, |
109 calls, |
115 calls, |
110 totalTime, |
116 totalTime, |
263 @type str |
269 @type str |
264 """ |
270 """ |
265 self.basename = os.path.splitext(pfn)[0] |
271 self.basename = os.path.splitext(pfn)[0] |
266 |
272 |
267 fname = "{0}.profile".format(self.basename) |
273 fname = "{0}.profile".format(self.basename) |
268 if not os.path.exists(fname): |
274 if ( |
|
275 ( |
|
276 FileSystemUtilities.isRemoteFileName(fname) |
|
277 and not self.__serverFsInterface.exists(fname) |
|
278 ) |
|
279 or ( |
|
280 FileSystemUtilities.isPlainFileName(fname) |
|
281 and not os.path.exists(fname) |
|
282 ) |
|
283 ): |
269 EricMessageBox.warning( |
284 EricMessageBox.warning( |
270 self, |
285 self, |
271 self.tr("Profile Results"), |
286 self.tr("Profile Results"), |
272 self.tr( |
287 self.tr( |
273 """<p>There is no profiling data""" |
288 """<p>There is no profiling data""" |
275 ).format(pfn), |
290 ).format(pfn), |
276 ) |
291 ) |
277 self.close() |
292 self.close() |
278 return |
293 return |
279 try: |
294 try: |
280 with open(fname, "rb") as f: |
295 if FileSystemUtilities.isRemoteFileName(fname): |
281 self.stats = pickle.load(f) # secok |
296 data = self.__serverFsInterface.readFile(fname) |
|
297 self.stats = pickle.loads(data) |
|
298 else: |
|
299 with open(fname, "rb") as f: |
|
300 self.stats = pickle.load(f) # secok |
282 except (EOFError, OSError, pickle.PickleError): |
301 except (EOFError, OSError, pickle.PickleError): |
283 EricMessageBox.critical( |
302 EricMessageBox.critical( |
284 self, |
303 self, |
285 self.tr("Loading Profiling Data"), |
304 self.tr("Loading Profiling Data"), |
286 self.tr( |
305 self.tr( |