Mercurial > bottledash
diff dash.py @ 20:1a13a4ecf931
can not recive post-requests wich should deliver if a server is up or down. Updated after a refresh of the webpage, wich will automatically done after 5 seconds
author | sean |
---|---|
date | Wed, 12 Aug 2015 13:45:58 +0200 |
parents | be6a1aaec717 |
children | f730dd0bcf85 |
line wrap: on
line diff
--- a/dash.py Tue Aug 11 14:18:09 2015 +0200 +++ b/dash.py Wed Aug 12 13:45:58 2015 +0200 @@ -36,16 +36,28 @@ logger.addHandler(hdlr) logger.setLevel(logging.INFO) -##read the config file. usually "dash.conf" +### debug function: prints the current status of the "tiles" in +### the log-file +def log_tile_status(): + global tiles + + try: + for tile in tiles: + logger.info("found tile : " + str(tile)) + for option in tiles[0]: + logger.info(str(option) + ' : ' + str(tile[option])) + except KeyError: + pass + +###read the config file. usually "dash.conf" def read_config(): - + global settings # print(PATH) - global settings if os.path.isfile(CONFIG_PATH) == False: write_default_config() - print("read existing config file...") + # print("read existing config file...") config = configparser.ConfigParser() config.read(CONFIG_PATH) @@ -53,6 +65,10 @@ if "tile" in section[0]: tiles.append(section[1]) + ###log read tiles + logger.info("------- read tiles --------") + log_tile_status() + try: if config["settings"]: settings = config["settings"] @@ -117,8 +133,6 @@ # # script: (name of a script without extension) [required for d3js-types0] # - - [tile1] type=mon source=192.168.0.2 @@ -138,7 +152,6 @@ type=d3js div_name=techintern script=display_issues_techintern - """) file.close() @@ -148,25 +161,27 @@ def call_dashboard(): return dict(tiles=tiles, settings=settings) +#wait for post-request which shall inform the system about running services @post('/updown') def updown(): + global tiles + service = request.forms.get('service') status = request.forms.get('status') + try: + for tile in tiles: + if tile["source"] == str(service): + tile["status"] = str(status) + except KeyError: + logger.info("this tile got no source : " + str(tile)) + logger.info('------- new alert --------') logger.info('Service : ' + str(service)) logger.info('Status : ' + str(status)) - logger.info('--------------------------') - return "thx! :: " + str(service) + " is " + str(status) + " !" + log_tile_status() -@route('/config') -def call_config(): - return 'Not implemented yet' - - -@route('/static/<filepath:path>') -def server_static(filepath): - return static_file(filepath, root='./static_files/') + return "thanks for informing bottledash! :: " + str(service) + " is " + str(status) + " !" @error(404) def error404(error):