Small optimizations, removing some redundant code and handling some edge cases with server projects.

This commit is contained in:
AccentuSoft
2022-02-04 05:37:18 +02:00
parent e113561cb1
commit 5fa1054bbf
5 changed files with 39 additions and 39 deletions

View File

@@ -248,11 +248,13 @@ class CommunicationsHandler(QtCore.QObject):
try:
if self.sock is not None:
self.sock.shutdown(socket.SHUT_RDWR)
self.sock.close()
self.sock = None
except OSError:
# This would typically occur if the socket is already closed.
pass
try:
self.sock.close()
finally:
self.sock = None
def scanIncoming(self):
"""
@@ -625,8 +627,11 @@ class CommunicationsHandler(QtCore.QObject):
:return:
"""
if status_code != 200:
self.status_message_signal.emit('Operation ' + operation + ' failed with status code ' +
str(status_code) + ': ' + message, True)
if status_code == 404 and message == 'No project with the specified name exists!':
self.close_project_signal.emit()
else:
self.status_message_signal.emit('Operation ' + operation + ' failed with status code ' +
str(status_code) + ': ' + message, True)
else:
if operation == 'Create Project':
# No need to do anything here. Creating a new project also opens it.

View File

@@ -178,33 +178,30 @@ class EntityList(QtWidgets.QTreeWidget):
"""
Handle dragging of entities onto canvas.
"""
# No, I have no idea why this is the case: v
if event.button() == QtGui.Qt.MouseButton.NoButton:
itemDragged = self.itemAt(event.pos())
itemDragged = self.itemAt(event.pos())
# Categories & entity names don't have uids.
try:
if itemDragged.uid is None:
return
except Exception:
# Categories & entity names don't have uids.
try:
if itemDragged.uid is None:
return
except Exception:
return
self.setCurrentItem(itemDragged)
drag = QtGui.QDrag(self)
mimeData = QtCore.QMimeData()
self.setCurrentItem(itemDragged)
drag = QtGui.QDrag(self)
mimeData = QtCore.QMimeData()
mimeData.setText(dumps({'uid': itemDragged.uid}))
drag.setMimeData(mimeData)
mimeData.setText(dumps({'uid': itemDragged.uid}))
drag.setMimeData(mimeData)
# All Entities should have icons, but you never know.
pixmap = None
if itemDragged.icon(0) is not None:
pixmap = itemDragged.icon(0).pixmap(40, 40)
drag.setPixmap(pixmap)
drag.setHotSpot(QtCore.QPoint(pixmap.rect().width() / 2, pixmap.rect().height() / 2))
drag.exec_()
else:
super().mouseMoveEvent(event)
# All Entities should have icons, but you never know.
pixmap = None
if itemDragged.icon(0) is not None:
pixmap = itemDragged.icon(0).pixmap(40, 40)
drag.setPixmap(pixmap)
drag.setHotSpot(QtCore.QPoint(pixmap.rect().width() // 2, pixmap.rect().height() // 2))
drag.exec_()
super().mouseMoveEvent(event)
def mousePressEvent(self, event: QtGui.QMouseEvent) -> None:
super(EntityList, self).mousePressEvent(event)
@@ -416,7 +413,7 @@ class NodeList(QtWidgets.QTreeWidget):
if itemDragged.icon(0) is not None:
pixmap = itemDragged.icon(0).pixmap(40, 40)
drag.setPixmap(pixmap)
drag.setHotSpot(QtCore.QPoint(pixmap.rect().width() / 2, pixmap.rect().height() / 2))
drag.setHotSpot(QtCore.QPoint(pixmap.rect().width() // 2, pixmap.rect().height() // 2))
drag.exec_()
else:
# This should never happen.

View File

@@ -120,14 +120,6 @@ class ToolBarOne(QtWidgets.QToolBar):
def addCanvas(self):
self.parent().addCanvas()
def configureProxySettings(self):
pass
###
def publishCanvas(self):
pass
###
def selectLeafNodes(self):
self.parent().selectLeafNodes()

View File

@@ -1206,10 +1206,11 @@ class MainWindow(QtWidgets.QMainWindow):
self.FCOM.sendFileAbortAll(project_name)
self.unSyncCanvasByName()
if server is not None:
statusMessage = "Closed Server project: " + str(project_name)
self.MESSAGEHANDLER.info(statusMessage)
self.setStatus(statusMessage)
self.dockbarThree.serverStatus.updateStatus("Connected to server: " + server)
if project_name != "":
statusMessage = "Closed Server project: " + str(project_name)
self.MESSAGEHANDLER.info(statusMessage)
self.setStatus(statusMessage)
self.dockbarOne.documentsList.updateFileListFromServer(None)
with self.syncedCanvasesLock:

View File

@@ -13,7 +13,12 @@ class Holehe_Account_Discovery:
description = "Find information about a persons social media accounts"
originTypes = {'Email Address'}
resultTypes = {'Email Address', 'Phone Number', 'Phrase', 'Date', 'Domain'}
parameters = {'Use Password Recovery Methods': {'description': 'TODO',
parameters = {'Use Password Recovery Methods': {'description': 'This option dictates whether the module checks '
'for the existence for an account in services where '
'the way to determine if an account was registered '
'is to attempt password recovery. This may, in '
'certain cases, have a chance of alerting the '
'owner of the account.',
'type': 'SingleChoice',
'value': {'Yes', 'No'}
}}