def update(self): try: file_statuses = self.gse_manager.get_file_status() except Pyro4.errors.CommunicationError as e: print ''.join(Pyro4.util.getPyroTraceback()) raise for link_name, file_status in file_statuses.items(): for file_id, status in file_status.items(): new_row = False if file_id in self.files: this_file = self.files[file_id] if (((len(status['packets_received']) == status['packets_expected']) and ((time.time() - status['recent_timestamp']) > 120)) or (time.time() - status['recent_timestamp']) > 900): index = self.files.keys().index(file_id) self.beginRemoveRows(QtCore.QModelIndex(), index, index + 1) print "removing", index, file_id del self.files[file_id] self.endRemoveRows() continue if status['recent_timestamp'] == this_file[ 'recent_timestamp']: continue else: if ((len(status['packets_received']) == status['packets_expected']) and (time.time() - status['recent_timestamp']) > 10): continue new_row = True status['link'] = link_name packet = status['first_packet'] packets_received = len(status['packets_received']) status['total_packets_received'] = packets_received status['bytes_per_second'] = 0 status['time_remaining'] = 0 if status['first_timestamp'] != status['recent_timestamp']: bytes_per_packet = packet.total_packet_length status['bytes_per_second'] = bytes_per_packet * ( packets_received - 1) / (status['recent_timestamp'] - status['first_timestamp']) if status['bytes_per_second'] != 0: status['time_remaining'] = ( bytes_per_packet * (status['packets_expected'] - packets_received) / status['bytes_per_second']) if new_row: self.beginInsertRows(QtCore.QModelIndex(), self.rowCount(), self.rowCount()) self.files[file_id] = status if new_row: self.endInsertRows() index = self.files.keys().index(file_id) self.dataChanged.emit( self.createIndex(index, 0), self.createIndex(index + 1, self.columnCount()))
def parent(self, index): if not index.isValid(): return QtCore.QModelIndex() # print(index) childItem = index.internalPointer() # print(type(childItem)) parentItem = childItem.parentItem() if parentItem == self.rootItem: return QtCore.QModelIndex() if parentItem is None: return QtCore.QModelIndex() return self.createIndex(parentItem.row(), 0, parentItem)
def parent(self, index): if index.isValid(): p = index.internalPointer().parent() if p: return QtCore.QAbstractItemModel.createIndex( self, p.row(), 0, p) return QtCore.QModelIndex()
def parent(self, index): node = self.getNode(index) parentNode = node.parent() if parentNode == self._rootNode: return QtCore.QModelIndex() return self.createIndex(parentNode.row(), 0, parentNode)
def index(self, row, column, parent): parentNode = self.getNode(parent) childItem = parentNode.child(row) if childItem: return self.createIndex(row, column, childItem) else: return QtCore.QModelIndex()
def index(self, row, column, parent): if not self.hasIndex(row, column, parent): return QtCore.QModelIndex() parentItem = None if not parent.isValid(): parentItem = self.rootItem else: parentItem = parent.internalPointer() childItem = parentItem.child(row) if childItem: return self.createIndex(row, column, childItem) else: return QtCore.QModelIndex()
def removeRows(self, position, rows, parent=QtCore.QModelIndex()): parentNode = self.getNode(parent) self.beginRemoveRows(parent, position, position + rows - 1) for row in range(rows): success = parentNode.removeChild(position) self.endRemoveRows() return success
def index(self, row, column, _parent=None): if not _parent or not _parent.isValid(): parent = self._root else: parent = _parent.internalPointer() # if not QtCore.QAbstractItemModel.hasIndex(self, row, column, _parent): # return QtCore.QModelIndex() child = parent.child(row) if child: return QtCore.QAbstractItemModel.createIndex( self, row, column, child) else: return QtCore.QModelIndex()
def columnCount(self, parent=QtCore.QModelIndex()): if parent.isValid(): return 0 return self._dataframe.columns.size
def rowCount(self, parent=QtCore.QModelIndex()): if parent.isValid(): return 0 return len(self._dataframe.index)
def update(self, path, sensor_no, _acc, _acc_f): if path == self._path and sensor_no not in self._data: self.beginInsertRows(QtCore.QModelIndex(), len(self._data), len(self._data)) self._data.append(sensor_no) self.endInsertRows()
def _add_source(self, source): self.beginInsertRows(QtCore.QModelIndex(), len(self._data), len(self._data)) self._data.append(source) self.endInsertRows()
def newRecord(self, record): self.beginInsertRows(QtCore.QModelIndex(), 0, 0) self.log_records.append(record) self.endInsertRows()