From 611fae1aa545b91e3ebc1292fa4c261555133721 Mon Sep 17 00:00:00 2001 From: Remy Date: Fri, 29 Jul 2011 11:39:16 -0700 Subject: [PATCH] Better error handling in the post-processor --- headphones/importer.py | 4 ++-- headphones/postprocessor.py | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/headphones/importer.py b/headphones/importer.py index 9385d51c..aba111fd 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -132,11 +132,11 @@ def artistlist_to_mbids(artistlist): myDB.upsert("artists", newValueDict, controlValueDict) # Update the cloud: - logger.info('Updating the cloud') + logger.info('Updating artist information from Last.fm') try: lastfm.getSimilar() except Exception, e: - logger.warn('Updating the cloud failed: %s' % e) + logger.warn('Failed to update arist information from Last.fm: %s' % e) def addArtisttoDB(artistid, extrasonly=False): diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index 91d4f2aa..f3a4a720 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -135,7 +135,7 @@ def cleanupFiles(albumpath): os.remove(os.path.join(r, files)) def moveFiles(albumpath, release, tracks): - + try: year = release['ReleaseDate'][:4] except TypeError: @@ -187,7 +187,7 @@ def correctMetadata(albumid, release, downloaded_track_list): item.write() def renameFiles(albumpath, downloaded_track_list, release): - + logger.info('Renaming files') try: year = release['ReleaseDate'][:4] except TypeError: @@ -214,7 +214,11 @@ def renameFiles(albumpath, downloaded_track_list, release): new_file = os.path.join(albumpath, new_file_name) - shutil.move(downloaded_track, new_file) + try: + shutil.move(downloaded_track, new_file) + except Exception, e: + logger.error('Error renaming file: %s. Error: %s' % (downloaded_track, e)) + continue def updateHave(albumpath):