From 8387ed838396444f64d734b7cfa655e5549b15f1 Mon Sep 17 00:00:00 2001 From: Remy Date: Thu, 14 Jul 2011 22:15:36 -0700 Subject: [PATCH] Fixed the updater issue hopefully - threaded shutdown/restart/update process --- Headphones.py | 1 - headphones/__init__.py | 13 +++++-------- headphones/webserve.py | 19 +++++++++++-------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Headphones.py b/Headphones.py index e457a2e5..f8053ff4 100755 --- a/Headphones.py +++ b/Headphones.py @@ -98,7 +98,6 @@ def main(): # Start the background threads headphones.start() - return diff --git a/headphones/__init__.py b/headphones/__init__.py index cff12df6..8bd2afa7 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -1,3 +1,5 @@ +from __future__ import with_statement + import os, sys, subprocess import threading @@ -361,7 +363,6 @@ def start(): # Check for new versions versioncheck.checkGithub() - started = True def dbcheck(): @@ -395,13 +396,9 @@ def shutdown(restart=False, update=False): popen_list = [sys.executable, FULL_PATH] popen_list += ARGS - #if '--nolaunch' not in popen_list: - # popen_list += ['--nolaunch'] + if '--nolaunch' not in popen_list: + popen_list += ['--nolaunch'] logger.info('Restarting Headphones with ' + str(popen_list)) subprocess.Popen(popen_list, cwd=os.getcwd()) - os._exit(0) - -def refresh(): - - raise cherrypy.HTTPRedirect("home") \ No newline at end of file + os._exit(0) \ No newline at end of file diff --git a/headphones/webserve.py b/headphones/webserve.py index c7c5ff3f..9702baae 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -10,7 +10,7 @@ import string import time import datetime import sqlite3 -from threading import Thread +import threading import headphones from headphones.mb import getReleaseGroup @@ -26,7 +26,7 @@ class WebInterface(object): def home(self): page = [templates._header] - if not headphones.LATEST_VERSION: + if not headphones.CURRENT_VERSION: page.append('''
You're running an unknown version of Heapdhones. Click here to update
''') elif headphones.CURRENT_VERSION != headphones.LATEST_VERSION and headphones.INSTALL_TYPE != 'win': page.append('''
A @@ -627,21 +627,24 @@ class WebInterface(object): def shutdown(self): logger.info(u"Headphones is shutting down...") - headphones.shutdown() - return 'Shutting down Headphones...' + threading.Timer(2, headphones.shutdown).start() + return ''' + Shutting Down Headphones....''' shutdown.exposed = True def restart(self): logger.info(u"Headphones is restarting...") - headphones.shutdown(restart=True) - return 'Restarting Headphones...' + threading.Timer(2, headphones.shutdown, [True]).start() + return ''' + Restarting Headphones....''' restart.exposed = True def update(self): logger.info('Headphones is updating...') - headphones.shutdown(restart=True, update=True) - return 'Updating Headphones...' + threading.Timer(2, headphones.shutdown, [True, True]).start() + return ''' + Updating Headphones....''' update.exposed = True \ No newline at end of file