Save the runtime status information in the application object for using

it other places.

globals() does not return consistent value across the application
context.

Thanks Neel Patel for reporting the issue.
This commit is contained in:
Ashesh Vashi 2016-06-21 15:12:20 +05:30
parent d133e33c4b
commit a35288e25d
2 changed files with 5 additions and 8 deletions

View File

@ -72,6 +72,9 @@ else:
config.DEFAULT_SERVER_PORT)
server_port = config.DEFAULT_SERVER_PORT
# Let the application save the status about the runtime for using it later.
app.PGADMIN_RUNTIME = PGADMIN_RUNTIME
# Output a startup message if we're not under the runtime
if not PGADMIN_RUNTIME:
print("Starting %s. Please navigate to http://localhost:%d in your browser." %

View File

@ -22,6 +22,7 @@ import pytz
from subprocess import Popen, PIPE
import sys
from flask import current_app as app
from flask.ext.babel import gettext as _
from flask.ext.security import current_user
@ -33,13 +34,6 @@ if sys.version_info < (3,):
else:
from io import StringIO
# The port number should have already been set by the runtime if we're running
# in desktop mode.
PGADMIN_RUNTIME = False
if 'PGADMIN_PORT' in globals():
PGADMIN_RUNTIME = True
def get_current_time(format='%Y-%m-%d %H:%M:%S.%f %z'):
"""
@ -188,7 +182,7 @@ class BatchProcess(object):
p = None
cmd = [
(sys.executable if not PGADMIN_RUNTIME else
(sys.executable if not app.PGADMIN_RUNTIME else
'pythonw.exe' if os.name == 'nt' else 'python'),
executor,
'-p', self.id,