From 4ac7bd104dcba74f99af2a8b437f995e6589d961 Mon Sep 17 00:00:00 2001 From: KRKeegan <-NOSPAM-kevin@krkeegan.com> Date: Mon, 25 Feb 2008 16:31:56 -0800 Subject: [PATCH] Enable rereading of pyTivo.conf without restart Initial design. Causes config.py to reread the conf file. httpserver.py unloads a reloads the container dict Allof this is initiate through a restart command to the admin plugin. --- config.py | 6 +++++- httpserver.py | 5 +++++ plugins/admin/admin.py | 10 ++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index 52c37c1..674ab8f 100644 --- a/config.py +++ b/config.py @@ -6,7 +6,11 @@ BLACKLIST_169 = ('540', '649') config = ConfigParser.ConfigParser() p = os.path.dirname(__file__) -config.read(os.path.join(p, 'pyTivo.conf')) +config_file = os.path.join(p, 'pyTivo.conf') +config.read(config_file) + +def reset(): + config.read(config_file) def getGUID(): if config.has_option('Server', 'GUID'): diff --git a/httpserver.py b/httpserver.py index cd5137d..dd24992 100644 --- a/httpserver.py +++ b/httpserver.py @@ -39,6 +39,11 @@ class TivoHTTPServer(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer): except KeyError: print 'Unable to add container', name + def reset(self): + self.containers.clear() + for section, settings in config.getShares(): + self.add_container(section, settings) + class TivoHTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler): def address_string(self): diff --git a/plugins/admin/admin.py b/plugins/admin/admin.py index 96ce97b..770de18 100644 --- a/plugins/admin/admin.py +++ b/plugins/admin/admin.py @@ -1,4 +1,4 @@ -import os, socket, re, sys, ConfigParser +import os, socket, re, sys, ConfigParser, config from ConfigParser import NoOptionError from Cheetah.Template import Template from plugin import Plugin @@ -18,8 +18,14 @@ p = os.path.sep.join(p) config_file_path = os.path.join(p, 'pyTivo.conf') class Admin(Plugin): - CONTENT_TYPE = 'text/html' + + def Restart(self, handler, query): + config.reset() + handler.server.reset() + handler.send_response(200) + handler.end_headers() + def Admin(self, handler, query): #Read config file new each time in case there was any outside edits config = ConfigParser.ConfigParser() -- 2.11.4.GIT