interp.setLocals(mod.__dict__);
//System.err.println("imp");
for (int i = 0; i < opts.warnoptions.size(); i++) {
String wopt = (String) opts.warnoptions.elementAt(i);
PySystemState.warnoptions.append(new PyString(wopt));
}
String msg = "";
if (Options.importSite) {
try {
imp.load("site");
if (opts.notice) {
PyObject builtins = Py.getSystemState().builtins;
boolean copyright = builtins.__finditem__("copyright") != null;
boolean credits = builtins.__finditem__("credits") != null;
boolean license = builtins.__finditem__("license") != null;
if (copyright) {
msg += "\"copyright\"";
if (credits && license)
msg += ", ";
else if (credits || license)
msg += " or ";
}
if (credits) {
msg += "\"credits\"";
if (license)
msg += " or ";
}
if (license)
msg += "\"license\"";
if (msg.length() > 0)
System.err.println("Type " + msg + " for more information.");
}
} catch (PyException pye) {
if (!Py.matchException(pye, Py.ImportError)) {
System.err.println("error importing site");
Py.printException(pye);
System.exit(-1);
}
}
}
if (opts.division != null) {
if ("old".equals(opts.division))
Options.divisionWarning = 0;
else if ("warn".equals(opts.division))
Options.divisionWarning = 1;
else if ("warnall".equals(opts.division))
Options.divisionWarning = 2;
else if ("new".equals(opts.division)) {
Options.Qnew = true;
interp.cflags.division = true;
}
}
// was there a filename on the command line?
if (opts.filename != null) {
String path = new java.io.File(opts.filename).getParent();
if (path == null)
path = "";
Py.getSystemState().path.insert(0, new PyString(path));
if (opts.jar) {
runJar(opts.filename);
} else if (opts.filename.equals("-")) {
try {
throw new RuntimeException("Can not run from <stdin> in internal PyDev version.");
// interp.locals.__setitem__(new PyString("__file__"),
// new PyString("<stdin>"));
// interp.execfile(System.in, "<stdin>");
} catch (Throwable t) {
Py.printException(t);
}
} else {
try {
interp.locals.__setitem__(new PyString("__file__"), new PyString(opts.filename));
interp.execfile(opts.filename);
} catch (Throwable t) {
Py.printException(t);
if (!opts.interactive) {
interp.cleanup();
System.exit(-1);
}
}
}
} else {
// if there was no file name on the command line, then "" is
// the first element on sys.path. This is here because if
// there /was/ a filename on the c.l., and say the -i option
// was given, sys.path[0] will have gotten filled in with the
// dir of the argument filename.
Py.getSystemState().path.insert(0, new PyString(""));
if (opts.command != null) {
try {
interp.exec(opts.command);
} catch (Throwable t) {