Skip to content

Commit

Permalink
Remove unecessary constants from Constants.py
Browse files Browse the repository at this point in the history
USER_CONFIRM_RESTART and USER_INTERACTION_PERMISSIONS are only used internally on a single class each, there's no point in making them global gui constants.
  • Loading branch information
DiegoTavares committed Aug 20, 2024
1 parent 4bb1e0c commit 59c6a14
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 40 deletions.
2 changes: 0 additions & 2 deletions cuegui/cuegui/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ def __packaged_version():
EMAIL_BODY_PREFIX = __config.get('email.body_prefix')
EMAIL_BODY_SUFFIX = __config.get('email.body_suffix')
EMAIL_DOMAIN = __config.get('email.domain')
USER_CONFIRM_RESTART = "You must restart for this action to take effect, close window?: "
USER_INTERACTION_PERMISSIONS = "You do not have permissions to {0} {1} owned by {2}"

GITHUB_CREATE_ISSUE_URL = __config.get('links.issue.create')
URL_USERGUIDE = __config.get('links.user_guide')
Expand Down
7 changes: 5 additions & 2 deletions cuegui/cuegui/MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
class MainWindow(QtWidgets.QMainWindow):
"""The main window of the application. Multiple windows may exist."""

# Message to be displayed when a change requires an application restart
USER_CONFIRM_RESTART = "You must restart for this action to take effect, close window?: "

windows = []
windows_names = []
windows_titles = {}
Expand Down Expand Up @@ -469,7 +472,7 @@ def __revertLayout(self):
result = QtWidgets.QMessageBox.question(
self,
"Restart required ",
cuegui.Constants.USER_CONFIRM_RESTART,
MainWindow.USER_CONFIRM_RESTART,
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)

if result == QtWidgets.QMessageBox.Yes:
Expand All @@ -481,7 +484,7 @@ def __enableJobInteraction(self):
result = QtWidgets.QMessageBox.question(
self,
"Job Interaction Settings ",
cuegui.Constants.USER_CONFIRM_RESTART,
MainWindow.USER_CONFIRM_RESTART,
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)

if result == QtWidgets.QMessageBox.Yes:
Expand Down
75 changes: 39 additions & 36 deletions cuegui/cuegui/MenuActions.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ def getText(self, title, body, default):
class JobActions(AbstractActions):
"""Actions for jobs."""

# Template for permission alert messages
USER_INTERACTION_PERMISSIONS = "You do not have permissions to {0} {1} owned by {2}"

def __init__(self, *args):
AbstractActions.__init__(self, *args)

