use of org.apache.commons.cli.AlreadySelectedException in project onebusaway-gtfs-modules by OneBusAway.
the class GtfsTransformerMain method run.
/*****************************************************************************
* {@link Runnable} Interface
****************************************************************************/
public void run(String[] args) throws IOException {
if (needsHelp(args)) {
printHelp();
System.exit(0);
}
try {
CommandLine cli = _parser.parse(_options, args, true);
runApplication(cli, args);
} catch (MissingOptionException ex) {
System.err.println("Missing argument: " + ex.getMessage());
printHelp();
System.exit(-2);
} catch (MissingArgumentException ex) {
System.err.println("Missing argument: " + ex.getMessage());
printHelp();
System.exit(-2);
} catch (UnrecognizedOptionException ex) {
System.err.println("Unknown argument: " + ex.getMessage());
printHelp();
System.exit(-2);
} catch (AlreadySelectedException ex) {
System.err.println("Argument already selected: " + ex.getMessage());
printHelp();
System.exit(-2);
} catch (ParseException ex) {
System.err.println(ex.getMessage());
printHelp();
System.exit(-2);
} catch (TransformSpecificationException ex) {
System.err.println("error with transform line: " + ex.getLine());
System.err.println(ex.getMessage());
System.exit(-1);
} catch (Exception ex) {
ex.printStackTrace();
System.exit(-1);
}
}
use of org.apache.commons.cli.AlreadySelectedException in project incubator-systemml by apache.
the class DMLScript method executeScript.
/**
* Single entry point for all public invocation alternatives (e.g.,
* main, executeScript, JaqlUdf etc)
*
* @param conf Hadoop configuration
* @param args arguments
* @return true if success, false otherwise
* @throws DMLException if DMLException occurs
* @throws ParseException if ParseException occurs
*/
public static boolean executeScript(Configuration conf, String[] args) throws DMLException {
//parse arguments and set execution properties
//keep old rtplatform
RUNTIME_PLATFORM oldrtplatform = rtplatform;
//keep old explain
ExplainType oldexplain = EXPLAIN;
Options options = createCLIOptions();
try {
DMLOptions dmlOptions = parseCLArguments(args, options);
// String[] scriptArgs = null; //optional script arguments
// boolean namedScriptArgs = false;
STATISTICS = dmlOptions.stats;
STATISTICS_COUNT = dmlOptions.statsCount;
USE_ACCELERATOR = dmlOptions.gpu;
FORCE_ACCELERATOR = dmlOptions.forceGPU;
EXPLAIN = dmlOptions.explainType;
ENABLE_DEBUG_MODE = dmlOptions.debug;
SCRIPT_TYPE = dmlOptions.scriptType;
rtplatform = dmlOptions.execMode;
String fnameOptConfig = dmlOptions.configFile;
boolean isFile = dmlOptions.filePath != null;
String fileOrScript = isFile ? dmlOptions.filePath : dmlOptions.script;
boolean help = dmlOptions.help;
if (help) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("systemml", options);
return true;
}
if (dmlOptions.clean) {
cleanSystemMLWorkspace();
return true;
}
//set log level
if (!ENABLE_DEBUG_MODE)
setLoggingProperties(conf);
//Step 2: prepare script invocation
if (isFile && StringUtils.endsWithIgnoreCase(fileOrScript, ".pydml")) {
SCRIPT_TYPE = ScriptType.PYDML;
}
String dmlScriptStr = readDMLScript(isFile, fileOrScript);
Map<String, String> argVals = dmlOptions.argVals;
DML_FILE_PATH_ANTLR_PARSER = dmlOptions.filePath;
//Step 3: invoke dml script
printInvocationInfo(fileOrScript, fnameOptConfig, argVals);
if (ENABLE_DEBUG_MODE) {
// inner try loop is just to isolate the debug exception, which will allow to manage the bugs from debugger v/s runtime
launchDebugger(dmlScriptStr, fnameOptConfig, argVals, SCRIPT_TYPE);
} else {
execute(dmlScriptStr, fnameOptConfig, argVals, args, SCRIPT_TYPE);
}
} catch (AlreadySelectedException e) {
System.err.println("Mutually exclusive options were selected. " + e.getMessage());
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("systemml", options);
return false;
} catch (org.apache.commons.cli.ParseException e) {
System.err.println(e.getMessage());
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("systemml", options);
} catch (ParseException pe) {
throw pe;
} catch (DMLScriptException e) {
//rethrow DMLScriptException to propagate stop call
throw e;
} catch (Exception ex) {
LOG.error("Failed to execute DML script.", ex);
throw new DMLException(ex);
} finally {
//reset runtime platform and visualize flag
rtplatform = oldrtplatform;
EXPLAIN = oldexplain;
}
return true;
}
use of org.apache.commons.cli.AlreadySelectedException in project onebusaway-gtfs-modules by OneBusAway.
the class GtfsMergerMain method run.
/*****************************************************************************
* {@link Runnable} Interface
****************************************************************************/
public void run(String[] args) throws IOException {
if (needsHelp(args)) {
printHelp();
System.exit(0);
}
try {
CommandLine cli = _parser.parse(_options, args, true);
runApplication(cli, args);
} catch (MissingOptionException ex) {
System.err.println("Missing argument: " + ex.getMessage());
printHelp();
} catch (MissingArgumentException ex) {
System.err.println("Missing argument: " + ex.getMessage());
printHelp();
} catch (UnrecognizedOptionException ex) {
System.err.println("Unknown argument: " + ex.getMessage());
printHelp();
} catch (AlreadySelectedException ex) {
System.err.println("Argument already selected: " + ex.getMessage());
printHelp();
} catch (ParseException ex) {
System.err.println(ex.getMessage());
printHelp();
} catch (Exception ex) {
ex.printStackTrace();
}
}
Aggregations