# HG changeset patch # User sean # Date 1438164171 -7200 # Node ID 8fc4db85f2f5bc5ba09df6f9d9fc55080a82ecb0 # Parent c8cb2aa0b72c723138bb32637798d06b36bbc7db fixed a path error diff -r c8cb2aa0b72c -r 8fc4db85f2f5 dash.py --- a/dash.py Wed Jul 22 13:31:25 2015 +0200 +++ b/dash.py Wed Jul 29 12:02:51 2015 +0200 @@ -6,10 +6,12 @@ from bottle import get, post, request, view, response, route from bottle import template, run, static_file, error -import configparser -import os.path +import os.path,sys,configparser CONFIG_FILE = "dash.conf" +PATH = os.path.abspath(os.path.dirname(sys.argv[0])) +CONFIG_PATH = PATH + "/" + CONFIG_FILE + tiles = [] settings = {} @@ -17,14 +19,18 @@ default_settings['settings'] = {'show_top_bar': True} ##read the config file. usually "dash.conf" + def read_config(): + + # print(PATH) global settings - if os.path.isfile(CONFIG_FILE) == False: + if os.path.isfile(CONFIG_PATH) == False: write_default_config() + print("read existing config file...") config = configparser.ConfigParser() - config.read(CONFIG_FILE) + config.read(CONFIG_PATH) for section in config.items(): if "tile" in section[0]: @@ -40,7 +46,8 @@ ###write the default condfig file if there is none def write_default_config(): - file = open("dash.conf", "w") + print("there is no Config file! Creating one...") + file = open(CONFIG_PATH, "w") file.write(""" ### bottledash default configuration ### created by sean engelhardt >sean.engelhardt@intevation.de @@ -133,4 +140,4 @@ read_config() # print(tiles) -run(host='localhost', port=8080, debug=True) +# run(host='localhost', port=8080, debug=True)