From dfe95cce63adf7158edb7487093c18420d7e0e78 Mon Sep 17 00:00:00 2001
From: Julien Duponchelle <julien@duponchelle.info>
Date: Sun, 5 Jul 2015 21:53:47 +0200
Subject: [PATCH] Fix qemu binary lookup in frozen OSX application

https://github.com/GNS3/gns3-gui/issues/496
---
 gns3server/modules/qemu/__init__.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gns3server/modules/qemu/__init__.py b/gns3server/modules/qemu/__init__.py
index d8e2b149..6b95d989 100644
--- a/gns3server/modules/qemu/__init__.py
+++ b/gns3server/modules/qemu/__init__.py
@@ -75,7 +75,8 @@ class Qemu(BaseManager):
             paths.update(["/usr/bin", "/usr/local/bin", "/opt/local/bin"])
             if hasattr(sys, "frozen"):
                 try:
-                    paths.add(os.path.abspath(os.path.join(os.getcwd(), "../../../qemu/bin/")))
+                    exec_dir = os.path.dirname(os.path.abspath(sys.executable))
+                    paths.add(os.path.abspath(os.path.join(exec_dir, "../Resources/qemu/bin/")))
                 # If the user run the server by hand from outside
                 except FileNotFoundError:
                     paths.add("/Applications/GNS3.app/Contents/Resources/qemu/bin")