mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-21 21:54:26 +00:00
Look for azcopy.exe in AZCOPY if it's a directory (#3344)
* Look for azcopy.exe in AZCOPY if it's a directory * Make file check in AZCOPY dir more concise Co-authored-by: George Pollard <gpollard@microsoft.com> * Add logic to support searching for azcopy on linux --------- Co-authored-by: George Pollard <gpollard@microsoft.com>
This commit is contained in:
@ -5,10 +5,20 @@ import subprocess # nosec
|
|||||||
|
|
||||||
def find_azcopy() -> str:
|
def find_azcopy() -> str:
|
||||||
azcopy = os.environ.get("AZCOPY")
|
azcopy = os.environ.get("AZCOPY")
|
||||||
|
binary_name = "azcopy" if os.name == "posix" else "azcopy.exe"
|
||||||
|
|
||||||
if azcopy:
|
if azcopy:
|
||||||
if not os.path.exists(azcopy):
|
if not os.path.exists(azcopy):
|
||||||
raise Exception(f"AZCOPY environment variable is invalid: {azcopy}")
|
raise Exception(f"AZCOPY environment variable is invalid: {azcopy}")
|
||||||
|
elif os.path.isdir(azcopy):
|
||||||
|
contains_azcopy = os.path.isfile(os.path.join(azcopy, binary_name))
|
||||||
|
|
||||||
|
if contains_azcopy:
|
||||||
|
azcopy = os.path.join(azcopy, binary_name)
|
||||||
|
else:
|
||||||
|
raise Exception(
|
||||||
|
f"The directory specified by AZCOPY doesn't contain the file '{binary_name}': {azcopy}"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
azcopy = shutil.which("azcopy")
|
azcopy = shutil.which("azcopy")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user