Skip to content

Commit

Permalink
Fixing frame updates in FrameMonitorTree (#169)
Browse files Browse the repository at this point in the history
* fixing frame updates in FrameMonitorTree
  • Loading branch information
Greg Denton authored Jan 24, 2019
1 parent a3087de commit 94422b1
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions cuegui/cuegui/FrameMonitorTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,17 +407,12 @@ def _getUpdateChanged(self):
logger.warning("no job or job is finished, bailing")
return []
logger.info(" + Nth update = %s" % self.__class__)
updatedFrames = job_pb2.UpdatedFrameSeq()
updatedFrames = []
try:
updated_data = self.__job.getUpdatedFrames(self.__lastUpdateTime)
# Once the updatedFrames include the proxy instead of the id, this can be removed
for frame in updated_data.updated_frames.updated_frames:
frame = opencue.util.proxy(frame.id, "Frame")
logger.info("Frame Updates: %s" % len(updated_data.updated_frames.updated_frames))
self.__lastUpdateTime = updated_data.server_time
self.__jobState = updated_data.state

updatedFrames = updated_data.updated_frames
updatedFrames = updated_data.updated_frames.updated_frames

except opencue.EntityNotFoundException, e:
self.setJobObj(None)
Expand Down Expand Up @@ -467,14 +462,9 @@ def _processUpdateChanged(self, work, rpcObjects):
else:
self._itemsLock.lockForWrite()
try:
for updatedFrame in rpcObjects.updated_frames:
for updatedFrame in rpcObjects:
# If id already exists, update it
if updatedFrame.id in self._items:
frame = self._items[updatedFrame.id].rpcObject

for item in dir(updatedFrame.id):
if not item.startswith("__") and item != "id":
setattr(frame.data, item, getattr(updatedFrame, item))
self._updateFrame(updatedFrame)
finally:
self._itemsLock.unlock()

Expand All @@ -484,6 +474,16 @@ def _processUpdateChanged(self, work, rpcObjects):
except Exception, e:
map(logger.warning, Utils.exceptionOutput(e))

def _updateFrame(self, updatedFrame):
"""Update the frame object on a WidgetItem with the values from a UpdatedFrame object.
@type updatedFrame: job_pb2.UpdatedFrame
@param updatedFrame: UpdatedFrame to copy values from."""
logger.info("_updateFrame")
frameWidget = self._items.get('Frame.{}'.format(updatedFrame.id))
if frameWidget:
for field in job_pb2.UpdatedFrame.DESCRIPTOR.fields_by_name.keys():
if field != "id":
setattr(frameWidget.rpcObject.data, field, getattr(updatedFrame, field))

def contextMenuEvent(self, e):
"""When right clicking on an item, this raises a context menu"""
Expand Down Expand Up @@ -696,9 +696,12 @@ def __doWork(self):
try:
if self.__queue:
(proxy, path) = self.__queue.popitem()
return (proxy,
Utils.getLastLine(path),
Utils.secondsToHHMMSS(time.time() - os.stat(path).st_mtime))
if os.path.exists(path):
return (proxy,
Utils.getLastLine(path),
Utils.secondsToHHMMSS(time.time() - os.stat(path).st_mtime))
else:
return None
except Exception, e:
map(logger.warning, Utils.exceptionOutput(e))

Expand Down

0 comments on commit 94422b1

Please sign in to comment.