lists.checkmk.com
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
List overview
Download
Checkmk git commits
July 2018
----- 2024 -----
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
checkmk-commits@lists.checkmk.com
10 participants
467 discussions
Start a n
N
ew thread
Refactored multiple snapins to new snapin API
by Lars Michelsen
Module: check_mk Branch: master Commit: 6791908e2e509c48a98fc39877ba88c5db45e418 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6791908e2e509c…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Thu Jul 12 09:10:23 2018 +0200 Refactored multiple snapins to new snapin API Change-Id: I7c3a5cc94e7110bb88f260dcbf65a9f18eb19a1e --- cmk/gui/plugins/sidebar/__init__.py | 78 +- cmk/gui/plugins/sidebar/about.py | 57 ++ {web => cmk/gui}/plugins/sidebar/bi.py | 6 + cmk/gui/plugins/sidebar/bookmarks.py | 369 +++++++++ cmk/gui/plugins/sidebar/master_control.py | 199 +++++ {web => cmk/gui}/plugins/sidebar/mkeventd.py | 14 +- {web => cmk/gui}/plugins/sidebar/nagvis_maps.py | 45 +- cmk/gui/plugins/sidebar/quicksearch.py | 998 ++++++++++++++++++++++++ {web => cmk/gui}/plugins/sidebar/shipped.py | 529 +------------ cmk/gui/plugins/sidebar/utils.py | 210 +++++ {web => cmk/gui}/plugins/sidebar/wato.py | 10 + cmk/gui/sidebar.py | 633 +-------------- web/plugins/pages/shipped.py | 4 - web/plugins/sidebar/search.py | 498 ------------ 14 files changed, 1990 insertions(+), 1660 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=6791908e2e…
6 years, 2 months
1
0
0
0
Refactored view plugins to new module hierarchy
by Lars Michelsen
Module: check_mk Branch: master Commit: 6ab6dabe32d5dce9ca71c708849ba9555451adf0 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6ab6dabe32d5dc…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Thu Jul 12 09:10:23 2018 +0200 Refactored view plugins to new module hierarchy * Moved web/plugins/views to cmk/gui/plugins/views * Moved web/plugins/icons to cmk/gui/plugins/views/icons * Moved web/plugins/perfometer to cmk/gui/plugins/views/perfometers * Plugins are real modules now * Did not change plugin API yet Change-Id: Ib61e60a438597ea6b923d7f5126abbdde2cd9afe --- cmk/gui/availability.py | 6 +- cmk/gui/display_options.py | 138 ++ cmk/gui/mobile.py | 6 +- cmk/gui/notifications.py | 5 +- cmk/gui/plugins/views/__init__.py | 58 + {web => cmk/gui}/plugins/views/availability.py | 4 + {web => cmk/gui}/plugins/views/bi.py | 13 +- {web => cmk/gui}/plugins/views/builtin.py | 6 + {web => cmk/gui}/plugins/views/commands.py | 17 +- {web => cmk/gui}/plugins/views/dashboard.py | 6 +- {web => cmk/gui}/plugins/views/datasources.py | 6 + cmk/gui/plugins/views/icons/__init__.py | 234 ++++ .../gui/plugins/views}/icons/builtin.py | 68 +- .../gui/plugins/views}/icons/inventory.py | 7 +- .../gui/plugins/views}/icons/mkeventd.py | 9 +- .../gui/plugins/views}/icons/wato.py | 8 + {web => cmk/gui}/plugins/views/inventory.py | 60 +- {web => cmk/gui}/plugins/views/layouts.py | 27 +- {web => cmk/gui}/plugins/views/mkeventd.py | 30 +- {web => cmk/gui}/plugins/views/mobile.py | 10 +- {web => cmk/gui}/plugins/views/painters.py | 399 +----- {web => cmk/gui}/plugins/views/perfometer.py | 127 +- cmk/gui/plugins/views/perfometers/__init__.py | 168 +++ .../plugins/views/perfometers}/active_checks.py | 4 + .../gui/plugins/views/perfometers}/check_mk.py | 9 + {web => cmk/gui}/plugins/views/sorters.py | 18 + cmk/gui/plugins/views/utils.py | 1429 ++++++++++++++++++++ {web => cmk/gui}/plugins/views/wato.py | 7 + {web => cmk/gui}/plugins/views/webservice.py | 10 +- cmk/gui/views.py | 1382 ++----------------- cmk/gui/visuals.py | 6 + cmk/gui/wato/__init__.py | 13 +- cmk/gui/watolib.py | 4 + cmk/gui/weblib.py | 146 +- tests/pylint/test_pylint_web.py | 7 - web/plugins/dashboard/dashlets.py | 8 +- web/plugins/pages/shipped.py | 3 +- web/plugins/views/filters.py | 32 - 38 files changed, 2460 insertions(+), 2030 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=6ab6dabe32…
6 years, 2 months
1
0
0
0
Updated SLA webapi plugin to new module hierarchy
by Lars Michelsen
Module: check_mk Branch: master Commit: 355efa897a773678e0a3cb4f91b250663ec31961 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=355efa897a7736…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Thu Jul 12 09:10:23 2018 +0200 Updated SLA webapi plugin to new module hierarchy Change-Id: I492e9c45b3f791bf89fd452da0208ab3825a7cea --- web/plugins/webapi/webapi.py | 119 ------------------------------------------- 1 file changed, 119 deletions(-) diff --git a/web/plugins/webapi/webapi.py b/web/plugins/webapi/webapi.py index 41c8eae..cb6f2f1 100644 --- a/web/plugins/webapi/webapi.py +++ b/web/plugins/webapi/webapi.py @@ -35,125 +35,6 @@ from cmk.gui.i18n import _ from cmk.gui.exceptions import MKUserError #. -# .--Helpers-------------------------------------------------------------. -# | _ _ _ | -# | | | | | ___| |_ __ ___ _ __ ___ | -# | | |_| |/ _ \ | '_ \ / _ \ '__/ __| | -# | | _ | __/ | |_) | __/ | \__ \ | -# | |_| |_|\___|_| .__/ \___|_| |___/ | -# | |_| | -# +----------------------------------------------------------------------+ - -def validate_request_keys(request, required_keys = None, optional_keys = None): - if required_keys: - missing = set(required_keys) - set(request.keys()) - if missing: - raise MKUserError(None, _("Missing required key(s): %s") % ", ".join(missing)) - - - all_keys = (required_keys or []) + (optional_keys or []) - for key in request.keys(): - if key not in all_keys: - raise MKUserError(None, _("Invalid key: %s") % key) - - -def check_hostname(hostname, should_exist = True): - # Validate hostname with valuespec - Hostname().validate_value(hostname, "hostname") - - if should_exist: - host = watolib.Host.host(hostname) - if not host: - raise MKUserError(None, _("No such host")) - else: - if watolib.Host.host_exists(hostname): - raise MKUserError(None, _("Host %s already exists in the folder %s") % (hostname, watolib.Host.host(hostname).folder().path())) - - -# Check if the given attribute name exists, no type check -def validate_general_host_attributes(host_attributes): - # inventory_failed and site are no "real" host_attributes (TODO: Clean this up!) - all_host_attribute_names = map(lambda (x, y): x.name(), watolib.all_host_attributes()) + ["inventory_failed", "site"] - for name, value in host_attributes.items(): - if name not in all_host_attribute_names: - raise MKUserError(None, _("Unknown attribute: %s") % html.attrencode(name)) - - # For real host attributes validate the values - try: - attr = watolib.host_attribute(name) - except KeyError: - attr = None - - if attr != None: - if attr.needs_validation("host"): - attr.validate_input(value, "") - - # The site attribute gets an extra check - if name == "site" and value not in config.allsites().keys(): - raise MKUserError(None, _("Unknown site %s") % html.attrencode(value)) - - -# Check if the tag group exists and the tag value is valid -def validate_host_tags(host_tags): - for key, value in host_tags.items(): - for group_entry in config.host_tag_groups(): - if group_entry[0] == key: - for value_entry in group_entry[2]: - if value_entry[0] == value: - break - else: - raise MKUserError(None, _("Unknown host tag %s") % html.attrencode(value)) - break - else: - raise MKUserError(None, _("Unknown host tag group %s") % html.attrencode(key)) - - -def validate_host_attributes(attributes): - validate_general_host_attributes(dict((key, value) for key, value in attributes.items() if not key.startswith("tag_"))) - validate_host_tags(dict((key[4:], value) for key, value in attributes.items() if key.startswith("tag_"))) - - -def compute_config_hash(entity): - import json, md5 - try: - entity_encoded = json.dumps(entity, sort_keys=True) - entity_hash = md5.md5(entity_encoded).hexdigest() - except Exception, e: - logger.error("Error %s" % e) - entity_hash = "0" - - return entity_hash - - -def validate_config_hash(hash_value, entity): - entity_hash = compute_config_hash(entity) - if hash_value != entity_hash: - raise MKUserError(None, _("The configuration has changed in the meantime. "\ - "You need to load the configuration and start another update. " - "If the existing configuration should not be checked, you can " - "remove the configuration_hash value from the request object.")) - - -def add_configuration_hash(response, configuration_object): - response["configuration_hash"] = compute_config_hash(configuration_object) - - - -class APICallCollection(object): - @classmethod - def all_classes(cls): - classes = {} - for subclass in cls.__subclasses__(): # pylint: disable=no-member - classes[subclass.__name__] = subclass - - return classes.values() - - - def get_api_calls(self): - raise NotImplementedError("This API collection does not register any API call") - - -#. # .--Folders-------------------------------------------------------------. # | _____ _ _ | # | | ___|__ | | __| | ___ _ __ ___ |
6 years, 2 months
1
0
0
0
Cleaned up index imports
by Lars Michelsen
Module: check_mk Branch: master Commit: b7129256285c217df4c8a886f3422c1015b6d7d2 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b7129256285c21…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Thu Jul 12 09:10:23 2018 +0200 Cleaned up index imports Change-Id: If0aa76f5909f2f6b26caf5a5db2ebf3844db4860 --- web/app/index.wsgi | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/web/app/index.wsgi b/web/app/index.wsgi index 03404c5..0cc924e 100644 --- a/web/app/index.wsgi +++ b/web/app/index.wsgi @@ -47,14 +47,15 @@ import cmk.gui.http_status import cmk.paths import cmk.store as store -from cmk.gui.exceptions import \ - MKUserError, \ - MKConfigError, \ - MKGeneralException, \ - MKAuthException, \ - MKUnauthenticatedException, \ - FinalizeRequest, \ +from cmk.gui.exceptions import ( + MKUserError, + MKConfigError, + MKGeneralException, + MKAuthException, + MKUnauthenticatedException, + FinalizeRequest, HTTPRedirect +) class Application(object): """The Check_MK GUI WSGI entry point"""
6 years, 2 months
1
0
0
0
Refactored cron plugins to new module hierarchy
by Lars Michelsen
Module: check_mk Branch: master Commit: 3f03b96cd2520170de80c5a9466c88d8696728f9 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3f03b96cd25201…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Thu Jul 12 09:10:23 2018 +0200 Refactored cron plugins to new module hierarchy * Moved web/plugins/cron to cmk/gui/plugins/cron * Plugins are real modules now * Did not change plugin API yet Change-Id: Ie2f85883a39acb0f334f9f695949d673ab8b2833 --- cmk/gui/cron.py | 18 +++---- cmk/gui/plugins/cron/__init__.py | 60 ++++++++++++++++++++++ .../gui}/plugins/cron/gui_background_job.py | 2 + {web => cmk/gui}/plugins/cron/network_scan.py | 2 + {web => cmk/gui}/plugins/cron/user_sync.py | 1 + 5 files changed, 73 insertions(+), 10 deletions(-) diff --git a/cmk/gui/cron.py b/cmk/gui/cron.py index 80b9114..50cac3a 100644 --- a/cmk/gui/cron.py +++ b/cmk/gui/cron.py @@ -28,16 +28,20 @@ import os import time import traceback -import cmk.gui.utils as utils -from cmk.gui.log import logger import cmk.paths import cmk.store as store -import cmk.gui.i18n +import cmk.gui.utils as utils +from cmk.gui.log import logger +import cmk.gui.i18n from cmk.gui.exceptions import MKGeneralException +from cmk.gui.plugins.cron import ( + multisite_cronjobs, + register_job, +) + loaded_with_language = False -multisite_cronjobs = [] lock_file = cmk.paths.tmp_dir + "/cron.lastrun" @@ -47,17 +51,11 @@ def load_plugins(force): if loaded_with_language == cmk.gui.i18n.get_current_language() and not force: return - global multisite_cronjobs - multisite_cronjobs = [] utils.load_web_plugins("cron", globals()) loaded_with_language = cmk.gui.i18n.get_current_language() -def register_job(cron_job): - multisite_cronjobs.append(cron_job) - - # Page called by some external trigger (usually cron job in OMD site) # Note: this URL is being called *without* any login. We have no # user. Everyone can call this! We must not read any URL variables. diff --git a/cmk/gui/plugins/cron/__init__.py b/cmk/gui/plugins/cron/__init__.py new file mode 100644 index 0000000..ce9e549 --- /dev/null +++ b/cmk/gui/plugins/cron/__init__.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at
http://mathias-kettner.de/check_mk
. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +import os +import glob + +from cmk.gui.i18n import _ + +modules = glob.glob(os.path.join(os.path.dirname(__file__), "*.py")) +__all__ = [ os.path.basename(f)[:-3] for f in modules if f not in [ "__init__.py", "utils.py" ] ] + +#. +# .--Plugin API----------------------------------------------------------. +# | ____ _ _ _ ____ ___ | +# | | _ \| |_ _ __ _(_)_ __ / \ | _ \_ _| | +# | | |_) | | | | |/ _` | | '_ \ / _ \ | |_) | | | +# | | __/| | |_| | (_| | | | | | / ___ \| __/| | | +# | |_| |_|\__,_|\__, |_|_| |_| /_/ \_\_| |___| | +# | |___/ | +# '----------------------------------------------------------------------' + +multisite_cronjobs = [] + +def register_job(cron_job): + multisite_cronjobs.append(cron_job) + +#. +# .--Plugins-------------------------------------------------------------. +# | ____ _ _ | +# | | _ \| |_ _ __ _(_)_ __ ___ | +# | | |_) | | | | |/ _` | | '_ \/ __| | +# | | __/| | |_| | (_| | | | | \__ \ | +# | |_| |_|\__,_|\__, |_|_| |_|___/ | +# | |___/ | +# '----------------------------------------------------------------------' + +from . import * diff --git a/web/plugins/cron/gui_background_job.py b/cmk/gui/plugins/cron/gui_background_job.py similarity index 98% rename from web/plugins/cron/gui_background_job.py rename to cmk/gui/plugins/cron/gui_background_job.py index 17cd08e..cd2f8b4 100644 --- a/web/plugins/cron/gui_background_job.py +++ b/cmk/gui/plugins/cron/gui_background_job.py @@ -29,6 +29,8 @@ import cmk.gui.background_job import cmk.gui.gui_background_job as gui_background_job from cmk.gui.log import logger +from . import register_job + def housekeeping(): housekeep_classes = gui_background_job.GUIBackgroundJob.get_concrete_subclasses() cmk.gui.background_job.BackgroundJobManager(logger).do_housekeeping(housekeep_classes) diff --git a/web/plugins/cron/network_scan.py b/cmk/gui/plugins/cron/network_scan.py similarity index 98% rename from web/plugins/cron/network_scan.py rename to cmk/gui/plugins/cron/network_scan.py index 849fe4b..9bb3a7d 100644 --- a/web/plugins/cron/network_scan.py +++ b/cmk/gui/plugins/cron/network_scan.py @@ -26,4 +26,6 @@ import cmk.gui.wato as wato +from . import register_job + register_job(wato.execute_network_scan_job) diff --git a/web/plugins/cron/user_sync.py b/cmk/gui/plugins/cron/user_sync.py similarity index 98% rename from web/plugins/cron/user_sync.py rename to cmk/gui/plugins/cron/user_sync.py index eeae924..7cf58ad 100644 --- a/web/plugins/cron/user_sync.py +++ b/cmk/gui/plugins/cron/user_sync.py @@ -25,5 +25,6 @@ # Boston, MA 02110-1301 USA. import cmk.gui.userdb as userdb +from . import register_job register_job(userdb.execute_userdb_job)
6 years, 2 months
1
0
0
0
Static analysis tools now know config options
by Lars Michelsen
Module: check_mk Branch: master Commit: 7ad3916c2d1069a584714ab118fef73fbe6d83e0 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7ad3916c2d1069…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Thu Jul 12 09:10:23 2018 +0200 Static analysis tools now know config options * Moved registration of main configuration options from web/plugins/config to cmk/gui/plugins/config * Plugins are real modules now * Did not change plugin API yet * Goal: Make static analysis tools know which config options are available in the namespaces of the config module. Change-Id: I59dd785edc8864ae959a5e8fe4f1d34c71d897d7 --- cmk/.f12 | 2 + cmk/gui/__init__.py | 0 cmk/gui/plugins/config/__init__.py | 53 ++++++++++ .../builtin.py => cmk/gui/plugins/config/base.py | 112 +++++++++++++++++++-- web/htdocs/config.py | 79 ++++++++++++++- web/plugins/config/bi.py | 35 ------- web/plugins/config/mkeventd.py | 42 -------- web/plugins/config/wato.py | 69 ------------- 8 files changed, 230 insertions(+), 162 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=7ad3916c2d…
6 years, 2 months
1
0
0
0
Moved HTTP status definitions to separate module
by Lars Michelsen
Module: check_mk Branch: master Commit: 04eecef96f58c050f08c310eba5c5536f8f3e7c6 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=04eecef96f58c0…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Thu Jul 12 09:10:23 2018 +0200 Moved HTTP status definitions to separate module Change-Id: I67c30b61929d988d1a5be3c570e77de0e6fb173c --- web/htdocs/gui_exceptions.py | 10 ++--- web/htdocs/http.py | 75 ++--------------------------------- web/htdocs/http_status.py | 93 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 76 deletions(-) diff --git a/web/htdocs/gui_exceptions.py b/web/htdocs/gui_exceptions.py index d2c1d1a..716797f 100644 --- a/web/htdocs/gui_exceptions.py +++ b/web/htdocs/gui_exceptions.py @@ -25,7 +25,7 @@ # Boston, MA 02110-1301 USA. -import http +import http_status from cmk.exceptions import MKGeneralException, MKException @@ -41,17 +41,17 @@ class FinalizeRequest(Exception): """Is used to end the HTTP request processing from deeper code levels""" # TODO: Drop this default and make exit code explicit for all call sites def __init__(self, code = None): - super(FinalizeRequest, self).__init__(http.http_status(code)) - self.status = code or http.HTTP_OK + super(FinalizeRequest, self).__init__(http_status.status_with_reason(code)) + self.status = code or http_status.HTTP_OK class HTTPRedirect(FinalizeRequest): """Is used to end the HTTP request processing from deeper code levels and making the client request another page after receiving the response.""" - def __init__(self, url, code=http.HTTP_MOVED_TEMPORARILY): + def __init__(self, url, code=http_status.HTTP_MOVED_TEMPORARILY): super(HTTPRedirect, self).__init__(code) - if code not in [ http.HTTP_MOVED_PERMANENTLY, http.HTTP_MOVED_TEMPORARILY ]: + if code not in [ http_status.HTTP_MOVED_PERMANENTLY, http_status.HTTP_MOVED_TEMPORARILY ]: raise Exception("Invalid status code: %d" % code) self.url = url diff --git a/web/htdocs/http.py b/web/htdocs/http.py index 5e7387c..7fd4d9e 100644 --- a/web/htdocs/http.py +++ b/web/htdocs/http.py @@ -31,74 +31,8 @@ import time import Cookie import cgi import log - -# TODO: Use definitions from httplib (Python 3: http.HTTPStatus) -HTTP_CONTINUE = 100 -HTTP_SWITCHING_PROTOCOLS = 101 -HTTP_PROCESSING = 102 -HTTP_OK = 200 -HTTP_CREATED = 201 -HTTP_ACCEPTED = 202 -HTTP_NON_AUTHORITATIVE = 203 -HTTP_NO_CONTENT = 204 -HTTP_RESET_CONTENT = 205 -HTTP_PARTIAL_CONTENT = 206 -HTTP_MULTI_STATUS = 207 -HTTP_MULTIPLE_CHOICES = 300 -HTTP_MOVED_PERMANENTLY = 301 -HTTP_MOVED_TEMPORARILY = 302 -HTTP_SEE_OTHER = 303 -HTTP_NOT_MODIFIED = 304 -HTTP_USE_PROXY = 305 -HTTP_TEMPORARY_REDIRECT = 307 -HTTP_BAD_REQUEST = 400 -HTTP_UNAUTHORIZED = 401 -HTTP_PAYMENT_REQUIRED = 402 -HTTP_FORBIDDEN = 403 -HTTP_NOT_FOUND = 404 -HTTP_METHOD_NOT_ALLOWED = 405 -HTTP_NOT_ACCEPTABLE = 406 -HTTP_PROXY_AUTHENTICATION_REQUIRED= 407 -HTTP_REQUEST_TIME_OUT = 408 -HTTP_CONFLICT = 409 -HTTP_GONE = 410 -HTTP_LENGTH_REQUIRED = 411 -HTTP_PRECONDITION_FAILED = 412 -HTTP_REQUEST_ENTITY_TOO_LARGE = 413 -HTTP_REQUEST_URI_TOO_LARGE = 414 -HTTP_UNSUPPORTED_MEDIA_TYPE = 415 -HTTP_RANGE_NOT_SATISFIABLE = 416 -HTTP_EXPECTATION_FAILED = 417 -HTTP_UNPROCESSABLE_ENTITY = 422 -HTTP_LOCKED = 423 -HTTP_FAILED_DEPENDENCY = 424 -HTTP_UPGRADE_REQUIRED = 426 -HTTP_INTERNAL_SERVER_ERROR = 500 -HTTP_NOT_IMPLEMENTED = 501 -HTTP_BAD_GATEWAY = 502 -HTTP_SERVICE_UNAVAILABLE = 503 -HTTP_GATEWAY_TIME_OUT = 504 -HTTP_VERSION_NOT_SUPPORTED = 505 -HTTP_VARIANT_ALSO_VARIES = 506 -HTTP_INSUFFICIENT_STORAGE = 507 -HTTP_NOT_EXTENDED = 510 - -def http_status(code): - if code == HTTP_OK: - return '200 OK' - elif code == HTTP_MOVED_TEMPORARILY: - return '301 Moved Permanently' - elif code == HTTP_MOVED_PERMANENTLY: - return '302 Found' - elif code == HTTP_NOT_MODIFIED: - return '304 Not Modified' - elif code == HTTP_INTERNAL_SERVER_ERROR: - return '500 Internal Server Error' - elif code == HTTP_NOT_FOUND: - return '404 Not Found' - else: - return str(code) - +import http_status +from gui_exceptions import HTTPRedirect class Request(object): """Provides information about the users HTTP request to the application @@ -354,7 +288,7 @@ class Response(object): self._request = request - self._status_code = HTTP_OK + self._status_code = http_status.HTTP_OK self._output = [] self._headers_out = [] @@ -413,7 +347,6 @@ class Response(object): def http_redirect(self, url): """Finalize the currently processed page with a HTTP redirect to the given URL""" - from gui_exceptions import HTTPRedirect raise HTTPRedirect(url) @@ -425,7 +358,7 @@ class Response(object): @property def http_status(self): """Provides the HTTP response status header (code incl. text)""" - return http_status(self._status_code) + return http_status.status_with_reason(self._status_code) @property diff --git a/web/htdocs/http_status.py b/web/htdocs/http_status.py new file mode 100644 index 0000000..4a5dfac --- /dev/null +++ b/web/htdocs/http_status.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at
http://mathias-kettner.de/check_mk
. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +# TODO: Use definitions from httplib (Python 3: http.HTTPStatus) +HTTP_CONTINUE = 100 +HTTP_SWITCHING_PROTOCOLS = 101 +HTTP_PROCESSING = 102 +HTTP_OK = 200 +HTTP_CREATED = 201 +HTTP_ACCEPTED = 202 +HTTP_NON_AUTHORITATIVE = 203 +HTTP_NO_CONTENT = 204 +HTTP_RESET_CONTENT = 205 +HTTP_PARTIAL_CONTENT = 206 +HTTP_MULTI_STATUS = 207 +HTTP_MULTIPLE_CHOICES = 300 +HTTP_MOVED_PERMANENTLY = 301 +HTTP_MOVED_TEMPORARILY = 302 +HTTP_SEE_OTHER = 303 +HTTP_NOT_MODIFIED = 304 +HTTP_USE_PROXY = 305 +HTTP_TEMPORARY_REDIRECT = 307 +HTTP_BAD_REQUEST = 400 +HTTP_UNAUTHORIZED = 401 +HTTP_PAYMENT_REQUIRED = 402 +HTTP_FORBIDDEN = 403 +HTTP_NOT_FOUND = 404 +HTTP_METHOD_NOT_ALLOWED = 405 +HTTP_NOT_ACCEPTABLE = 406 +HTTP_PROXY_AUTHENTICATION_REQUIRED= 407 +HTTP_REQUEST_TIME_OUT = 408 +HTTP_CONFLICT = 409 +HTTP_GONE = 410 +HTTP_LENGTH_REQUIRED = 411 +HTTP_PRECONDITION_FAILED = 412 +HTTP_REQUEST_ENTITY_TOO_LARGE = 413 +HTTP_REQUEST_URI_TOO_LARGE = 414 +HTTP_UNSUPPORTED_MEDIA_TYPE = 415 +HTTP_RANGE_NOT_SATISFIABLE = 416 +HTTP_EXPECTATION_FAILED = 417 +HTTP_UNPROCESSABLE_ENTITY = 422 +HTTP_LOCKED = 423 +HTTP_FAILED_DEPENDENCY = 424 +HTTP_UPGRADE_REQUIRED = 426 +HTTP_INTERNAL_SERVER_ERROR = 500 +HTTP_NOT_IMPLEMENTED = 501 +HTTP_BAD_GATEWAY = 502 +HTTP_SERVICE_UNAVAILABLE = 503 +HTTP_GATEWAY_TIME_OUT = 504 +HTTP_VERSION_NOT_SUPPORTED = 505 +HTTP_VARIANT_ALSO_VARIES = 506 +HTTP_INSUFFICIENT_STORAGE = 507 +HTTP_NOT_EXTENDED = 510 + + +def status_with_reason(code): + if code == HTTP_OK: + return '200 OK' + elif code == HTTP_MOVED_TEMPORARILY: + return '301 Moved Permanently' + elif code == HTTP_MOVED_PERMANENTLY: + return '302 Found' + elif code == HTTP_NOT_MODIFIED: + return '304 Not Modified' + elif code == HTTP_INTERNAL_SERVER_ERROR: + return '500 Internal Server Error' + elif code == HTTP_NOT_FOUND: + return '404 Not Found' + else: + return str(code)
6 years, 2 months
1
0
0
0
Fixed circular dependency between exceptions and http module
by Lars Michelsen
Module: check_mk Branch: master Commit: 6deebb9395c5cc126997f9a54a45e51e3e2d97eb URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6deebb9395c5cc…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Thu Jul 12 09:10:23 2018 +0200 Fixed circular dependency between exceptions and http module Moved gui_exceptions to cmk.gui.exceptions and http_status to cmk.gui.http_status Change-Id: I6cf512659cf87be69729418e48e93b115692a451 --- web/htdocs/gui_exceptions.py => cmk/gui/exceptions.py | 10 +++++----- {web/htdocs => cmk/gui}/http_status.py | 0 web/app/index.wsgi | 2 +- web/htdocs/backup.py | 2 +- web/htdocs/bi.py | 2 +- web/htdocs/config.py | 2 +- web/htdocs/crash_reporting.py | 2 +- web/htdocs/cron.py | 2 +- web/htdocs/dashboard.py | 2 +- web/htdocs/forms.py | 2 +- web/htdocs/guitester.py | 2 +- web/htdocs/htmllib.py | 2 +- web/htdocs/http.py | 8 ++++---- web/htdocs/inventory.py | 2 +- web/htdocs/key_mgmt.py | 2 +- web/htdocs/login.py | 2 +- web/htdocs/logwatch.py | 2 +- web/htdocs/metrics.py | 2 +- web/htdocs/mkeventd.py | 2 +- web/htdocs/mobile.py | 2 +- web/htdocs/multitar.py | 2 +- web/htdocs/notify.py | 2 +- web/htdocs/pagetypes.py | 2 +- web/htdocs/prediction.py | 2 +- web/htdocs/sidebar.py | 2 +- web/htdocs/userdb.py | 2 +- web/htdocs/valuespec.py | 2 +- web/htdocs/views.py | 2 +- web/htdocs/visuals.py | 2 +- web/htdocs/wato.py | 2 +- web/htdocs/watolib.py | 2 +- web/htdocs/webapi.py | 2 +- web/htdocs/weblib.py | 2 +- 33 files changed, 39 insertions(+), 39 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=6deebb9395…
6 years, 2 months
1
0
0
0
Declare SidebarSnapin base class as abstract
by Lars Michelsen
Module: check_mk Branch: master Commit: 788188a079b7ab90ba9bd104681c7a20ee7f67d4 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=788188a079b7ab…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Thu Jul 12 09:10:23 2018 +0200 Declare SidebarSnapin base class as abstract Change-Id: I549f4808915cbd75004ebbd02dd130cc6cfcce95 --- web/htdocs/sidebar.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/web/htdocs/sidebar.py b/web/htdocs/sidebar.py index 91a2049..a005ada 100644 --- a/web/htdocs/sidebar.py +++ b/web/htdocs/sidebar.py @@ -24,6 +24,7 @@ # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301 USA. +import abc import pprint import os import copy @@ -1145,6 +1146,9 @@ def register_snapin(snapin_id, snapin): class SidebarSnapin(object): + metaclass = abc.ABCMeta + + @abc.abstractmethod def title(self): raise NotImplementedError() @@ -1153,6 +1157,7 @@ class SidebarSnapin(object): return "" + @abc.abstractmethod def show(self): raise NotImplementedError()
6 years, 2 months
1
0
0
0
Cleaned up sidebar snapin plugin API
by Lars Michelsen
Module: check_mk Branch: master Commit: 857a0de5e54d3d07baef5dd75e0e76ad976d5cb9 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=857a0de5e54d3d…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Thu Jul 12 09:10:23 2018 +0200 Cleaned up sidebar snapin plugin API * Moved base class SidebarSnapin to plugin hierarchy * Extracted two snapins to dedicated files * Refactored them to use the new SidebarSnapin mechanism * Introduced a snapin registry object Change-Id: I0f42c55006cbedd5e74f8e7333636edc9cd38715 --- cmk/gui/plugins/__init__.py | 0 cmk/gui/plugins/sidebar/__init__.py | 45 ++ cmk/gui/plugins/sidebar/speedometer.py | 246 +++++++++ cmk/gui/plugins/sidebar/virtual_host_tree.py | 574 ++++++++++++++++++++ web/htdocs/sidebar.py | 96 ++-- web/plugins/sidebar/shipped.py | 774 --------------------------- 6 files changed, 909 insertions(+), 826 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=857a0de5e5…
6 years, 2 months
1
0
0
0
← Newer
1
...
29
30
31
32
33
34
35
...
47
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Results per page:
10
25
50
100
200