def GetFullNetworkPath(path): fullNetworkPath = None if not Path.IsPathRooted(path): raise ArgumentException("A full file path must be specified.", "path") pathRoot = Path.GetPathRoot(path) driveRemoteName = GetDriveRemoteName(pathRoot) if driveRemoteName is not None: pathWithoutRoot = path.Substring(pathRoot.Length) fullNetworkPath = Path.Combine(driveRemoteName, pathWithoutRoot) return fullNetworkPath
def check_host_drive_freespace(): # get min free space from user config min_freespace = user_config.core.get_option('minhostdrivefreespace', default_value=0) if min_freespace: # find host drive and check free space host_drive = Path.GetPathRoot(HOST_APP.proc_path) for drive in DriveInfo.GetDrives(): if drive.Name == host_drive: free_hd_space = float(drive.TotalFreeSpace) / (1024**3) if free_hd_space < min_freespace: logger.warning( 'Remaining space on local drive ' 'is less than {}GB...'.format(min_freespace))
def GetDriveLetter(path): driveLetter = Path.GetPathRoot(path).Split(":")[0] return driveLetter.ToUpper() if len(driveLetter) == 1 else None