Expand Down Expand Up @@ -384,9 +387,9 @@ def kill(self, rpcObjects=None):
for job in jobs:
# check permissions
if not cuegui.Utils.isPermissible(job):
msg = cuegui.Constants.USER_INTERACTION_PERMISSIONS.format("kill",
"job(s)",
job.username())
msg = JobActions.USER_INTERACTION_PERMISSIONS.format("kill",
"job(s)",
job.username())
cuegui.Utils.showErrorMessageBox(msg)
else:
job.kill(reason=DEFAULT_JOB_KILL_REASON)
Expand Down Expand Up @@ -465,9 +468,9 @@ def eatDead(self, rpcObjects=None):
for job in jobs:
# check permissions
if not cuegui.Utils.isPermissible(job):
msg = cuegui.Constants.USER_INTERACTION_PERMISSIONS.format("eat dead",
"job",
job.username())
msg = JobActions.USER_INTERACTION_PERMISSIONS.format("eat dead",
"job",
job.username())
cuegui.Utils.showErrorMessageBox(msg)
else:
job.eatFrames(state=[opencue.compiled_proto.job_pb2.DEAD])
Expand Down Expand Up @@ -503,9 +506,9 @@ def retryDead(self, rpcObjects=None):
[job.data.name for job in jobs]):
for job in jobs:
if not cuegui.Utils.isPermissible(job):
msg = cuegui.Constants.USER_INTERACTION_PERMISSIONS.format("retry dead",
"job",
job.username())
msg = JobActions.USER_INTERACTION_PERMISSIONS.format("retry dead",
"job",
job.username())
cuegui.showErrorMessageBox(msg)
else:
job.retryFrames(
Expand Down Expand Up @@ -804,9 +807,9 @@ def kill(self, rpcObjects=None):
if layers:
#check permissions
if not cuegui.Utils.isPermissible(self._getSource()):
msg = cuegui.Constants.USER_INTERACTION_PERMISSIONS.format("kill",
"layers",
self._getSource().username())
msg = JobActions.USER_INTERACTION_PERMISSIONS.format("kill",
"layers",
self._getSource().username())
cuegui.Utils.showErrorMessageBox(msg)
else:
if cuegui.Utils.questionBoxYesNo(self._caller, "Confirm",
Expand All @@ -822,9 +825,9 @@ def eat(self, rpcObjects=None):
layers = self._getOnlyLayerObjects(rpcObjects)
if layers:
if not cuegui.Utils.isPermissible(self._getSource()):
msg = cuegui.Constants.USER_INTERACTION_PERMISSIONS.format("eat",
"layers",
self._getSource().username())
msg = JobActions.USER_INTERACTION_PERMISSIONS.format("eat",
"layers",
self._getSource().username())
cuegui.Utils.showErrorMessageBox(msg)
else:
if cuegui.Utils.questionBoxYesNo(self._caller, "Confirm",
Expand All @@ -840,9 +843,9 @@ def retry(self, rpcObjects=None):
layers = self._getOnlyLayerObjects(rpcObjects)
if layers:
if not cuegui.Utils.isPermissible(self._getSource()):
msg = cuegui.Constants.USER_INTERACTION_PERMISSIONS.format("retry",
"layers",
self._getSource().username())
msg = JobActions.USER_INTERACTION_PERMISSIONS.format("retry",
"layers",
self._getSource().username())
cuegui.Utils.showErrorMessageBox(msg)
else:
if cuegui.Utils.questionBoxYesNo(self._caller, "Confirm",
Expand All @@ -858,9 +861,9 @@ def retryDead(self, rpcObjects=None):
layers = self._getOnlyLayerObjects(rpcObjects)
if layers:
if not cuegui.Utils.isPermissible(self._getSource()):
msg = cuegui.Constants.USER_INTERACTION_PERMISSIONS.format("retry dead",
"layers",
self._getSource().username())
msg = JobActions.USER_INTERACTION_PERMISSIONS.format("retry dead",
"layers",
self._getSource().username())
cuegui.Utils.showErrorMessageBox(msg)
else:
if cuegui.Utils.questionBoxYesNo(self._caller, "Confirm",
Expand Down Expand Up @@ -1093,9 +1096,9 @@ def retry(self, rpcObjects=None):
job = self._getSource()
# check permissions
if not cuegui.Utils.isPermissible(job):
msg = cuegui.Constants.USER_INTERACTION_PERMISSIONS.format("retry",
"frames",
job.username())
msg = JobActions.USER_INTERACTION_PERMISSIONS.format("retry",
"frames",
job.username())
cuegui.Utils.showErrorMessageBox(msg)
else:
if cuegui.Utils.questionBoxYesNo(
Expand Down Expand Up @@ -1138,9 +1141,9 @@ def eat(self, rpcObjects=None):
#check permissions
print(self._getSource())
if not cuegui.Utils.isPermissible(self._getSource()):
msg = cuegui.Constants.USER_INTERACTION_PERMISSIONS.format("eat",
"frames",
self._getSource().username())
msg = JobActions.USER_INTERACTION_PERMISSIONS.format("eat",
"frames",
self._getSource().username())
cuegui.Utils.showErrorMessageBox(msg)
else:
if cuegui.Utils.questionBoxYesNo(self._caller, "Confirm",
Expand All @@ -1155,9 +1158,9 @@ def kill(self, rpcObjects=None):
names = [frame.data.name for frame in self._getOnlyFrameObjects(rpcObjects)]
if names:
if not cuegui.Utils.isPermissible(self._getSource(), self):
msg = cuegui.Constants.USER_INTERACTION_PERMISSIONS.format("kill",
"frames",
self._getSource().username())
msg = JobActions.USER_INTERACTION_PERMISSIONS.format("kill",
"frames",
self._getSource().username())
cuegui.Utils.showErrorMessageBox(msg)
else:
if cuegui.Utils.questionBoxYesNo(self._caller, "Confirm",
Expand Down Expand Up @@ -1271,9 +1274,9 @@ def eatandmarkdone(self, rpcObjects=None):
frameNames = [frame.data.name for frame in frames]
#check permissions
if not cuegui.Utils.isPermissible(self._getSource(), self):
msg = cuegui.Constants.USER_INTERACTION_PERMISSIONS.format("eat and mark done",
"frames",
self._getSource().username())
msg = JobActions.USER_INTERACTION_PERMISSIONS.format("eat and mark done",
"frames",
self._getSource().username())
cuegui.Utils.showErrorMessageBox(msg)
else:
if cuegui.Utils.questionBoxYesNo(
Expand Down Expand Up @@ -1750,9 +1753,9 @@ def kill(self, rpcObjects=None):
if procs:
print(self._getSource())
if not cuegui.Utils.isPermissible(self._getSource(), self):
msg = cuegui.Constants.USER_INTERACTION_PERMISSIONS.format("eat and mark done",
"frames",
self._getSource().username())
msg = JobActions.USER_INTERACTION_PERMISSIONS.format("eat and mark done",
"frames",
self._getSource().username())
cuegui.Utils.showErrorMessageBox(msg)
else:
if cuegui.Utils.questionBoxYesNo(
Expand Down

0 comments on commit 59c6a14

Please sign in to comment.