# HG changeset patch # User Chris Cannam # Date 1246962867 0 # Node ID 9a4e410bda7ad9aea41f42a593efc551692d1113 # Parent 7d87bf308509f19b4130456aa5fef5099c1b92e8 * Add --force option, and throw/catch exceptions for failure cases rather than exiting directly diff -r 7d87bf308509 -r 9a4e410bda7a README --- a/README Mon Jun 29 13:47:12 2009 +0000 +++ b/README Tue Jul 07 10:34:27 2009 +0000 @@ -25,7 +25,7 @@ The main program is by Mark Levy, Chris Cannam, and Chris Sutton. Sonic Annotator incorporates library code from the Sonic Visualiser application by Chris Cannam. Code copyright 2005-2007 Chris Cannam, -copyright 2006-2008 Queen Mary, University of London, except where +copyright 2006-2009 Queen Mary, University of London, except where indicated in the individual source files. This work was funded by the Engineering and Physical Sciences Research diff -r 7d87bf308509 -r 9a4e410bda7a runner/FeatureExtractionManager.cpp --- a/runner/FeatureExtractionManager.cpp Mon Jun 29 13:47:12 2009 +0000 +++ b/runner/FeatureExtractionManager.cpp Tue Jul 07 10:34:27 2009 +0000 @@ -22,6 +22,8 @@ #include #include +#include "base/Exceptions.h" + #include using namespace std; @@ -373,7 +375,7 @@ if (!source.isAvailable()) { cerr << "ERROR: File or URL \"" << audioSource.toStdString() << "\" could not be located" << endl; - exit(1); + throw FileNotFound(audioSource); } source.waitForData(); @@ -389,7 +391,7 @@ } else { cerr << "ERROR: Playlist \"" << audioSource.toStdString() << "\" could not be opened" << endl; - exit(1); + throw FileNotFound(audioSource); } } @@ -402,9 +404,7 @@ AudioFileReaderFactory::createReader(source, m_sampleRate, &retrievalProgress); if (!reader) { - cerr << "ERROR: File or URL \"" << audioSource.toStdString() - << "\" could not be opened" << endl; - exit(1); + throw FailedToOpenFile(audioSource); } size_t channels = reader->getChannelCount(); @@ -415,9 +415,10 @@ // reject file if it has too few channels, plugin will handle if it has too many if ((int)channels < m_channels) { - //!!! should not be terminating here! - cerr << "ERROR: File or URL \"" << audioSource.toStdString() << "\" has less than " << m_channels << " channels" << endl; - exit(1); + throw FileOperationFailed + (audioSource, + QString("read sufficient channels (found %1, require %2)") + .arg(channels).arg(m_channels)); } // allocate audio buffers diff -r 7d87bf308509 -r 9a4e410bda7a runner/main.cpp --- a/runner/main.cpp Mon Jun 29 13:47:12 2009 +0000 +++ b/runner/main.cpp Tue Jul 07 10:34:27 2009 +0000 @@ -143,7 +143,7 @@ cerr << "Sonic Annotator v" << RUNNER_VERSION << endl; cerr << "A utility for batch feature extraction from audio files." << endl; cerr << "Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London." << endl; - cerr << "Copyright 2007-2008 Queen Mary, University of London." << endl; + cerr << "Copyright 2007-2009 Queen Mary, University of London." << endl; cerr << endl; cerr << "This program is free software. You may redistribute copies of it under the" << endl; cerr << "terms of the GNU General Public License ." << endl; @@ -246,6 +246,8 @@ cerr << " for all supported audio files and take all of those as" << endl; cerr << " input instead." << endl; cerr << endl; + cerr << " -f, --force Continue with subsequent files following an error." << endl; + cerr << endl; cerr << "Housekeeping options:" << endl; cerr << endl; cerr << " -l, --list List all known transform ids to standard output." << endl; @@ -360,6 +362,7 @@ set requestedTransformListFiles; set requestedDefaultTransforms; set requestedSummaryTypes; + bool force = false; //!!! bool multiplex = false; bool recursive = false; bool list = false; @@ -488,6 +491,9 @@ } else if (arg == "-r" || arg == "--recursive") { recursive = true; continue; + } else if (arg == "-f" || arg == "--force") { + force = true; + continue; } else if (arg == "-l" || arg == "--list") { list = true; continue; @@ -719,10 +725,11 @@ std::cerr << "Extracting features for: \"" << i->toStdString() << "\"" << std::endl; try { manager.extractFeatures(*i); - } catch (FailedToOpenFile f) { - cerr << "ERROR: Failed to open output file for feature writer: " - << f.what() << endl; - break; + } catch (std::exception e) { + cerr << "ERROR: Failed to process file \"" << i->toStdString() + << "\": " << e.what() << endl; + if (force) continue; + else break; } } diff -r 7d87bf308509 -r 9a4e410bda7a version.h --- a/version.h Mon Jun 29 13:47:12 2009 +0000 +++ b/version.h Tue Jul 07 10:34:27 2009 +0000 @@ -1,1 +1,1 @@ -#define RUNNER_VERSION "0.2" +#define RUNNER_VERSION "0.3"