From b756407c3cb3e4afd40591b65902c390eb2b723f Mon Sep 17 00:00:00 2001 From: Ashesh Vashi Date: Mon, 3 Apr 2017 18:43:38 +0530 Subject: [PATCH] When running pgAdmin as a WSGI application, we will not be able to find the '__main__' module under 'sys.modules'. --- web/pgadmin/browser/server_groups/servers/types.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/pgadmin/browser/server_groups/servers/types.py b/web/pgadmin/browser/server_groups/servers/types.py index 24cb0b314..a002d2cf5 100644 --- a/web/pgadmin/browser/server_groups/servers/types.py +++ b/web/pgadmin/browser/server_groups/servers/types.py @@ -113,7 +113,8 @@ class ServerType(object): )) ) bin_path = self.utility_path.get() - if "$DIR" in bin_path: + # AS WSGI application, we will not find the '__main__' module. + if "__main__" in sys.modules: bin_path = bin_path.replace("$DIR", os.path.dirname(sys.modules['__main__'].__file__)) return os.path.abspath(os.path.join(