Mercurial > bottledash
view dash.py @ 6:3acc5164369e
resize content in height too
author | sean |
---|---|
date | Wed, 22 Jul 2015 10:47:55 +0200 |
parents | c49f7fe82743 |
children | c8cb2aa0b72c |
line wrap: on
line source
""" This software is part of "Bottledash" author: sean engelhardt > sean.engelhardt@intevation.de license: GNU >= V2. See LICENSE for details """ from bottle import get, post, request, view, response, route from bottle import template, run, static_file, error import configparser import os.path CONFIG_FILE = "dash.conf" tiles = [] def read_config(): if os.path.isfile(CONFIG_FILE) == False: write_default_config() config = configparser.ConfigParser() config.read(CONFIG_FILE) #read the tiles read_tiles_config(config) def read_tiles_config(config): for section in config.items(): if "tile" in section[0]: tiles.append(section[1]) # print(tiles[0]["type"]) def write_default_config(): file = open("dash.conf", "w") file.write(""" ### bottledash default configuration ### created by sean engelhardt >sean.engelhardt@intevation.de ### license: GNU GPL >= v2 ### ### Usage: ### define the tiles for the dashboard in sections ### ### options for tiles: ### ### type ### values: mon, d3.js ### ### source (only if type = mon) ### value: IP or FQDN ### status ### ### status (for debug purpose only | only if type = mon) ### values: up, down ### ### example: ### [tile1] ### type=mon ### source=192.168.0.2 ### status=up [tile1] type=mon source=192.168.0.2 status=down [tile2] type=mon source=192.168.2.1 status=up """) file.close() ##Bottle @route('/') @view('hello_template') def call_dashboard(): return dict(tiles=tiles) @route('/config') def call_config(): return 'Not implemented yet' @route('/static/<filepath:path>') def server_static(filepath): return static_file(filepath, root='./static_files/') @error(404) def error404(error): return 'Nothing here, sorry <br /> 404' read_config() print(tiles) run(host='localhost', port=8080, debug=True)