Search in sources :

Example 1 with InteractiveConsole

use of org.python.util.InteractiveConsole in project netxms by netxms.

the class Shell method run.

/**
 * @param args
 * @throws IOException
 * @throws NetXMSClientException
 */
private void run(String[] args) throws IOException, NXCException {
    initJython(args);
    readCredentials((args.length == 0) && isInteractive());
    final NXCSession session = connect();
    final InteractiveConsole console = createInterpreter(args);
    console.set("session", session);
    console.set("s", session);
    if (args.length == 0) {
        console.interact(getBanner(), null);
    } else {
        console.execfile(args[0]);
    }
    console.cleanup();
    session.disconnect();
}
Also used : NXCSession(org.netxms.client.NXCSession) InteractiveConsole(org.python.util.InteractiveConsole)

Example 2 with InteractiveConsole

use of org.python.util.InteractiveConsole in project netxms by netxms.

the class Shell method createInterpreter.

/**
 * @param args
 * @return
 */
private InteractiveConsole createInterpreter(String[] args) {
    PySystemState systemState = Py.getSystemState();
    final InteractiveConsole console;
    if (!isInteractive()) {
        systemState.ps1 = systemState.ps2 = Py.EmptyString;
    }
    console = new InteractiveConsole();
    Py.getSystemState().__setattr__("_jy_interpreter", Py.java2py(console));
    imp.load("site");
    console.exec("from org.netxms.client import *");
    console.exec("from org.netxms.client.agent.config import *");
    console.exec("from org.netxms.client.constants import *");
    console.exec("from org.netxms.client.dashboards import *");
    console.exec("from org.netxms.client.datacollection import *");
    console.exec("from org.netxms.client.events import *");
    console.exec("from org.netxms.client.log import *");
    console.exec("from org.netxms.client.maps import *");
    console.exec("from org.netxms.client.maps.configs import *");
    console.exec("from org.netxms.client.maps.elements import *");
    console.exec("from org.netxms.client.market import *");
    console.exec("from org.netxms.client.mt import *");
    console.exec("from org.netxms.client.objects import *");
    console.exec("from org.netxms.client.objecttools import *");
    console.exec("from org.netxms.client.packages import *");
    console.exec("from org.netxms.client.reporting import *");
    console.exec("from org.netxms.client.server import *");
    console.exec("from org.netxms.client.services import *");
    console.exec("from org.netxms.client.snmp import *");
    console.exec("from org.netxms.client.topology import *");
    console.exec("from org.netxms.client.users import *");
    console.exec("from org.netxms.client.xml import *");
    console.exec("from org.netxms.client.zeromq import *");
    console.set("__name__", "__nxshell__");
    return console;
}
Also used : PySystemState(org.python.core.PySystemState) InteractiveConsole(org.python.util.InteractiveConsole)

Aggregations

InteractiveConsole (org.python.util.InteractiveConsole)2 NXCSession (org.netxms.client.NXCSession)1 PySystemState (org.python.core.PySystemState)1