From: Mike G. \(Paris\) <mik...@ve...> - 2005-04-20 11:15:54
|
Try putting the >>>>>>> marked lines on two lines instead of four. I don't think Jython parses the newline like you expect. =20 self.inputStream =3D BufferedReader(InputStreamReader(argusSocket.getInputStream())) self.outputStream =3D PrintWriter(OutputStreamWriter(argusSocket.getOutputStream()), 1) Mike -----Original Message----- From: jyt...@li... [mailto:jyt...@li...] On Behalf Of Bill Stephens Sent: Tuesday, April 19, 2005 10:19 PM To: jyt...@li... Subject: [Jython-dev] Jython custom class compilation problem I'm trying to create a Jython class that I can use to server as my=20 interface to a daemon process on my local host. I've got a Jython script and Java class (can I just use my working java class in jython?) that=20 does the connect and writes to the port fine. I'm trying convert this to a jython class and get nothing but 'invalid=20 syntax' errors. The error happens at the following line... -> self.argusSocket =3D Socket(host, port) ^ This is the first class that I've tried. class... from java.lang import Object from java.io import * from java.net import * from java.util import Date class ArgusClient(Object): def __init__(self, host, port) : self.argusSocket =3D Socket(host, port) >>>>>>>>> self.inputStream =3D BufferedReader( >>>>>>>>> InputStreamReader(argusSocket.getInputStream())) >>>>>>>>> self.outputStream =3D PrintWriter( >>>>>>>>> OutputStreamWriter(argusSocket.getOutputStream()), 1) def sendMetric (self, prefix, epochtime, metrics): """sendMetric(prefix, epochtime, metricString) -> Create formatted metric string and send it to the ArgusDaemon. prefix =3D lower case prefic string epochtime =3D epoch time converted to minutes (/1000) metrics =3D string of the format = name=3Dvalue:name=3Dvalue:...""" rtnValue =3D 0 argusSuccess =3D "PASS"; argusFailure =3D "FAIL"; argusFormat =3D "%s:%d:%s" metricString =3D argusFormat % (prefix, epochtime, metrics) self.outputStream.println(metricString) responseLine =3D self.inputStream.readLine() print responseline while responseLine !=3D None: if (responseLine.indexOf(self.argusSuccess) !=3D -1) rtnValue =3D 1; break; responseLine =3D self.inputStream.readLine() return rtnValue def close (self): """close() -> close the connection to the ArgusDaemon""" argusBye =3D "BYE"; self.outputStream.println(bye) self.inputStream.close() self.outputStream.close() self.argusSocket.close() #test if __name__=3D=3D'__main__': client=3DArgusClient("localhost", 1029) date=3DDate() epochTime=3Ddate.getTime()/1000 success=3Dclient.sendMetric('smi_wl', epochTime, = 'jvmfree=3D100005') client.close ------------------------------------------------------- This SF.Net email is sponsored by: New Crystal Reports XI. Version 11 adds new functionality designed to reduce time involved in creating, integrating, and deploying reporting solutions. Free runtime info, new features, or free trial, at: http://www.businessobjects.com/devxi/728 _______________________________________________ Jython-dev mailing list Jyt...@li... https://lists.sourceforge.net/lists/listinfo/jython-dev |