Browse Source

Remove functionality to force lock-lift

master
Nils 7 months ago
parent
commit
da75e05100
  1. 4
      engine/api.py
  2. 3
      engine/findprograms.py
  3. 16
      engine/nsmservercontrol.py
  4. 5
      qtgui/designer/mainwindow.py
  5. 10
      qtgui/designer/mainwindow.ui
  6. 7
      qtgui/sessiontreecontroller.py

4
engine/api.py

@ -330,10 +330,6 @@ def sessionQuery(nsmSessionName:str):
Exports a single session project in the format of nsmServerControl.exportSessionsAsDicts"""
return nsmServerControl.sessionAsDict(nsmSessionName)
def sessionForceLiftLock(nsmSessionName:str):
nsmServerControl.forceLiftLock(nsmSessionName)
callbacks._sessionLocked(nsmSessionName, False)
def sessionDelete(nsmSessionName:str):
nsmServerControl.deleteSession(nsmSessionName)

3
engine/findprograms.py

@ -121,12 +121,15 @@ class SupportedProgramsDatabase(object):
#command = f"grep -iRsnl {path} -e /nsm/server/announce"
#Py>=3.7 completedProcess = subprocess.run(command, capture_output=True, text=True, shell=True)
"""
#Look into executable files. Slow and didn't bring up any new programs. Better to keep the database up to date ourselves.
completedProcess = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, shell=True) #universal_newlines is an alias for text, which was deprecated in 3.7 because text is more understandable. capture_output replaces the two PIPEs in 3.7
for fullPath in completedProcess.stdout.split():
self.progressHook(f"{fullPath}")
exe = pathlib.Path(fullPath).relative_to(path)
if not str(exe) in excludeFromProcessingSet: #skip over any known file, good or bad
result.append((str(exe), str(fullPath)))
"""
for prg in whiteSet:
self.progressHook(f"{prg}")

16
engine/nsmservercontrol.py

@ -1419,21 +1419,6 @@ class NsmServerControl(object):
lockFile = pathlib.Path(basePath, ".lock")
return lockFile.exists()
def forceLiftLock(self, nsmSessionName:str):
"""Removes lockfile, no matter if session is actually open or just a remainder
from a crash.
If no lock exist it does nothing."""
self._updateSessionListBlocking()
if self._checkIfLocked(nsmSessionName):
basePath = pathlib.Path(self.sessionRoot, nsmSessionName)
assert basePath.exists() #implied by _checkIfLocked
lockFile = pathlib.Path(basePath, ".lock")
lockFile.unlink(missing_ok=True)
logger.info(f"{nsmSessionName} was forced to unlock by us.")
else:
logger.info(f"Tried to unlock, but {nsmSessionName} is not locked")
def getSessionFiles(self, nsmSessionName:str)->list:
"""Return all session files, useful to present to the user, e.g. as warning
before deletion"""
@ -1566,7 +1551,6 @@ class NsmServerControl(object):
else:
mycopy()
self.forceLiftLock(newName)
except Exception as e: #we don't want to crash if user tries to copy to /root or so.
logger.error(e)
return False

5
qtgui/designer/mainwindow.py

@ -91,10 +91,6 @@ class Ui_MainWindow(object):
self.button_delete_selected_session.setEnabled(False)
self.button_delete_selected_session.setObjectName("button_delete_selected_session")
self.verticalLayout_3.addWidget(self.button_delete_selected_session)
self.button_remove_lock_selected_session = QtWidgets.QPushButton(self.widget)
self.button_remove_lock_selected_session.setEnabled(False)
self.button_remove_lock_selected_session.setObjectName("button_remove_lock_selected_session")
self.verticalLayout_3.addWidget(self.button_remove_lock_selected_session)
self.checkBoxNested = QtWidgets.QCheckBox(self.widget)
self.checkBoxNested.setChecked(True)
self.checkBoxNested.setObjectName("checkBoxNested")
@ -324,7 +320,6 @@ class Ui_MainWindow(object):
self.button_rename_selected_session.setText(_translate("MainWindow", "Rename Selected"))
self.button_copy_selected_session.setText(_translate("MainWindow", "Copy Selected"))
self.button_delete_selected_session.setText(_translate("MainWindow", "Delete Selected"))
self.button_remove_lock_selected_session.setText(_translate("MainWindow", "Remove Lock"))
self.checkBoxNested.setText(_translate("MainWindow", "Tree View"))
self.session_programs.setTitle(_translate("MainWindow", "Double-click to load program"))
self.session_loaded.setTitle(_translate("MainWindow", "In current session"))

10
qtgui/designer/mainwindow.ui

@ -193,16 +193,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_remove_lock_selected_session">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Remove Lock</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxNested">
<property name="text">

7
qtgui/sessiontreecontroller.py

@ -184,7 +184,6 @@ class SessionTreeController(object):
self.mainWindow.ui.button_copy_selected_session.clicked.connect(lambda: self._askForCopyAndCopy(self.treeWidget.currentItem().sessionDict["nsmSessionName"]))
self.mainWindow.ui.button_rename_selected_session.clicked.connect(lambda: self._askForNameAndRenameSession(self.treeWidget.currentItem().sessionDict["nsmSessionName"]))
self.mainWindow.ui.button_delete_selected_session.clicked.connect(lambda: self.deleteSessionItem(self.treeWidget.currentItem()))
self.mainWindow.ui.button_remove_lock_selected_session.clicked.connect(lambda: api.sessionForceLiftLock(self.treeWidget.currentItem().sessionDict["nsmSessionName"]))
logger.info("Full View Session Chooser ready")
@ -283,9 +282,7 @@ class SessionTreeController(object):
listOfLabelsAndFunctions = [
(QtCore.QCoreApplication.translate("SessionTree", "Copy Session"), lambda: self._askForCopyAndCopy(item.sessionDict["nsmSessionName"]))
]
if item.isDisabled():
listOfLabelsAndFunctions.append((QtCore.QCoreApplication.translate("SessionTree", "Force Lock Removal"), lambda: api.sessionForceLiftLock(item.sessionDict["nsmSessionName"])))
else:
if not item.isDisabled():
listOfLabelsAndFunctions.append((QtCore.QCoreApplication.translate("SessionTree", "Rename Session"), lambda: self._askForNameAndRenameSession(item.sessionDict["nsmSessionName"])))
#Delete should be the bottom item.
listOfLabelsAndFunctions.append((QtCore.QCoreApplication.translate("SessionTree", "Delete Session"), lambda: self.deleteSessionItem(item)))
@ -323,7 +320,6 @@ class SessionTreeController(object):
self.mainWindow.ui.button_copy_selected_session.setEnabled(sessionSelectedState)
self.mainWindow.ui.button_rename_selected_session.setEnabled(sessionSelectedState)
self.mainWindow.ui.button_delete_selected_session.setEnabled(sessionSelectedState)
self.mainWindow.ui.button_remove_lock_selected_session.setEnabled(sessionSelectedState and item.sessionDict["locked"] == True)
def _reactSignal_itemDoubleClicked(self, item:QtWidgets.QTreeWidgetItem, column:int):
if not item.isDisabled() and type(item) is SessionItem:
@ -385,4 +381,3 @@ class SessionTreeController(object):
if self._cachedSessionDicts: #not startup
self._reactCallback_sessionsChanged(self._cachedSessionDicts)
self.treeWidget.sortItems(self.sortByColumnValue, self.sortDescendingValue)

Loading…
Cancel
Save