public String processInput(String input) { String output; boolean moreInputRequired; if (input == null) { // '\nHello {0}\nWelcome to the Ganymede Jython interpreter!\n\nType "quit" to exit.\n{1}' return ts.l("processInput.greeting", socket.getInetAddress().getHostAddress(), prompt); } if (input.equals(ts.l("processInput.quitcommand"))) { return doneString; } try { moreInputRequired = interp.push(input); if (moreInputRequired) { return "... "; } buffer.flush(); output = buffer.toString(); interp.resetbuffer(); buffer.getBuffer().setLength(0); } catch (PyException pex) { output = buffer.toString() + "\n" + pex.toString(); interp.resetbuffer(); buffer.getBuffer().setLength(0); } return output + prompt; }
public JythonServerProtocol(Socket sock) { JythonServerProtocol.doneString = ts.l("global.done"); this.socket = sock; buffer = new StringWriter(64); interp = new InteractiveConsole(); interp.setOut(buffer); interp.setErr(buffer); /* Import the additional Jython library routines */ interp.exec("import sys"); interp.exec( "sys.path.append( sys.prefix + '" + System.getProperty("file.separator") + "' + 'jython-lib.jar' )"); /* Seed the interpreter with a pointer to important Ganymede classes */ interp.exec("from arlut.csd.ganymede.server import *"); interp.exec("from arlut.csd.ganymede.common import *"); }
public void createSession(String personaName) { try { /* Snag the appropriate Admin Persona from the database */ DBObject persona = (DBObject) ((DBObjectBase) Ganymede.db.get("Admin Persona")).get(personaName); /* If there is a user associated with this persona, snag it */ DBObject user = null; InvidDBField userField = (InvidDBField) persona.get("User"); if (userField != null) { user = (DBObject) userField.getVal(); } /* Now we have all we need to create the session */ session = new GanymedeSession(personaName, user, persona, false); } catch (RemoteException ex) { Ganymede.stackTrace(ex); return; } interp.set("session", session); }