fix csv format error
This commit is contained in:
+37
-3
@@ -172,13 +172,26 @@ def _normalize_input_path(path_value):
|
||||
path = resolve_runtime_path(path_value)
|
||||
path = str(path).strip()
|
||||
|
||||
# Normalize forward slashes to backslashes first
|
||||
path = path.replace("/", "\\")
|
||||
|
||||
# Accept \\server\share style UNC paths and ensure proper escaping
|
||||
if path.startswith("\\\\"):
|
||||
# Clean up any doubled backslashes from replacement
|
||||
while "\\\\\\" in path:
|
||||
path = path.replace("\\\\\\", "\\\\")
|
||||
return path
|
||||
|
||||
# Accept //server/share style and normalize to UNC for smbclient.
|
||||
if path.startswith("//"):
|
||||
return "\\\\" + path.lstrip("/").replace("/", "\\")
|
||||
path = path.lstrip("/").replace("/", "\\")
|
||||
return "\\\\" + path
|
||||
|
||||
# Accept /<ipv4>/<share>/... and normalize to UNC for Linux-hosted inputs.
|
||||
if re.match(r"^/\d{1,3}(?:\.\d{1,3}){3}/[^/]+", path):
|
||||
return "\\\\" + path.lstrip("/").replace("/", "\\")
|
||||
if re.match(r"^\\?\d{1,3}(?:\\\.\d{1,3}){3}\\[^\\]+", path):
|
||||
if path.startswith("\\"):
|
||||
path = path.lstrip("\\")
|
||||
return "\\\\" + path
|
||||
|
||||
return path
|
||||
|
||||
@@ -225,6 +238,27 @@ def _iter_dir_entries(path, smb_credentials=None):
|
||||
return list(os.scandir(path))
|
||||
|
||||
|
||||
def path_exists_with_smb(path, smb_credentials=None):
|
||||
"""Check if a path exists, with SMB authentication for UNC paths."""
|
||||
if not path:
|
||||
return False
|
||||
|
||||
path = _normalize_input_path(path)
|
||||
|
||||
# For UNC paths, use SMB to check
|
||||
if _is_unc_path(path):
|
||||
try:
|
||||
_register_smb_session_if_needed(path, smb_credentials=smb_credentials)
|
||||
# Try to list entries; if successful, path exists
|
||||
_iter_dir_entries(path, smb_credentials=smb_credentials)
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
# For local paths, use standard os.path.exists
|
||||
return os.path.exists(path)
|
||||
|
||||
|
||||
def scan_results(results_dir_dut, results_dir_ref, smb_credentials=None):
|
||||
results_dir_dut = _normalize_input_path(results_dir_dut)
|
||||
results_dir_ref = _normalize_input_path(results_dir_ref)
|
||||
|
||||
Reference in New Issue
Block a user