def show_organization_stats(self, organization_id: OrganizationID, organization_stats: OrganizationStats): self.label_organization_name.show() self.label_organization_size.show() self.label_organization_name.setText(organization_id.str) total = file_size.get_filesize(organization_stats.metadata_size + organization_stats.data_size) self.label_organization_size.setText( _("TEXT_ORGANIZATION_SIZE_organizationsize").format( organizationsize=total)) self.label_organization_size.setToolTip( _("TEXT_ORGANIZATION_SIZE_TOOLTIP_datasize-metadatasize").format( datasize=file_size.get_filesize(organization_stats.data_size), metadatasize=file_size.get_filesize( organization_stats.metadata_size), ))
def __init__(self, version, creator, name, size, src, dst, timestamp): super().__init__() self.setupUi(self) self.label_version.setText(str(version)) self.label_user.setText(creator) self.label_size.setText(get_filesize(size) if size is not None else "") self.label_date.setText(format_datetime(timestamp)) if not src: self.label_src.hide() else: self.label_src.setText(str(src)) if not dst: self.label_dst.hide() else: self.label_dst.setText(str(dst))
def add_file( self, file_name, entry_id, file_size, created_on, updated_on, is_synced, is_confined, selected=False, ): if is_confined and not self.config.gui_show_confined: return entry_id = entry_id.hex row_idx = self.rowCount() self.insertRow(row_idx) item = FileTableItem(is_synced, is_confined, file_name.str) item.setData(NAME_DATA_INDEX, 1) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(ENTRY_ID_DATA_INDEX, entry_id) self.setItem(row_idx, Column.ICON, item) item = CustomTableItem(file_name.str) item.setToolTip("\n".join(file_name.str[i:i + 64] for i in range(0, len(file_name.str), 64))) item.setData(NAME_DATA_INDEX, file_name.str) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(ENTRY_ID_DATA_INDEX, entry_id) self.setItem(row_idx, Column.NAME, item) item = CustomTableItem(format_datetime(created_on)) item.setData(NAME_DATA_INDEX, created_on) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(ENTRY_ID_DATA_INDEX, entry_id) self.setItem(row_idx, Column.CREATED, item) item = CustomTableItem(format_datetime(updated_on)) item.setData(NAME_DATA_INDEX, updated_on) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(ENTRY_ID_DATA_INDEX, entry_id) self.setItem(row_idx, Column.UPDATED, item) item = CustomTableItem(get_filesize(file_size)) item.setData(NAME_DATA_INDEX, file_size) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(ENTRY_ID_DATA_INDEX, entry_id) self.setItem(row_idx, Column.SIZE, item) if selected: self.setRangeSelected( QTableWidgetSelectionRange(row_idx, 0, row_idx, len(Column) - 1), True)
def _wait_status_shown(): assert file_status_w.label_location.text().endswith(str(Path("/foo/bar.txt"))) assert file_status_w.label_workspace.text() == "wksp1" assert file_status_w.label_filetype.text() == "file" assert file_status_w.label_size.text() == "0 B" assert file_status_w.label_created_on.text() != "" and file_status_w.label_created_on.text() != _( "TEXT_FILE_INFO_NON_APPLICABLE" ) assert file_status_w.label_created_by.text() == "Boby McBobFace" assert file_status_w.label_last_updated_on.text() != "" and file_status_w.label_last_updated_on.text() != _( "TEXT_FILE_INFO_NON_APPLICABLE" ) assert file_status_w.label_last_updated_by.text() == "Boby McBobFace" assert file_status_w.label_availability.text() == _("TEXT_YES") assert file_status_w.label_uploaded.text() == _("TEXT_YES") assert file_status_w.label_local.text() == "0/0 (100%)" assert file_status_w.label_remote.text() == "0/0 (100%)" assert file_status_w.label_default_block_size.text() == get_filesize(DEFAULT_BLOCK_SIZE)
def _add_file(self, file_name, file_size, created_on, updated_on): row_idx = self.table_files.rowCount() self.table_files.insertRow(row_idx) item = CustomTableItem(QIcon(":/icons/images/icons/file.png"), "") item.setData(Qt.UserRole, FileType.File) self.table_files.setItem(row_idx, 0, item) item = QTableWidgetItem(file_name) self.table_files.setItem(row_idx, 1, item) item = CustomTableItem(created_on.format("%x %X")) item.setData(Qt.UserRole, created_on) self.table_files.setItem(row_idx, 2, item) item = CustomTableItem(updated_on.format("%x %X")) item.setData(Qt.UserRole, updated_on) self.table_files.setItem(row_idx, 3, item) item = CustomTableItem(get_filesize(file_size)) item.setData(Qt.UserRole, file_size) self.table_files.setItem(row_idx, 4, item) item = QTableWidgetItem(QIcon(":/icons/images/icons/garbage.png"), "") self.table_files.setItem(row_idx, 5, item)
def add_file(self, file_name, uuid, file_size, created_on, updated_on, is_synced, selected=False): row_idx = self.rowCount() self.insertRow(row_idx) item = FileTableItem(is_synced, file_name) item.setData(NAME_DATA_INDEX, 1) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(UUID_DATA_INDEX, uuid) self.setItem(row_idx, Column.ICON, item) item = CustomTableItem(file_name) item.setToolTip("\n".join(file_name[i:i + 64] for i in range(0, len(file_name), 64))) item.setData(NAME_DATA_INDEX, file_name) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(UUID_DATA_INDEX, uuid) self.setItem(row_idx, Column.NAME, item) item = CustomTableItem(format_datetime(created_on)) item.setData(NAME_DATA_INDEX, created_on) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(UUID_DATA_INDEX, uuid) self.setItem(row_idx, Column.CREATED, item) item = CustomTableItem(format_datetime(updated_on)) item.setData(NAME_DATA_INDEX, updated_on) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(UUID_DATA_INDEX, uuid) self.setItem(row_idx, Column.UPDATED, item) item = CustomTableItem(get_filesize(file_size)) item.setData(NAME_DATA_INDEX, file_size) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(UUID_DATA_INDEX, uuid) self.setItem(row_idx, Column.SIZE, item) if selected: self.setRangeSelected( QTableWidgetSelectionRange(row_idx, 0, row_idx, len(Column) - 1), True)
async def get_status(self): path_info = await self.workspace_fs.path_info(self.path) block_info = None if path_info["type"] == "file": block_info: BlockInfo = await self.workspace_fs.get_blocks_by_type( self.path) self.label_size.setText(get_filesize(path_info["size"])) version_lister = self.workspace_fs.get_version_lister() version_list = await version_lister.list(path=self.path) user_id = version_list[0][0].creator.user_id created_time = version_list[0][0].updated updated_time = path_info["updated"] version_list = await version_lister.list( path=self.path, starting_timestamp=updated_time) user_id_last = version_list[0][-1].creator.user_id creator = await self.core.get_user_info(user_id) last_author = await self.core.get_user_info(user_id_last) full_path = self.core.mountpoint_manager.get_path_in_mountpoint( self.workspace_fs.workspace_id, self.path, self.workspace_fs.timestamp if isinstance(self.workspace_fs, WorkspaceFSTimestamped) else None, ) self.label_location.setText(str(full_path)) self.label_filetype.setText(str(path_info["type"])) self.label_workspace.setText( self.workspace_fs.get_workspace_name().str) self.label_created_on.setText(format_datetime(created_time)) self.label_last_updated_on.setText(format_datetime(updated_time)) self.label_created_by.setText(creator.short_user_display) self.label_last_updated_by.setText(last_author.short_user_display) if block_info: local_blocks = len(block_info.local_only_blocks) remote_blocks = len(block_info.remote_only_blocks) local_and_remote_blocks = len(block_info.local_and_remote_blocks) total_blocks = local_blocks + remote_blocks + local_and_remote_blocks local_block_count = local_blocks + local_and_remote_blocks local_block_percentage = int( (local_block_count / total_blocks if total_blocks else 1) * 100.0) remote_block_count = remote_blocks + local_and_remote_blocks remote_block_percentage = int( (remote_block_count / total_blocks if total_blocks else 1) * 100.0) if local_block_count == total_blocks: self.label_availability.setText(_("TEXT_YES")) else: self.label_availability.setText(_("TEXT_NO")) if remote_block_count == total_blocks: self.label_uploaded.setText(_("TEXT_YES")) else: self.label_uploaded.setText(_("TEXT_NO")) self.label_local.setText( f"{local_block_count}/{total_blocks} ({local_block_percentage}%)" ) self.label_remote.setText( f"{remote_block_count}/{total_blocks} ({remote_block_percentage}%)" ) self.label_default_block_size.setText( get_filesize(DEFAULT_BLOCK_SIZE))