From 500a8f1e790f1f888229a9916bf4fb1fe4d1643a Mon Sep 17 00:00:00 2001 From: James Vasile Date: Wed, 6 Feb 2013 12:39:05 -0500 Subject: [PATCH] write cherrypy.config if needed --- plinth.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/plinth.py b/plinth.py index ef13e593f..abca100ce 100755 --- a/plinth.py +++ b/plinth.py @@ -7,6 +7,33 @@ import cfg if not os.path.join(cfg.file_root, "vendor") in sys.path: sys.path.append(os.path.join(cfg.file_root, "vendor")) + +def write_cherrypy_config_if_needed(): + """If there is no cherrpy.config, write one.""" + if not os.path.exists(os.path.join(cfg.file_root, "cherrypy.config")): + with open(os.path.join(cfg.file_root, "cherrypy.config"), 'w') as OUTF: + OUTF.write(""" +[global] +server.socket_host = '0.0.0.0' +server.socket_port = 8000 +server.thread_pool = 10 +tools.staticdir.root = "%(file_root)s" +tools.sessions.on = True +tools.auth.on = True +tools.sessions.storage_type = "file" +tools.sessions.timeout = 90 +tools.sessions.storage_path = "%(data_dir)s/cherrypy_sessions" + +[/static] +tools.staticdir.on = True +tools.staticdir.dir = "static" + +[/favicon.ico] +tools.staticfile.on = True +tools.staticfile.filename = "%(file_root)s/static/theme/favicon.ico" +""" % {'data_dir':cfg.data_dir, 'file_root':cfg.file_root}) + +write_cherrypy_config_if_needed() import cherrypy from cherrypy import _cpserver from cherrypy.process.plugins import Daemonizer