diff dash.py @ 8:8fc4db85f2f5

fixed a path error
author sean
date Wed, 29 Jul 2015 12:02:51 +0200
parents c8cb2aa0b72c
children b06cb7fbf7f8
line wrap: on
line diff
--- 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)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)