Module: check_mk
Branch: master
Commit: 302c84ded64fef5d78d2ad99eceba082a27196d2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=302c84ded64fef…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Fri Oct 26 09:55:24 2018 +0200
YAPFed web directory
CMK-1180
Change-Id: Ic0f3688c7406c0445e6abf8958dca32ce3d5c10f
---
web/app/index.wsgi | 39 ++++++++++++++++++---------------------
1 file changed, 18 insertions(+), 21 deletions(-)
diff --git a/web/app/index.wsgi b/web/app/index.wsgi
index c1230e0..33ae521 100644
--- a/web/app/index.wsgi
+++ b/web/app/index.wsgi
@@ -55,11 +55,13 @@ from cmk.gui.exceptions import (
MKAuthException,
MKUnauthenticatedException,
FinalizeRequest,
- HTTPRedirect
+ HTTPRedirect,
)
+
class Application(object):
"""The Check_MK GUI WSGI entry point"""
+
def __init__(self, wsgi_environ, start_response):
self._start_response = start_response
self._request = cmk.gui.http.Request(wsgi_environ)
@@ -80,12 +82,12 @@ class Application(object):
self._process_request()
-
def _process_request(self):
try:
config.initialize()
- with cmk.profile.Profile(enabled=self._profiling_enabled(),
+ with cmk.profile.Profile(
+ enabled=self._profiling_enabled(),
profile_file=os.path.join(cmk.paths.var_dir,
"multisite.profile")):
self._handle_request()
@@ -96,8 +98,15 @@ class Application(object):
except FinalizeRequest, e:
html.response.set_status_code(e.status)
- except (MKUserError, MKAuthException, MKUnauthenticatedException, MKConfigError,
MKGeneralException,
- livestatus.MKLivestatusNotFoundError, livestatus.MKLivestatusException),
e:
+ except (
+ MKUserError,
+ MKAuthException,
+ MKUnauthenticatedException,
+ MKConfigError,
+ MKGeneralException,
+ livestatus.MKLivestatusNotFoundError,
+ livestatus.MKLivestatusException,
+ ), e:
# TODO: Refactor all the special cases handled here to simplify the exception
handling
html.unplug_all()
@@ -110,7 +119,7 @@ class Application(object):
title = _("Livestatus problem")
plain_title = _("Livestatus problem")
else:
- title = e.title()
+ title = e.title()
plain_title = e.plain_title()
if self._plain_error():
@@ -121,7 +130,6 @@ class Application(object):
html.show_error(e)
html.footer()
-
# Some exception need to set a specific HTTP status code
if ty == MKUnauthenticatedException:
html.response.set_status_code(cmk.gui.http_status.HTTP_UNAUTHORIZED)
@@ -150,7 +158,6 @@ class Application(object):
logger.exception()
raise
-
def _teardown(self):
"""Final steps that are performed after each handled HTTP
request"""
store.release_all_locks()
@@ -159,7 +166,6 @@ class Application(object):
html.finalize()
cmk.gui.globals.html.unset_current()
-
def _handle_request(self):
html.init_modes()
@@ -206,13 +212,11 @@ class Application(object):
self._ensure_general_access()
handler()
-
def _show_exception_info(self, e):
html.write_text("%s" % e)
if config.debug:
html.write_text(traceback.format_exc())
-
def _handle_not_authenticated(self):
if self._fail_silently():
# While api call don't show the login dialog
@@ -223,7 +227,7 @@ class Application(object):
# or "dashboard.py". This results in strange problems.
if html.myfile != 'login':
html.response.http_redirect('%scheck_mk/login.py?_origtarget=%s' %
- (config.url_prefix(), html.urlencode(html.makeuri([]))))
+ (config.url_prefix(),
html.urlencode(html.makeuri([]))))
else:
# This either displays the login page or validates the information submitted
# to the login form. After successful login a http redirect to the
originally
@@ -232,7 +236,6 @@ class Application(object):
raise FinalizeRequest()
-
def _localize_request(self):
previous_language = cmk.gui.i18n.get_current_language()
user_language = html.get_ascii_input("lang", config.user.language())
@@ -246,29 +249,25 @@ class Application(object):
if cmk.gui.i18n.get_current_language() != previous_language:
modules.load_all_plugins()
-
def _fail_silently(self):
"""Ajax-Functions want no HTML output in case of an error but
just a plain server result code of 500"""
return html.has_var("_ajaxid")
-
def _plain_error(self):
"""Webservice functions may decide to get a normal result code
but a text with an error message in case of an error"""
return html.has_var("_plain_error") or html.myfile ==
"webapi"
-
def _profiling_enabled(self):
if config.profile == False:
- return False # Not enabled
+ return False # Not enabled
if config.profile == "enable_by_var" and not
html.has_var("_profile"):
- return False # Not enabled by HTTP variable
+ return False # Not enabled by HTTP variable
return True
-
# TODO: This is a page handler. It should not be located in generic application
# object. Move it to another place
def _page_not_found(self):
@@ -279,7 +278,6 @@ class Application(object):
html.show_error(_("This page was not found. Sorry."))
html.footer()
-
def _ensure_general_access(self):
if config.user.may("general.use"):
return
@@ -302,7 +300,6 @@ class Application(object):
raise MKAuthException(" ".join(reason))
-
def __iter__(self):
"""Is called by the WSGI server to serve the current
page"""
self._start_response(self._response.http_status, self._response.headers)