Merge branch 'develop'

This commit is contained in:
Remy
2011-08-12 18:16:00 -07:00
6 changed files with 40 additions and 26 deletions

View File

@@ -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__":

View File

@@ -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": []
});
});

View File

@@ -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": []
});
});

View File

@@ -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:

View File

@@ -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:

View File

@@ -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):