From d48dbc6bbb7b9484303afc4ab26d323f5b90cc20 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 6 Aug 2014 00:59:03 +0200 Subject: [PATCH 1/2] Creating method of shutdown actions --- headphones/webserve.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index eea2b836..7b52f4e8 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -1393,25 +1393,23 @@ class WebInterface(object): configUpdate.exposed = True + def do_shutdown(self, signal, title, timer): + headphones.SIGNAL = signal + message = title + '...' + return serve_template(templatename="shutdown.html", title=title, + message=message, timer=timer) + def shutdown(self): - headphones.SIGNAL = 'shutdown' - message = 'Shutting Down...' - return serve_template(templatename="shutdown.html", title="Shutting Down", message=message, timer=15) - return page + return self.do_shutdown('shutdown', 'Shutting Down', 15) shutdown.exposed = True def restart(self): - headphones.SIGNAL = 'restart' - message = 'Restarting...' - return serve_template(templatename="shutdown.html", title="Restarting", message=message, timer=30) + return self.do_shutdown('restart', 'Restarting', 30) restart.exposed = True def update(self): - headphones.SIGNAL = 'update' - message = 'Updating...' - return serve_template(templatename="shutdown.html", title="Updating", message=message, timer=120) - return page + return self.do_shutdown('update', 'Updating', 120) update.exposed = True def extras(self): From 9ec4866cea04385314d595ac82f12ef545a99360 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 6 Aug 2014 12:10:03 +0200 Subject: [PATCH 2/2] renaming do_shutdown() -> do_state_change() --- headphones/webserve.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index 7b52f4e8..8d43c87d 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -1393,23 +1393,22 @@ class WebInterface(object): configUpdate.exposed = True - def do_shutdown(self, signal, title, timer): + def do_state_change(self, signal, title, timer): headphones.SIGNAL = signal message = title + '...' return serve_template(templatename="shutdown.html", title=title, message=message, timer=timer) def shutdown(self): - return self.do_shutdown('shutdown', 'Shutting Down', 15) - + return self.do_state_change('shutdown', 'Shutting Down', 15) shutdown.exposed = True def restart(self): - return self.do_shutdown('restart', 'Restarting', 30) + return self.do_state_change('restart', 'Restarting', 30) restart.exposed = True def update(self): - return self.do_shutdown('update', 'Updating', 120) + return self.do_state_change('update', 'Updating', 120) update.exposed = True def extras(self):