comparison runner/main.cpp @ 21:9a4e410bda7a

* Add --force option, and throw/catch exceptions for failure cases rather than exiting directly
author Chris Cannam
date Tue, 07 Jul 2009 10:34:27 +0000
parents 7d87bf308509
children 4ab7c925f7ac
comparison
equal deleted inserted replaced
20:7d87bf308509 21:9a4e410bda7a
141 141
142 cerr << endl; 142 cerr << endl;
143 cerr << "Sonic Annotator v" << RUNNER_VERSION << endl; 143 cerr << "Sonic Annotator v" << RUNNER_VERSION << endl;
144 cerr << "A utility for batch feature extraction from audio files." << endl; 144 cerr << "A utility for batch feature extraction from audio files." << endl;
145 cerr << "Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London." << endl; 145 cerr << "Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London." << endl;
146 cerr << "Copyright 2007-2008 Queen Mary, University of London." << endl; 146 cerr << "Copyright 2007-2009 Queen Mary, University of London." << endl;
147 cerr << endl; 147 cerr << endl;
148 cerr << "This program is free software. You may redistribute copies of it under the" << endl; 148 cerr << "This program is free software. You may redistribute copies of it under the" << endl;
149 cerr << "terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>." << endl; 149 cerr << "terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>." << endl;
150 cerr << "This program is supplied with NO WARRANTY, to the extent permitted by law." << endl; 150 cerr << "This program is supplied with NO WARRANTY, to the extent permitted by law." << endl;
151 cerr << endl; 151 cerr << endl;
244 cerr << " -r, --recursive If any of the <audio> arguments is found to be a local" << endl; 244 cerr << " -r, --recursive If any of the <audio> arguments is found to be a local" << endl;
245 cerr << " directory, search the tree starting at that directory" << endl; 245 cerr << " directory, search the tree starting at that directory" << endl;
246 cerr << " for all supported audio files and take all of those as" << endl; 246 cerr << " for all supported audio files and take all of those as" << endl;
247 cerr << " input instead." << endl; 247 cerr << " input instead." << endl;
248 cerr << endl; 248 cerr << endl;
249 cerr << " -f, --force Continue with subsequent files following an error." << endl;
250 cerr << endl;
249 cerr << "Housekeeping options:" << endl; 251 cerr << "Housekeeping options:" << endl;
250 cerr << endl; 252 cerr << endl;
251 cerr << " -l, --list List all known transform ids to standard output." << endl; 253 cerr << " -l, --list List all known transform ids to standard output." << endl;
252 cerr << endl; 254 cerr << endl;
253 cerr << " -s, --skeleton <I> Generate a skeleton transform file for transform id <I>" << endl; 255 cerr << " -s, --skeleton <I> Generate a skeleton transform file for transform id <I>" << endl;
358 set<string> requestedWriterTags; 360 set<string> requestedWriterTags;
359 set<string> requestedTransformFiles; 361 set<string> requestedTransformFiles;
360 set<string> requestedTransformListFiles; 362 set<string> requestedTransformListFiles;
361 set<string> requestedDefaultTransforms; 363 set<string> requestedDefaultTransforms;
362 set<string> requestedSummaryTypes; 364 set<string> requestedSummaryTypes;
365 bool force = false;
363 //!!! bool multiplex = false; 366 //!!! bool multiplex = false;
364 bool recursive = false; 367 bool recursive = false;
365 bool list = false; 368 bool list = false;
366 bool summaryOnly = false; 369 bool summaryOnly = false;
367 QString skeletonFor = ""; 370 QString skeletonFor = "";
485 << ": WARNING: Multiplex argument not yet implemented" << endl; //!!! 488 << ": WARNING: Multiplex argument not yet implemented" << endl; //!!!
486 continue; 489 continue;
487 */ 490 */
488 } else if (arg == "-r" || arg == "--recursive") { 491 } else if (arg == "-r" || arg == "--recursive") {
489 recursive = true; 492 recursive = true;
493 continue;
494 } else if (arg == "-f" || arg == "--force") {
495 force = true;
490 continue; 496 continue;
491 } else if (arg == "-l" || arg == "--list") { 497 } else if (arg == "-l" || arg == "--list") {
492 list = true; 498 list = true;
493 continue; 499 continue;
494 } else if (arg == "-s" || arg == "--skeleton") { 500 } else if (arg == "-s" || arg == "--skeleton") {
717 for (QStringList::const_iterator i = sources.begin(); 723 for (QStringList::const_iterator i = sources.begin();
718 i != sources.end(); ++i) { 724 i != sources.end(); ++i) {
719 std::cerr << "Extracting features for: \"" << i->toStdString() << "\"" << std::endl; 725 std::cerr << "Extracting features for: \"" << i->toStdString() << "\"" << std::endl;
720 try { 726 try {
721 manager.extractFeatures(*i); 727 manager.extractFeatures(*i);
722 } catch (FailedToOpenFile f) { 728 } catch (std::exception e) {
723 cerr << "ERROR: Failed to open output file for feature writer: " 729 cerr << "ERROR: Failed to process file \"" << i->toStdString()
724 << f.what() << endl; 730 << "\": " << e.what() << endl;
725 break; 731 if (force) continue;
732 else break;
726 } 733 }
727 } 734 }
728 735
729 for (int i = 0; i < writers.size(); ++i) delete writers[i]; 736 for (int i = 0; i < writers.size(); ++i) delete writers[i];
730 737