mirror of
https://github.com/GNS3/gns3-server
synced 2025-07-30 02:18:09 +00:00
parent
887f9b298e
commit
a2e51ac090
@ -47,13 +47,13 @@ class Qemu(BaseManager):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
qemus = []
|
qemus = []
|
||||||
paths = []
|
paths = set()
|
||||||
try:
|
try:
|
||||||
paths.append(os.getcwd())
|
paths.add(os.getcwd())
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
log.warning("The current working directory doesn't exist")
|
log.warning("The current working directory doesn't exist")
|
||||||
if "PATH" in os.environ:
|
if "PATH" in os.environ:
|
||||||
paths.extend(os.environ["PATH"].split(os.pathsep))
|
paths.update(os.environ["PATH"].split(os.pathsep))
|
||||||
else:
|
else:
|
||||||
log.warning("The PATH environment variable doesn't exist")
|
log.warning("The PATH environment variable doesn't exist")
|
||||||
# look for Qemu binaries in the current working directory and $PATH
|
# look for Qemu binaries in the current working directory and $PATH
|
||||||
@ -64,21 +64,21 @@ class Qemu(BaseManager):
|
|||||||
exec_dir = os.path.dirname(os.path.abspath(sys.executable))
|
exec_dir = os.path.dirname(os.path.abspath(sys.executable))
|
||||||
for f in os.listdir(exec_dir):
|
for f in os.listdir(exec_dir):
|
||||||
if f.lower().startswith("qemu"):
|
if f.lower().startswith("qemu"):
|
||||||
paths.append(os.path.join(exec_dir, f))
|
paths.add(os.path.join(exec_dir, f))
|
||||||
|
|
||||||
if "PROGRAMFILES(X86)" in os.environ and os.path.exists(os.environ["PROGRAMFILES(X86)"]):
|
if "PROGRAMFILES(X86)" in os.environ and os.path.exists(os.environ["PROGRAMFILES(X86)"]):
|
||||||
paths.append(os.path.join(os.environ["PROGRAMFILES(X86)"], "qemu"))
|
paths.add(os.path.join(os.environ["PROGRAMFILES(X86)"], "qemu"))
|
||||||
if "PROGRAMFILES" in os.environ and os.path.exists(os.environ["PROGRAMFILES"]):
|
if "PROGRAMFILES" in os.environ and os.path.exists(os.environ["PROGRAMFILES"]):
|
||||||
paths.append(os.path.join(os.environ["PROGRAMFILES"], "qemu"))
|
paths.add(os.path.join(os.environ["PROGRAMFILES"], "qemu"))
|
||||||
elif sys.platform.startswith("darwin"):
|
elif sys.platform.startswith("darwin"):
|
||||||
# add specific locations on Mac OS X regardless of what's in $PATH
|
# add specific locations on Mac OS X regardless of what's in $PATH
|
||||||
paths.extend(["/usr/local/bin", "/opt/local/bin"])
|
paths.update(["/usr/local/bin", "/opt/local/bin"])
|
||||||
if hasattr(sys, "frozen"):
|
if hasattr(sys, "frozen"):
|
||||||
try:
|
try:
|
||||||
paths.append(os.path.abspath(os.path.join(os.getcwd(), "../../../qemu/bin/")))
|
paths.add(os.path.abspath(os.path.join(os.getcwd(), "../../../qemu/bin/")))
|
||||||
# If the user run the server by hand from outside
|
# If the user run the server by hand from outside
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
paths.append(["/Applications/GNS3.app/Contents/Resources/qemu/bin"])
|
paths.add("/Applications/GNS3.app/Contents/Resources/qemu/bin")
|
||||||
for path in paths:
|
for path in paths:
|
||||||
try:
|
try:
|
||||||
for f in os.listdir(path):
|
for f in os.listdir(path):
|
||||||
|
Loading…
Reference in New Issue
Block a user