| |||
Jython:replace value with another value Posted by patni (patni), 16 May 2005 Following is the line in the script self.body.addParameter('''deleteSelection''', '''31''') Now I want to replace '31' with repid Where repid is a number reading from file. #To get reportid from file in file system f = open( '/root/sqatest/test_suites/scripts/avadhoot_scripts/id.txt', 'r' ) repid = f.read() repid = repid.strip() f.close() print repid How I can do that? Posted by admin (Graham Ellis), 16 May 2005 self.body.addParameter('''deleteSelection''', repid) If you're reading the repid variable outside the method in which this line of code occurs, you'll need to pass it in .... Posted by patni (patni), 19 May 2005 self.body.addParameter('''deleteSelection''', repid) Shows error while executing Encountered an error: java.io.IOException: Server returned HTTP response code: 500 for URL: http://192.168.135.251/logapp20/action/admin/devices/tcp_mod_msg_fwd.do?reportType=systemStatus Posted by admin (Graham Ellis), 19 May 2005 The you've probably not got the right value in repid or the result of doing the substitute causes the parameter to point to an incorrect URL.I don't quite know how to say this. I know you're new to Jython and it's a lot to learn, but I think there must be more effective ways for you to do so than by asking me hear about the code line by line - that's inefficient for me and inefficient for you too. This board is really intended to help out with those occasional problems that you can't get solved elsewhere rather then being an early "port of call" whenever an error message come us. Can I make some suggestions. a) I think you would benefit hugely from a Python course - have a look at ours (at http://www.wellho.net/course/yp.html or at those run by Mark Lutz (at http://www.rmi.net/~lutz/) - depending on where in the world you're located b) Mark's book has a lot of Python coverage and there's a wide range of other books too. We've got a list of all the Python books we have here in our library, and they're categories by level and with a description of what each one includes - see http://www.wellho.net/booktopic/Python.html Hope this helps ... please do feel free to continue to post up occasional difficult issues you find to this board, but please don't use it as a first resort; if I see more than, perhaps, one or two questions a week then I start to feel that there must be a better way. - Graham Posted by patni (patni), 24 May 2005 I tried with thisself.body.addParameter('''deleteSelection''', repid) But still Its not working. Its not giving me any exception problem But also its not deleting the report of specified report id Posted by admin (Graham Ellis), 25 May 2005 I don't have enough evidence to be able to comment fully. If this works with a constant value but fails when you use repid, have you checked what's in repid by printing it out? Have you tried doing the substitute by hand and then seeing if it works? I suspect that tests like these will lead you to the error; I don't think I can, as I suspect that the root cause of the error isn't listed within the sample code you've supplied.This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
| |||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |