Jython:replace value with another value
Posted by patni (patni), 16 May 2005Following is the line in the script
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()
How I can do that?
Posted by admin (Graham Ellis), 16 May 2005
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 2005self.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 2005The 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.
Posted by patni (patni), 24 May 2005I tried with this
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 2005I 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.
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: email@example.com • WEB: http://www.wellho.net • SKYPE: wellho