Merged adjustanct 'if' statements when allowed.

Also - removed the unused variables.
This commit is contained in:
Ashesh Vashi 2020-04-08 20:27:09 +05:30
parent 6c5883bce0
commit a930c6617b
2 changed files with 21 additions and 22 deletions

View File

@ -117,10 +117,9 @@ else:
app.debug = False app.debug = False
# respond to JS # respond to JS
if config.DEBUG: if config.DEBUG and javascriptBundler.report() == JsState.NONE:
if javascriptBundler.report() == JsState.NONE:
app.logger.error("Unable to generate javascript")
app.logger.error( app.logger.error(
"Unable to generate javascript.\n"
"To run the app ensure that yarn install command runs successfully" "To run the app ensure that yarn install command runs successfully"
) )
raise Exception("No generated javascript, aborting") raise Exception("No generated javascript, aborting")

View File

@ -472,7 +472,7 @@ def create_app(app_name=None):
try: try:
proc_arch64 = os.environ['PROCESSOR_ARCHITEW6432'].lower() proc_arch64 = os.environ['PROCESSOR_ARCHITEW6432'].lower()
except Exception as e: except Exception:
proc_arch64 = None proc_arch64 = None
if proc_arch == 'x86' and not proc_arch64: if proc_arch == 'x86' and not proc_arch64:
@ -486,7 +486,7 @@ def create_app(app_name=None):
try: try:
root_key = winreg.OpenKey( root_key = winreg.OpenKey(
winreg.HKEY_LOCAL_MACHINE, winreg.HKEY_LOCAL_MACHINE,
"SOFTWARE\\" + server_type + "\Services", 0, "SOFTWARE\\" + server_type + "\\Services", 0,
winreg.KEY_READ | arch_key winreg.KEY_READ | arch_key
) )
for i in xrange(0, winreg.QueryInfoKey(root_key)[0]): for i in xrange(0, winreg.QueryInfoKey(root_key)[0]):
@ -518,7 +518,7 @@ def create_app(app_name=None):
) )
inst_key.Close() inst_key.Close()
except Exception as e: except Exception:
pass pass
else: else:
# We use the postgres-winreg.ini file on non-Windows # We use the postgres-winreg.ini file on non-Windows
@ -566,7 +566,7 @@ def create_app(app_name=None):
svr_superuser, svr_port, svr_discovery_id, svr_superuser, svr_port, svr_discovery_id,
svr_comment) svr_comment)
except Exception as e: except Exception:
pass pass
@user_logged_in.connect_via(app) @user_logged_in.connect_via(app)
@ -618,11 +618,12 @@ def create_app(app_name=None):
# Check the auth key is valid, if it's set, and we're not in server # Check the auth key is valid, if it's set, and we're not in server
# mode, and it's not a help file request. # mode, and it's not a help file request.
if not config.SERVER_MODE and app.PGADMIN_INT_KEY != '': if not config.SERVER_MODE and app.PGADMIN_INT_KEY != '' and ((
if (('key' not in request.args or 'key' not in request.args or
request.args['key'] != app.PGADMIN_INT_KEY) and request.args['key'] != app.PGADMIN_INT_KEY) and
request.cookies.get('PGADMIN_INT_KEY') != request.cookies.get('PGADMIN_INT_KEY') != app.PGADMIN_INT_KEY and
app.PGADMIN_INT_KEY and request.endpoint != 'help.static'): request.endpoint != 'help.static'
):
abort(401) abort(401)
if not config.SERVER_MODE and not current_user.is_authenticated: if not config.SERVER_MODE and not current_user.is_authenticated:
@ -642,10 +643,9 @@ def create_app(app_name=None):
# if the server is restarted the in memory key will be lost # if the server is restarted the in memory key will be lost
# but the user session may still be active. Logout the user # but the user session may still be active. Logout the user
# to get the key again when login # to get the key again when login
if config.SERVER_MODE and current_user.is_authenticated: if config.SERVER_MODE and current_user.is_authenticated and \
if current_app.keyManager.get() is None and \ current_app.keyManager.get() is None and \
request.endpoint not in ('security.login', request.endpoint not in ('security.login', 'security.logout'):
'security.logout'):
logout_user() logout_user()
@app.after_request @app.after_request