Skip to content

Commit 19b0883

Browse files
authored
Fix python3 related issues on Redirect plugin (#1631)
- Qt's QCompleter expects a list as input and an iterable was being provided. - The call to `proc.getJob` can raise an Exception if no result is found. The previously untreated exception would halt the procs loop and prevent the full list from being processed - Another occurence of QCompleter was also altered to ensure a list and not an iterable is passed
1 parent 97e5d3f commit 19b0883

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

cuegui/cuegui/Redirect.py

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def refresh(self):
152152
slist = opencue.api.getJobNames()
153153
slist.sort()
154154

155-
self.__c = QtWidgets.QCompleter(slist, self)
155+
self.__c = QtWidgets.QCompleter(list(slist), self)
156156
self.__c.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
157157
self.setCompleter(self.__c)
158158

@@ -411,7 +411,7 @@ class RedirectWidget(QtWidgets.QWidget):
411411
"""
412412

413413
HEADERS = ["Name", "Cores", "Memory", "PrcTime", "Group", "Service",
414-
"Job Cores", "Pending", "LLU", "Log"]
414+
"Job Cores", "Waiting Frames", "LLU", "Log"]
415415

416416
def __init__(self, parent=None):
417417
QtWidgets.QWidget.__init__(self, parent)
@@ -604,7 +604,7 @@ def __isBurstSafe(self, alloc, procs, show):
604604
@classmethod
605605
def __isAllowed(cls, procs, targetJob):
606606
"""Checks if the follow criteria are met to allow redirect to target job:
607-
- if source/target job have pending frames
607+
- if source/target job have waiting frames
608608
- if target job hasn't reached maximum cores
609609
- check if adding frames will push target job over it's max cores
610610
@@ -626,18 +626,18 @@ def __isAllowed(cls, procs, targetJob):
626626
targetJob.coresReserved(),
627627
targetJob.maxCores())
628628

629-
# Case 2: 1. Check target job for pending frames
630-
# 2. Check source procs for pending frames
629+
# Case 2: 1. Check target job for waiting frames
630+
# 2. Check source procs for waiting frames
631631
if allowed and targetJob.waitingFrames() <= 0:
632632
allowed = False
633-
errMsg = "Target job %s has no pending (waiting) frames" % targetJob.name()
633+
errMsg = "Target job %s has no waiting frames" % targetJob.name()
634634

635635
if allowed:
636636
for proc in procs:
637637
job = proc.getJob()
638638
if job.waitingFrames() <= 0:
639639
allowed = False
640-
errMsg = "Source job %s has no pending (waiting) frames" % job.name()
640+
errMsg = "Source job %s has no waiting frames" % job.name()
641641
break
642642

643643
# Case 3: Check if each proc or summed up procs will
@@ -808,21 +808,26 @@ def update(self):
808808
if proc.data.group_name not in groupFilter:
809809
continue
810810

811-
name = proc.data.name.split("/")[0]
812-
lluTime = cuegui.Utils.getLLU(proc)
813-
job = proc.getJob()
814-
logLines = cuegui.Utils.getLastLine(proc.data.log_path) or ""
815-
816-
if name not in hosts:
817-
cue_host = opencue.api.findHost(name)
818-
hosts[name] = {
819-
"host": cue_host,
820-
"procs": [],
821-
"mem": cue_host.data.idle_memory,
822-
"cores": int(cue_host.data.idle_cores),
823-
"time": 0,
824-
"ok": False,
825-
'alloc': cue_host.data.alloc_name}
811+
# pylint: disable=broad-except
812+
try:
813+
name = proc.data.name.split("/")[0]
814+
lluTime = cuegui.Utils.getLLU(proc)
815+
job = proc.getJob()
816+
logLines = cuegui.Utils.getLastLine(proc.data.log_path) or ""
817+
818+
if name not in hosts:
819+
cue_host = opencue.api.findHost(name)
820+
hosts[name] = {
821+
"host": cue_host,
822+
"procs": [],
823+
"mem": cue_host.data.idle_memory,
824+
"cores": int(cue_host.data.idle_cores),
825+
"time": 0,
826+
"ok": False,
827+
'alloc': cue_host.data.alloc_name}
828+
except Exception:
829+
# Ignore dangling procs (not bound to a job through a VirtualProc)
830+
continue
826831

827832
host = hosts[name]
828833
if host["ok"]:
@@ -835,7 +840,7 @@ def update(self):
835840
host["llu"] = cuegui.Utils.numFormat(lluTime, "t")
836841
host["log"] = logLines
837842
host['job_cores'] = job.data.job_stats.reserved_cores
838-
host['waiting'] = job.pendingFrames() or 0
843+
host['waiting'] = job.waitingFrames() or 0
839844

840845
if host["cores"] >= self.__controls.getCores() and \
841846
host["cores"] <= self.__controls.getMaxCores() and \

cuegui/cuegui/plugins/StuckFramePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ def refresh(self):
563563
"""Refreshes the show list."""
564564
slist = opencue.api.getDefaultServices()
565565
slist.sort(key=lambda s: s.name())
566-
self.__c = QtWidgets.QCompleter(slist, self)
566+
self.__c = QtWidgets.QCompleter(list(slist), self)
567567
self.__c.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
568568
self.setCompleter(self.__c)
569569

0 commit comments

Comments
 (0)