def checkDiskSpace(self, path: str): # noinspection PyCallByClass if self.spaceWarningDelivered or not QFileInfo.exists(path): return info = QStorageInfo(path) available = info.bytesAvailable() / 1000 / 1000 if available < VideoService.spaceWarningThreshold: warnmsg = 'There is less than {0}MB of disk space available at the target folder selected to save ' + \ 'your media. VidCutter WILL FAIL to produce your media if you run out of space during ' + \ 'operations.' QMessageBox.warning(self.parent, 'Disk space is low!', warnmsg.format(VideoService.spaceWarningThreshold)) self.spaceWarningDelivered = True
def checkDiskSpace(self, path: str) -> None: # noinspection PyCallByClass if self.spaceWarningDelivered or not QFileInfo.exists(path): return info = QStorageInfo(path) available = info.bytesAvailable() / 1000 / 1000 if available < VideoService.spaceWarningThreshold: warnmsg = 'There is less than {}MB of free disk space in the '.format(VideoService.spaceWarningThreshold) warnmsg += 'folder selected to save your media. ' warnmsg += 'VidCutter will fail if space runs out before processing completes.' spacewarn = VCMessageBox('Warning', 'Disk space alert', warnmsg, self.parentWidget()) spacewarn.addButton(VCMessageBox.Ok) spacewarn.exec_() self.spaceWarningDelivered = True
def setDestination(self, path: str) -> None: """ Set the downloaded destination path :param path: valid path """ self.display_name, self.path = get_path_display_name(path) try: self.os_stat_device = os.stat(path).st_dev except FileNotFoundError: logging.error( "Cannot set download destination display: %s does not exist", path) self.os_stat_device = 0 mount = QStorageInfo(path) bytes_total, bytes_free = get_mount_size(mount=mount) self.storage_space = StorageSpace(bytes_free=bytes_free, bytes_total=bytes_total, path=path)
def DInfo(path): none = "---" d = path[0:3].upper() si = QStorageInfo(d) s = ' {:<4}'.format(d[0]) dt = driveTypes() if si.isValid(): if os.name == 'nt': s += ' {:<12}'.format(dt[win32file.GetDriveType(d)]) else: s += ' {:<12}'.format(none) if si.isReady(): s += '{:>12,} {:>12,}'.format(int(si.bytesTotal() / 1024), int(si.bytesFree() / 1024)).replace( ",", " ") else: s += '{0:>12} {0:>12}'.format(none) else: s += ' {0:<12}{0:>12} {0:>12}'.format(none) print(s)
def __init__(self, parent = None): super(StorageModel, self).__init__(parent) self.volumes = QStorageInfo.mountedVolumes()