From 337a952a2bc41a3d77d15b29a7c7740fa4d7dd01 Mon Sep 17 00:00:00 2001 From: Remy Date: Fri, 12 Aug 2011 16:10:43 -0700 Subject: [PATCH 1/3] Updated history template to show most recent first --- data/interfaces/default/history.html | 4 ++-- data/interfaces/remix/history.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/data/interfaces/default/history.html b/data/interfaces/default/history.html index 77d80d87..b79a43af 100644 --- a/data/interfaces/default/history.html +++ b/data/interfaces/default/history.html @@ -69,9 +69,9 @@ "sInfo":"Showing _START_ to _END_ of _TOTAL_ items", "sInfoEmpty":"Showing 0 to 0 of 0 items", "sInfoFiltered":"(filtered from _MAX_ total items)"}, - "bStateSave": true, "iDisplayLength": 25, - "sPaginationType": "full_numbers" + "sPaginationType": "full_numbers", + "aaSorting": [] }); }); diff --git a/data/interfaces/remix/history.html b/data/interfaces/remix/history.html index 77d80d87..b79a43af 100644 --- a/data/interfaces/remix/history.html +++ b/data/interfaces/remix/history.html @@ -69,9 +69,9 @@ "sInfo":"Showing _START_ to _END_ of _TOTAL_ items", "sInfoEmpty":"Showing 0 to 0 of 0 items", "sInfoFiltered":"(filtered from _MAX_ total items)"}, - "bStateSave": true, "iDisplayLength": 25, - "sPaginationType": "full_numbers" + "sPaginationType": "full_numbers", + "aaSorting": [] }); }); From d330accbfcb305e9fb714b9c5b22d47771690410 Mon Sep 17 00:00:00 2001 From: Remy Date: Fri, 12 Aug 2011 17:19:53 -0700 Subject: [PATCH 2/3] Shutdown/restart signals now handled by the main thread --- Headphones.py | 15 +++++++++++++++ headphones/__init__.py | 9 ++++++--- headphones/webserve.py | 10 +++------- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/Headphones.py b/Headphones.py index ccef9ec1..4487df68 100644 --- a/Headphones.py +++ b/Headphones.py @@ -1,5 +1,6 @@ #!/usr/bin/env python import os, sys +import time from lib.configobj import ConfigObj @@ -99,6 +100,20 @@ def main(): # Start the background threads headphones.start() + while True: + if not headphones.SIGNAL: + time.sleep(1) + else: + logger.info('Received signal: ' + headphones.SIGNAL) + if headphones.SIGNAL == 'shutdown': + headphones.shutdown() + elif headphones.SIGNAL == 'restart': + headphones.shutdown(restart=True) + else: + headphones.shutdown(restart=True, update=True) + + headphones.SIGNAL = None + return if __name__ == "__main__": diff --git a/headphones/__init__.py b/headphones/__init__.py index 7f4d7e6b..7b1fc2fb 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -18,7 +18,7 @@ FULL_PATH = None PROG_DIR = None ARGS = None -INVOKED_COMMAND = None +SIGNAL = None QUIET = False DAEMON = False @@ -496,20 +496,23 @@ def dbcheck(): def shutdown(restart=False, update=False): - + cherrypy.engine.exit() SCHED.shutdown(wait=False) config_write() + if not restart and not update: + logger.info('Headphones is shutting down...') if update: + logger.info('Headphones is updating...') try: versioncheck.update() except Exception, e: logger.warn('Headphones failed to update: %s. Restarting.' % e) if restart: - + logger.info('Headphones is restarting...') popen_list = [sys.executable, FULL_PATH] popen_list += ARGS if '--nolaunch' not in popen_list: diff --git a/headphones/webserve.py b/headphones/webserve.py index c03c2790..399d22ee 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -397,8 +397,7 @@ class WebInterface(object): configUpdate.exposed = True def shutdown(self): - logger.info(u"Headphones is shutting down...") - threading.Timer(2, headphones.shutdown).start() + headphones.SIGNAL = 'shutdown' message = 'Shutting Down...' return serve_template(templatename="shutdown.html", title="Shutting Down", message=message, timer=15) return page @@ -406,19 +405,16 @@ class WebInterface(object): shutdown.exposed = True def restart(self): - logger.info(u"Headphones is restarting...") - threading.Timer(2, headphones.shutdown, [True]).start() + headphones.SIGNAL = 'restart' message = 'Restarting...' return serve_template(templatename="shutdown.html", title="Restarting", message=message, timer=30) restart.exposed = True def update(self): - logger.info('Headphones is updating...') - threading.Timer(2, headphones.shutdown, [True, True]).start() + headphones.SIGNAL = 'update' message = 'Updating...' return serve_template(templatename="shutdown.html", title="Updating", message=message, timer=120) return page - update.exposed = True def extras(self): From 21a9fdfcc8967885ebaee7c33a87940a5fc7917b Mon Sep 17 00:00:00 2001 From: Remy Date: Fri, 12 Aug 2011 18:12:45 -0700 Subject: [PATCH 3/3] Fix for folder permissions - now chmods after files are moved --- headphones/postprocessor.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index 75cb124c..367b3889 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -314,26 +314,18 @@ def moveFiles(albumpath, release, tracks): if os.path.exists(destination_path): i = 1 while True: - new_folder_name = destination_path + '[%i]' % i - if os.path.exists(new_folder_name): + newfolder = folder + '[%i]' % i + destination_path = os.path.normpath(os.path.join(headphones.DESTINATION_DIR, newfolder)) + if os.path.exists(destination_path): i += 1 else: - destination_path = new_folder_name + folder = newfolder break logger.info('Moving files from %s to %s' % (albumpath, destination_path)) try: os.makedirs(destination_path) - - # Chmod the directories using the folder_format (script courtesy of premiso!) - folder_list = folder.split('/') - - - temp_f = os.path.join(headphones.DESTINATION_DIR); - for f in folder_list: - temp_f = os.path.join(temp_f, f) - os.chmod(temp_f, int(headphones.FOLDER_PERMISSIONS, 8)) except Exception, e: logger.error('Could not create folder for %s. Not moving: %s' % (release['AlbumTitle'], e)) @@ -343,6 +335,14 @@ def moveFiles(albumpath, release, tracks): for files in f: shutil.move(os.path.join(r, files), destination_path) + # Chmod the directories using the folder_format (script courtesy of premiso!) + folder_list = folder.split('/') + + temp_f = headphones.DESTINATION_DIR + for f in folder_list: + temp_f = os.path.join(temp_f, f) + os.chmod(temp_f, int(headphones.FOLDER_PERMISSIONS, 8)) + try: shutil.rmtree(albumpath) except Exception, e: