Skip to content

Commit 94422b1

Browse files
author
Greg Denton
authored
Fixing frame updates in FrameMonitorTree (#169)
* fixing frame updates in FrameMonitorTree
1 parent a3087de commit 94422b1

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

cuegui/cuegui/FrameMonitorTree.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -407,17 +407,12 @@ def _getUpdateChanged(self):
407407
logger.warning("no job or job is finished, bailing")
408408
return []
409409
logger.info(" + Nth update = %s" % self.__class__)
410-
updatedFrames = job_pb2.UpdatedFrameSeq()
410+
updatedFrames = []
411411
try:
412412
updated_data = self.__job.getUpdatedFrames(self.__lastUpdateTime)
413-
# Once the updatedFrames include the proxy instead of the id, this can be removed
414-
for frame in updated_data.updated_frames.updated_frames:
415-
frame = opencue.util.proxy(frame.id, "Frame")
416-
logger.info("Frame Updates: %s" % len(updated_data.updated_frames.updated_frames))
417413
self.__lastUpdateTime = updated_data.server_time
418414
self.__jobState = updated_data.state
419-
420-
updatedFrames = updated_data.updated_frames
415+
updatedFrames = updated_data.updated_frames.updated_frames
421416

422417
except opencue.EntityNotFoundException, e:
423418
self.setJobObj(None)
@@ -467,14 +462,9 @@ def _processUpdateChanged(self, work, rpcObjects):
467462
else:
468463
self._itemsLock.lockForWrite()
469464
try:
470-
for updatedFrame in rpcObjects.updated_frames:
465+
for updatedFrame in rpcObjects:
471466
# If id already exists, update it
472-
if updatedFrame.id in self._items:
473-
frame = self._items[updatedFrame.id].rpcObject
474-
475-
for item in dir(updatedFrame.id):
476-
if not item.startswith("__") and item != "id":
477-
setattr(frame.data, item, getattr(updatedFrame, item))
467+
self._updateFrame(updatedFrame)
478468
finally:
479469
self._itemsLock.unlock()
480470

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

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

488488
def contextMenuEvent(self, e):
489489
"""When right clicking on an item, this raises a context menu"""
@@ -696,9 +696,12 @@ def __doWork(self):
696696
try:
697697
if self.__queue:
698698
(proxy, path) = self.__queue.popitem()
699-
return (proxy,
700-
Utils.getLastLine(path),
701-
Utils.secondsToHHMMSS(time.time() - os.stat(path).st_mtime))
699+
if os.path.exists(path):
700+
return (proxy,
701+
Utils.getLastLine(path),
702+
Utils.secondsToHHMMSS(time.time() - os.stat(path).st_mtime))
703+
else:
704+
return None
702705
except Exception, e:
703706
map(logger.warning, Utils.exceptionOutput(e))
704707

0 commit comments

Comments
 (0)