Skip to content

Commit

Permalink
Fix Pylint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
roulaoregan-spi committed Mar 30, 2022
1 parent dafb431 commit dd4d6ba
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
18 changes: 9 additions & 9 deletions cuegui/cuegui/Redirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

logger = cuegui.Logger.getLogger(__file__)

MEMORY_PATTERN = re.compile("\d+(?:TB|GB|MB|KB)")
MEMORY_PATTERN = re.compile("[0-9]+(?:TB|GB|MB|KB)")
MEMORY_BTYPE = "TB|GB|MB|KB"


Expand Down Expand Up @@ -463,7 +463,7 @@ def mouseDoubleClickEvent(self, index):
if jobObject:
if cuegui.Utils.isJob(jobObject[0]):
QtGui.qApp.view_object.emit(jobObject[0])
except Exception as e:
except opencue.exception.CueException as e:
text = ('Not able to add job to Job Monitor Tree. '
'Error Message:\n %s' % e)
self.__warn(text)
Expand Down Expand Up @@ -565,7 +565,7 @@ def __isBurstSafe(self, alloc, procs, show):
return True

showObj = opencue.api.findShow(show)
stripShowRegex = '\.%s' % show
stripShowRegex = '\\.%s' % show
showSubs = dict((re.sub(stripShowRegex, "", s.data.name), s)
for s in showObj.getSubscriptions()
if s.data.allocation_name in alloc)
Expand Down Expand Up @@ -597,7 +597,8 @@ def __isBurstSafe(self, alloc, procs, show):
% (alloc, show, show, alloc))
return False

def __isAllowed(self, procs, targetJob):
@classmethod
def __isAllowed(cls, procs, targetJob):
"""Checks if the follow criteria are met to allow redirect to target job:
- if source/target job have pending frames
- if target job hasn't reached maximum cores
Expand Down Expand Up @@ -709,7 +710,7 @@ def redirect(self):
if not allowed:
warning = errMsg
break
except Exception as e:
except opencue.exception.CueException as e:
warning = str(e)

if warning:
Expand Down Expand Up @@ -754,6 +755,7 @@ def clearTarget(self):
self.__controls.getJobBox().clear()

def update(self):
""" Update the model """
self.__model.clear()
self.__model.setHorizontalHeaderLabels(RedirectWidget.HEADERS)

Expand Down Expand Up @@ -845,6 +847,7 @@ def update(self):
self.__hosts = hosts

def __addHost(self, entry):
""" Add Host to ProxyModel """
host = entry["host"]
procs = entry["procs"]
rtime = entry["time"]
Expand All @@ -863,7 +866,7 @@ def __addHost(self, entry):
QtGui.QStandardItem(
"%0.2fGB" % (proc.data.reserved_memory / 1048576.0)),
QtGui.QStandardItem(cuegui.Utils.secondsToHHMMSS(time.time() -
proc.data.dispatch_time)),
proc.data.dispatch_time)),
QtGui.QStandardItem(proc.data.group_name),
QtGui.QStandardItem(",".join(proc.data.services)),
QtGui.QStandardItem(str(entry["job_cores"])),
Expand All @@ -884,9 +887,6 @@ def __addHost(self, entry):
class ProxyModel(QtCore.QSortFilterProxyModel):
"""Provides support for sorting data passed between the model and the tree view"""

def __init__(self, parent=None):
super(ProxyModel, self).__init__(parent)

def lessThan(self, left, right):

leftData = self.sourceModel().data(left)
Expand Down
28 changes: 25 additions & 3 deletions cuegui/cuegui/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ def shutdownThread(thread):
return thread.wait(1500)

def getLLU(item):
""" LLU time from log_path """
if isProc(item):
logFile = item.data.log_path
elif isFrame(item):
Expand All @@ -643,10 +644,31 @@ def getLLU(item):

return lluTime

def numFormat(num, type):
def numFormat(num, _type):
""" format LLU time """
if num == "" or num < .001 or num is None:
return ""
if type == "t":
if _type == "t":
return secondsToHHMMSS(int(num))
if type == "f":
if _type == "f":
return "%.2f" % float(num)

def byteConversion(amount, btype):
""" convert unit of memory size into bytes for comparing different
unit measures
:param amount: unit of memory size
:ptype amount: float
:param btype: unit type
:ptype btype: string
:return: unit in bytes
:rtype: float
"""
n = 1
conversionMap = {"KB": 1, "TB": 4, "GB": 3, "MB": 2}
_bytes = amount
if btype.upper() in conversionMap:
n = conversionMap[btype.upper()]
for _ in range(n):
_bytes *= 1024
return _bytes

0 comments on commit dd4d6ba

Please sign in to comment.