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): ...@@ -26,3 +26,9 @@ def pixmapfile(filename):
if os.path.exists(candidate): if os.path.exists(candidate):
return candidate return candidate
return filename return filename
def configfile(filename):
candidate = os.path.expanduser("~/.printrun/%s" % filename)
if os.path.exists(candidate):
return candidate
return filename
#!/usr/bin/python #!/usr/bin/python
import cherrypy, pronterface, re, ConfigParser, threading, sys import pronterface
import cherrypy, re, ConfigParser, threading, sys
import os.path import os.path
from printrun.printrun_utils import configfile
users = {} users = {}
def PrintHeader(): def PrintHeader():
...@@ -238,7 +241,7 @@ class WebInterface(object): ...@@ -238,7 +241,7 @@ class WebInterface(object):
config = ConfigParser.SafeConfigParser(allow_no_value=True) config = ConfigParser.SafeConfigParser(allow_no_value=True)
else: else:
config = ConfigParser.SafeConfigParser() config = ConfigParser.SafeConfigParser()
config.read('auth.config') config.read(configfile('auth.config'))
users[config.get("user", "user")] = config.get("user", "pass") users[config.get("user", "user")] = config.get("user", "pass")
self.pface = pface self.pface = pface
global gPronterPtr global gPronterPtr
...@@ -358,7 +361,7 @@ def KillWebInterfaceThread(): ...@@ -358,7 +361,7 @@ def KillWebInterfaceThread():
def StartWebInterfaceThread(webInterface): def StartWebInterfaceThread(webInterface):
current_dir = os.path.dirname(os.path.abspath(__file__)) current_dir = os.path.dirname(os.path.abspath(__file__))
cherrypy.config.update({'engine.autoreload_on':False}) 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, conf = {'/css/style.css': {'tools.staticfile.on': True,
'tools.staticfile.filename': os.path.join(current_dir, 'css/style.css'), 'tools.staticfile.filename': os.path.join(current_dir, 'css/style.css'),
}, },
...@@ -368,9 +371,9 @@ def StartWebInterfaceThread(webInterface): ...@@ -368,9 +371,9 @@ def StartWebInterfaceThread(webInterface):
'/images/control_z.png': {'tools.staticfile.on': True, '/images/control_z.png': {'tools.staticfile.on': True,
'tools.staticfile.filename': os.path.join(current_dir, 'images/control_z.png'), '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) cherrypy.quickstart(webInterface, '/', config=conf)
if __name__ == '__main__': if __name__ == '__main__':
cherrypy.config.update("http.config") cherrypy.config.update(configfile("http.config"))
cherrypy.quickstart(WebInterfaceStub()) cherrypy.quickstart(WebInterfaceStub())
...@@ -51,7 +51,7 @@ from printrun import printcore, gviz ...@@ -51,7 +51,7 @@ from printrun import printcore, gviz
from printrun.xybuttons import XYButtons from printrun.xybuttons import XYButtons
from printrun.zbuttons import ZButtons from printrun.zbuttons import ZButtons
from printrun.graph import Graph from printrun.graph import Graph
from printrun.printrun_utils import pixmapfile from printrun.printrun_utils import pixmapfile, configfile
import pronsole import pronsole
webavail = False webavail = False
...@@ -137,7 +137,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -137,7 +137,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.panel.SetBackgroundColour(self.settings.bgcolor) self.panel.SetBackgroundColour(self.settings.bgcolor)
customdict={} customdict={}
try: try:
execfile("custombtn.txt",customdict) execfile(configfile("custombtn.txt"),customdict)
if len(customdict["btns"]): if len(customdict["btns"]):
if not len(self.custombuttons): if not len(self.custombuttons):
try: 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