Fix bugs with Collectors not stopping & not recognizing '*' origin types properly.

This commit is contained in:
AccentuSoft
2022-05-26 00:02:24 +03:00
parent 01fa05f922
commit e6af83b602
2 changed files with 13 additions and 1 deletions

View File

@@ -1845,6 +1845,7 @@ class CollectorsDialog(QtWidgets.QDialog):
currentClientCollectors = self.mainWindow.getClientCollectors()
try:
currentClientCollectors.pop(collectorToStop)
self.mainWindow.stopRunningCollector(collectorToStop)
self.mainWindow.setClientCollectors(currentClientCollectors)
except KeyError:
self.mainWindow.MESSAGEHANDLER.error('Trying to stop Collector that was never ran. Was confirmation that '
@@ -1892,7 +1893,7 @@ class CollectorStartDialog(QtWidgets.QDialog):
self.entitySelector.header().setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch)
relevantEntityFields = [(entity['uid'], entity[list(entity)[1]], entity['Entity Type'], entity['Icon'])
for entity in entityDB.getAllEntities()
if entity['Entity Type'] in originTypes or originTypes == '*']
if entity['Entity Type'] in originTypes or '*' in originTypes]
for eligibleEntity in relevantEntityFields:
newTreeWidgetItem = QtWidgets.QTreeWidgetItem(self.entitySelector)
newTreeWidgetItemPixmap = QtGui.QPixmap()

View File

@@ -1296,6 +1296,17 @@ class MainWindow(QtWidgets.QMainWindow):
currentCollectors[collector_uid] = time.time_ns() // 1000
self.setClientCollectors(currentCollectors)
def stopRunningCollector(self, collectorUID: str):
"""
Stops collector. Need to be ran before setClientCollectors.
"""
with self.serverCollectorsLock:
for collectorCategory in self.runningCollectors:
for collectorName in self.runningCollectors[collectorCategory]:
for collector in self.runningCollectors[collectorCategory][collectorName]:
if collector['uid'] == collectorUID:
self.runningCollectors[collectorCategory][collectorName].remove(collector)
def receiveProjectsListListener(self, projects: list) -> None:
with self.serverProjectsLock:
self.serverProjects = projects