Commit 1d79b123 authored by Guillaume Seguin's avatar Guillaume Seguin

Look for configuration files in ~/.printrun/ before looking in `pwd`

parent 888143be
......@@ -26,3 +26,9 @@ def pixmapfile(filename):
if os.path.exists(candidate):
return candidate
return filename
def configfile(filename):
candidate = os.path.expanduser("~/.printrun/%s" % filename)
if os.path.exists(candidate):
return candidate
return filename
#!/usr/bin/python
import cherrypy, pronterface, re, ConfigParser, threading, sys
import pronterface
import cherrypy, re, ConfigParser, threading, sys
import os.path
from printrun.printrun_utils import configfile
users = {}
def PrintHeader():
......@@ -238,7 +241,7 @@ class WebInterface(object):
config = ConfigParser.SafeConfigParser(allow_no_value=True)
else:
config = ConfigParser.SafeConfigParser()
config.read('auth.config')
config.read(configfile('auth.config'))
users[config.get("user", "user")] = config.get("user", "pass")
self.pface = pface
global gPronterPtr
......@@ -358,7 +361,7 @@ def KillWebInterfaceThread():
def StartWebInterfaceThread(webInterface):
current_dir = os.path.dirname(os.path.abspath(__file__))
cherrypy.config.update({'engine.autoreload_on':False})
cherrypy.config.update("http.config")
cherrypy.config.update(configfile("http.config"))
conf = {'/css/style.css': {'tools.staticfile.on': True,
'tools.staticfile.filename': os.path.join(current_dir, 'css/style.css'),
},
......@@ -368,9 +371,9 @@ def StartWebInterfaceThread(webInterface):
'/images/control_z.png': {'tools.staticfile.on': True,
'tools.staticfile.filename': os.path.join(current_dir, 'images/control_z.png'),
}}
cherrypy.config.update("http.config")
cherrypy.config.update(configfile("http.config"))
cherrypy.quickstart(webInterface, '/', config=conf)
if __name__ == '__main__':
cherrypy.config.update("http.config")
cherrypy.config.update(configfile("http.config"))
cherrypy.quickstart(WebInterfaceStub())
......@@ -51,7 +51,7 @@ from printrun import printcore, gviz
from printrun.xybuttons import XYButtons
from printrun.zbuttons import ZButtons
from printrun.graph import Graph
from printrun.printrun_utils import pixmapfile
from printrun.printrun_utils import pixmapfile, configfile
import pronsole
webavail = False
......@@ -137,7 +137,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.panel.SetBackgroundColour(self.settings.bgcolor)
customdict={}
try:
execfile("custombtn.txt",customdict)
execfile(configfile("custombtn.txt"),customdict)
if len(customdict["btns"]):
if not len(self.custombuttons):
try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment