problem with Sorting from Array

2011-02-02 Thread shanti bhushan
Dear All,

funtion "textPosValue " will give me key ,type and pos values from the
arrays.
This an embedded application code .
I want to execute some thing when key ==0 && type ==0 please let me
know
where to put such code i am getting confused with it


def textPosValue(data):
str_arr1=[" 0",".@/:1","abc2",
   "def3","ghi4",
   "jkl5","mno6",
   "pqrs7","tuv8",
   "wxyz9" ]
str_arr2=[" 0",".@/:1","ABC2",
   "DEF3","GHI4",
   "JKL5","MNO6",
   "PQRS7","TUV8",
   "WXYZ9" ]
str_arr3=["0","1","2",
 "3","4","5",
 "6","7","8",
 "9" ]
str_arr4=[" 0",".@/:1","?[] 2",
   "!<> 3",",&\ 4",
   "()~ 5","'{}` 6",
   ";$|^ 7","_#% 8",
   "-*+=9" ]
str=[str_arr1,str_arr2,str_arr3,str_arr4]
k=1
first=0
SecPos=0
sts=0
try:
for first in range(4):
for SecPos in range(10):
#print "first,SecPos,str[first]
[Secpos]",first,SecPos,str[first][SecPos]
sts=str[first][SecPos].find(data)
#print sts
if (sts < 0):
   continue
else:
k=0
break
if (k==0):
print sts
break


return first, SecPos, sts
except IndexError:
return -1,-1,-1


for ch in "43.88.79.132" :
type,key,Pos=textPosValue(ch)
for i in range(type):
cat,data=remote_keypress("green")
send_sircs(cat,data)
sleep(0.5)

for j in range(Pos+1):
if (key ==0 && type ==0) // i 
want
to execute some thing when , key ==0 && type ==0 , is it the right
position??
cat,data=remote_keypress("space")
send_sircs(cat,data)
sleep(0.5)
cat,data=remote_keypress("violet")
send_sircs(cat,data)
sleep(0.5)

cat,data=remote_keypress(key)
send_sircs(cat,data)
sleep(0.5)
sleep(0.5)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: process cannot access the file because it is being used by other process

2010-06-21 Thread shanti bhushan
On Jun 21, 2:15 pm, Tim Golden  wrote:
> On 21/06/2010 09:23, shanti bhushan wrote:
>
> > i am using below code ,it works fine on ordinary python 26 ,but when i
> > use this script in my python testing tool it gives me message "process
> > cannot access the file because it is being used by other process" for
> > the second time invoking of mongoose server.
> > Please help me in handling this exception.
>
> Before I make any suggestions on the code, I might suggest that you
> learn to wait a little. You sent three pretty much identical messages
> within the space of three hours. Believe me: if people aren't helping,
> it's not because they haven't seen your first message. Or the follow-up.
> Or the one after that. It's because they don't know the answer, or
> haven't the time to answer. Or aren't in the same timezone as you and
> so haven't woken up yet!
>
> > def invoke_server2():
> >      file = open("mongoose-2.8.exe", "r")
> >      try:
> >          proc = subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:
> > \372\pythonweb\mongoose-2.8.exe -root D:\New1\>YourOutput.txt"')
> >      except OSError:
> >          print "os error"
> >          file.close()
> >          sys.exc_clear()
> >          os.remove("mongoose-2.8.exe")
>
> OK. I'm not sure what you're achieving with the open ("mongoose...") line
> and its corresponding close. In fact, I can't work out what the whole
> exception block is achieving. I actually had to go and look up what
> sys.exc_clear is doing -- and I don't think it's doing what you think
> it's doing. You appear to be trapping an OS error, such as file-not-found
> or access-denied, by trying to ignore the error and then deleting the
> server
> itself!
>
> Let's straighten some stuff out. First your Popen line could almost
> certainly
> be simplified to this:
>
> 
> import subprocess
>
> with open ("YourOutput.txt", "w") as outf:
>    proc = subprocess.Popen (
>      [r"D:\372\pythonweb\mongoose-2.8.exe", "-root", r"D:\New1"],
>      stdout=outf
>    )
>
> 
>
> and to kill the proc, you can just call proc.kill ()
>
> Does that take you forward? Are you still seeing the "Cannot access file..."
> errors?
>
> TJG

i used below code

import subprocess
import time
def invoke_server1():
proc = subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:
\372\pythonweb\mongoose-2.8.exe -root D:\New1\"')


invoke_server1()


time.sleep(10)
proc.kill()

this code only invokes the server but is not killing after 10 seconds.

my purpose is invoke server many times with different argument and
kill it.
but when ever  i use subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /
c
"taskkill /F /IM mongoose-2.8.exe >YourOutput1.txt"'
this gives me error "process cannot access the file because it is
being used by other process"
-- 
http://mail.python.org/mailman/listinfo/python-list


process cannot access the file because it is being used by other process

2010-06-21 Thread shanti bhushan
Hi,

i am using below code ,it works fine on ordinary python 26 ,but when i
use this script in my python testing tool it gives me message "process
cannot access the file because it is being used by other process" for
the second time invoking of mongoose server.
Please help me in handling this exception.

def invoke_server2():
file = open("mongoose-2.8.exe", "r")
try:
proc = subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:
\372\pythonweb\mongoose-2.8.exe -root D:\New1\ >YourOutput.txt"')
except OSError:
print "os error"
file.close()
sys.exc_clear()
os.remove("mongoose-2.8.exe")

def invoke_server3():
file = open("mongoose-2.8.exe", "r")
try:
proc = subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:
\372\pythonweb\mongoose-2.8.exe -root D:\New2\ >YourOutput.txt"')
except OSError:
print "os error"
file.close()
sys.exc_clear()
os.remove("mongoose-2.8.exe")


def kill_server():
killret=subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c
"taskkill /F /IM mongoose-2.8.exe >YourOutput1.txt"')
print killret


invoke_server1()
time.sleep(5)
kill_server()
time.sleep(5)
invoke_server2()
time.sleep(5)
kill_server()
time.sleep(5)
invoke_server3()
time.sleep(5)
kill_server()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: start and kill process by command promt

2010-06-20 Thread shanti bhushan
On Jun 21, 10:41 am, shanti bhushan  wrote:
> Hi,
> I want to invoke local wen server named mogoose, and kill it after
> some time by python script.
> Then i want to change the argument and invoke it again.
>
> I am able to do this with below code.
>
> import subprocess
> import time
>
> def invoke_server1():
>     s1ret=subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:
> \372\pythonweb\mongoose-2.8.exe >YourOutput.txt"')
>     print s1ret
>
> def invoke_server2():
>     s2ret=subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:
> \372\pythonweb\mongoose-2.8.exe -root D:\New1\ >YourOutput.txt"')
>     print s2ret
> def invoke_server3():
>     s3ret=subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:
> \372\pythonweb\mongoose-2.8.exe -root D:\New2\ >YourOutput.txt"')
>     print s3ret
>
> def kill_server():
>     killret=subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c
> "taskkill /F /IM mongoose-2.8.exe >YourOutput1.txt"')
>     print killret
>
> kill_server()
> time.sleep(5)
> invoke_server1()
> time.sleep(5)
> kill_server()
> time.sleep(5)
> invoke_server2()
> time.sleep(5)
> kill_server()
> time.sleep(10)
> invoke_server3()
> time.sleep(5)
> kill_server()
>
> This works fine in python26 ,but when i use this code in one testing
> tool, server is invoked 1st time properly.but for second time it says
> process already occupied cannot access the process. I am not able to
> understand why subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c
> "taskkill /F /IM mongoose-2.8.exe  is not working second time .Please
> guide me in this respect.
>
> Or please tell me is there any other way,to do same thing with python
> script that will start and kill windows process for my requirement.
>
> Regards
> Bhushan

i am getting following error message
"process cannot acces the file because it is being used by other
process"
-- 
http://mail.python.org/mailman/listinfo/python-list


start and kill process by command promt

2010-06-20 Thread shanti bhushan
Hi,
I want to invoke local wen server named mogoose, and kill it after
some time by python script.
Then i want to change the argument and invoke it again.

I am able to do this with below code.

import subprocess
import time

def invoke_server1():
s1ret=subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:
\372\pythonweb\mongoose-2.8.exe >YourOutput.txt"')
print s1ret

def invoke_server2():
s2ret=subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:
\372\pythonweb\mongoose-2.8.exe -root D:\New1\ >YourOutput.txt"')
print s2ret
def invoke_server3():
s3ret=subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:
\372\pythonweb\mongoose-2.8.exe -root D:\New2\ >YourOutput.txt"')
print s3ret

def kill_server():
killret=subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c
"taskkill /F /IM mongoose-2.8.exe >YourOutput1.txt"')
print killret

kill_server()
time.sleep(5)
invoke_server1()
time.sleep(5)
kill_server()
time.sleep(5)
invoke_server2()
time.sleep(5)
kill_server()
time.sleep(10)
invoke_server3()
time.sleep(5)
kill_server()



This works fine in python26 ,but when i use this code in one testing
tool, server is invoked 1st time properly.but for second time it says
process already occupied cannot access the process. I am not able to
understand why subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c
"taskkill /F /IM mongoose-2.8.exe  is not working second time .Please
guide me in this respect.

Or please tell me is there any other way,to do same thing with python
script that will start and kill windows process for my requirement.

Regards
Bhushan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subprocess in Command promt+ webbrowser

2010-06-19 Thread shanti bhushan
On Jun 19, 11:01 am, shanti bhushan  wrote:
> I have a code ,in which i invoke the local webserver in back
> ground ,then open URL and access the web page.
> below is my code.
> I am able to invoke and kill the local webserver in seperate python
> script,but when i club opening of browser and and subprocess , my like
> below ,then my script is not responding.
> Please guide me.
>
> import subprocess
> import time
> subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:\372\pythonweb
> \mongoose-2.8.exe -root D:\New1\ >YourOutput.txt"')
> webbrowser.open("http://43.88.79.229:8080/index.html/";)
> time.sleep(11)
> subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c "taskkill /F /IM
> mongoose-2.8.exe >YourOutput1.txt"') # kill in back ground
> time.sleep(3)
> subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:\372\pythonweb
> \mongoose-2.8.exe -root D:\New1\ >YourOutput.txt"')
> webbrowser.open("http://43.88.79.229:8080/index.html/";)
> time.sleep(11)
> subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c "taskkill /F /IM
> mongoose-2.8.exe >YourOutput1.txt"') # kill in back ground
> time.sleep(3)
> subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:\372\pythonweb
> \mongoose-2.8.exe -root D:\New2\ >YourOutput.txt"')
> webbrowser.open("http://43.88.79.229:8080/index.html/";)


if i want to put exception handing for invoking the local web
server ?? how to do that please guide
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subprocess in Command promt+ webbrowser

2010-06-18 Thread shanti bhushan
On Jun 19, 11:01 am, shanti bhushan  wrote:
> I have a code ,in which i invoke the local webserver in back
> ground ,then open URL and access the web page.
> below is my code.
> I am able to invoke and kill the local webserver in seperate python
> script,but when i club opening of browser and and subprocess , my like
> below ,then my script is not responding.
> Please guide me.
>
> import subprocess
> import time
> subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C 
> "D:\372\pythonweb\mongoose-2.8.exe >YourOutput.txt"')
time.sleep(3)
webbrowser.open("http://43.88.79.229:8080/index.html";)
time.sleep(11)
subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c "taskkill /F /IM
mongoose-2.8.exe >YourOutput1.txt"') # kill in back ground
time.sleep(3)
subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:\372\pythonweb
\mongoose-2.8.exe -root D:\New1\ >YourOutput.txt"')
time.sleep(3)
webbrowser.open("http://43.88.79.229:8080/index.html";)
time.sleep(11)
subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c "taskkill /F /IM
mongoose-2.8.exe >YourOutput1.txt"') # kill in back ground
time.sleep(3)
subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:\372\pythonweb
\mongoose-2.8.exe -root D:\New2\ >YourOutput.txt"')
time.sleep(3)
webbrowser.open("http://43.88.79.229:8080/index.html";)
time.sleep(11)
subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c "taskkill /F /IM
mongoose-2.8.exe >YourOutput1.txt"') # kill in back ground


This scripts works fine with python 26 in windows XP, but when i
replace the browser opening part with broswer to be open on different
machine in python made tool.That it always give me warning that
process already open.If i kill the the command then also it gives same
problem.
Please guide me is it sycronisation issue?,some exception handling is
required??
-- 
http://mail.python.org/mailman/listinfo/python-list


subprocess in Command promt+ webbrowser

2010-06-18 Thread shanti bhushan
I have a code ,in which i invoke the local webserver in back
ground ,then open URL and access the web page.
below is my code.
I am able to invoke and kill the local webserver in seperate python
script,but when i club opening of browser and and subprocess , my like
below ,then my script is not responding.
Please guide me.

import subprocess
import time
subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:\372\pythonweb
\mongoose-2.8.exe -root D:\New1\ >YourOutput.txt"')
webbrowser.open("http://43.88.79.229:8080/index.html/";)
time.sleep(11)
subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c "taskkill /F /IM
mongoose-2.8.exe >YourOutput1.txt"') # kill in back ground
time.sleep(3)
subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:\372\pythonweb
\mongoose-2.8.exe -root D:\New1\ >YourOutput.txt"')
webbrowser.open("http://43.88.79.229:8080/index.html/";)
time.sleep(11)
subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /c "taskkill /F /IM
mongoose-2.8.exe >YourOutput1.txt"') # kill in back ground
time.sleep(3)
subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D:\372\pythonweb
\mongoose-2.8.exe -root D:\New2\ >YourOutput.txt"')
webbrowser.open("http://43.88.79.229:8080/index.html/";)




-- 
http://mail.python.org/mailman/listinfo/python-list


python local web server

2010-06-14 Thread shanti bhushan
Hi ,
I want to use the python local web server.
I want to do the following activities with the server.
1. I want to change to configuration of any time ,with the help of
python script.
2. I want to log request and response for the server so ,i can use it
for analysis.

Please guide me in this respect, if this code is already avaialble
please update me.
Please guide me the design or direct me the best approach to do all
this.

Regards
Shanti Bhushan
-- 
http://mail.python.org/mailman/listinfo/python-list


Capture the request/response log for local web server through python.

2010-06-14 Thread shanti bhushan
Dear all,
I have made local webserver up by the python script

import string,cgi,time
from os import curdir, sep
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
#import pri
import glob
import logging
import logging.handlers
class MyHandler(BaseHTTPRequestHandler):

def do_GET(self):
try:
if self.path.endswith(".html"):
f = open(curdir + sep + self.path) #self.path has /
test.html
#note that this potentially makes every file on your computer readable
by the internet

self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
self.wfile.write(f.read())
f.close()
return
if self.path.endswith(".esp"):   #our dynamic content
self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
self.wfile.write("hey, today is the" +
str(time.localtime()[7]))
self.wfile.write(" day in the year " +
str(time.localtime()[0]))
return

return

except IOError:
self.send_error(404,'File Not Found: %s' % self.path)


def do_POST(self):
global rootnode
try:
ctype, pdict =
cgi.parse_header(self.headers.getheader('content-type'))
if ctype == 'multipart/form-data':
query=cgi.parse_multipart(self.rfile, pdict)
self.send_response(301)

self.end_headers()
upfilecontent = query.get('upfile')
print "filecontent", upfilecontent[0]
self.wfile.write("POST OK.");
self.wfile.write(upfilecontent[0]);

except :
pass

def main():
try:
server = HTTPServer(('', 80), MyHandler)
print 'started httpserver...'
server.serve_forever()
except KeyboardInterrupt:
print '^C received, shutting down server'
server.socket.close()

if __name__ == '__main__':
main()


I have designed one html page also.
when i access the HTML page ,i want to capture following things
user_agents client-request ,server-response with the help of python
script.
please guide me to write such python script with which i can log all
server /client request and response.

Regards,
Shanti Bhushan
shanti.bhus...@hotmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: configuration setting for python server

2010-06-14 Thread shanti bhushan
On Jun 15, 5:53 am, David Zaslavsky  wrote:
> On Monday 14 June 2010 6:19:33 am shanti bhushan wrote:> I want to update the 
> configuration file for python server ,but i am
> > not able to locate the python configuration file.
>
> What configuration file? I don't see anything in your code that reads a
> configuration file.
>
> :) David

next thing is i want to know which python server will have this option
of configuration file.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: configuration setting for python server

2010-06-14 Thread shanti bhushan
On Jun 15, 5:53 am, David Zaslavsky  wrote:
> On Monday 14 June 2010 6:19:33 am shanti bhushan wrote:> I want to update the 
> configuration file for python server ,but i am
> > not able to locate the python configuration file.
>
> What configuration file? I don't see anything in your code that reads a
> configuration file.
>
> :) David

like this code

ServerAdmin webmas...@localhost
DocumentRoot /var/www/

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default
start page
# in /apache2-default/, but still have / go to the
right place
#RedirectMatch ^/$ /apache2-default/

for apache we can configure the apache server.
do we have some configuration file for python server??
if yes please tell me which configuration file should be used
-- 
http://mail.python.org/mailman/listinfo/python-list


configuration setting for python server

2010-06-14 Thread shanti bhushan
I want to update the configuration file for python server ,but i am
not able to locate the python configuration file.
Please guide me in this respect.

I am using a python web server
This is the code for it

---
import string,cgi,time
from os import curdir, sep
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
#import pri
class MyHandler(BaseHTTPRequestHandler):
def do_GET(self):
try:
if self.path.endswith(".html"):
f = open(curdir + sep + self.path) #self.path has /
test.html
#note that this potentially makes every file on your computer readable
by the internet
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write(f.read())
f.close()
return
if self.path.endswith(".esp"):   #our dynamic content
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write("hey, today is the" +
str(time.localtime()[7]))
self.wfile.write(" day in the year " +
str(time.localtime()[0]))
return

return

except IOError:
self.send_error(404,'File Not Found: %s' % self.path)

def do_POST(self):
global rootnode
try:
ctype, pdict =
cgi.parse_header(self.headers.getheader('content-type'))
if ctype == 'multipart/form-data':
query=cgi.parse_multipart(self.rfile, pdict)
self.send_response(301)

self.end_headers()
upfilecontent = query.get('upfile')
print "filecontent", upfilecontent[0]
self.wfile.write("POST OK.");
self.wfile.write(upfilecontent[0]);

except :
pass
def main():
try:
server = HTTPServer(('', 80), MyHandler)
print 'started httpserver...'
server.serve_forever()
except KeyboardInterrupt:
print '^C received, shutting down server'
server.socket.close()
if __name__ == '__main__':
main()


sample Configuration file for Apache server


ServerAdmin webmas...@localhost
DocumentRoot /var/www/

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default
start page
# in /apache2-default/, but still have / go to the
right place
#RedirectMatch ^/$ /apache2-default/


I want to update the configuration file for python server ,but i am
not able to locate the python configuration file.
Please guide me in this respect.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: url fetching from xml depending upon selection

2010-05-18 Thread shanti bhushan
On May 18, 12:04 pm, Stefan Behnel  wrote:
> shanti bhushan, 18.05.2010 07:18:
>
>
>
>
>
> > I have a sample.XML file
> > the code is like this
>
> > 
> > 
> > 
> >    My Podcasts
> >    Sun, 07 Mar 2010 15:53:26
>
> > GMT
> >    Sun, 07 Mar 2010 15:53:26
>
> > GMT
> > 
> > 
> >    
> >      http://first.co.jp"; />
> >      http://www.google.com"; />
> >      http://www.epaper.times.india.com"; />
> >    
> >    
> >      http://second.co.jp"; />
> >      http://www.google.com"; />
> >      http://www.epaper.times.india.com"; />
> >    
> >    
> >      http://third.co.jp"; />
> >      http://www.google.com"; />
> >      http://www.epaper.times.india.com"; />
> >    
> > 
> > 
>
> > This my python code
> > from xml.etree import ElementTree
>
> > with open('our.xml', 'rt') as f:
> >      tree = ElementTree.parse(f)
>
> > for node, value in tree.findall('.//TestCase/Input'):
>
> >          url=node.attrib.get('url')
> >          print url
>
> > i want to print the url depending on name="sprint_001".
>
>      for test_case in tree.findall('.//TestCase'):
>          if test_case.get('name') == 'sprint_002':
>             for input_el in test_case:
>                 print input_el.get('url')
>
> Stefan- Hide quoted text -
>
> - Show quoted text -

Great Help Stefan -
my regards to you
thankyou once again it waorks fine ...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: url fetching from xml depending upon selection

2010-05-18 Thread shanti bhushan
On May 18, 12:04 pm, Stefan Behnel  wrote:
> shanti bhushan, 18.05.2010 07:18:
>
>
>
>
>
> > I have a sample.XML file
> > the code is like this
>
> > 
> > 
> > 
> >    My Podcasts
> >    Sun, 07 Mar 2010 15:53:26
>
> > GMT
> >    Sun, 07 Mar 2010 15:53:26
>
> > GMT
> > 
> > 
> >    
> >      http://first.co.jp"; />
> >      http://www.google.com"; />
> >      http://www.epaper.times.india.com"; />
> >    
> >    
> >      http://second.co.jp"; />
> >      http://www.google.com"; />
> >      http://www.epaper.times.india.com"; />
> >    
> >    
> >      http://third.co.jp"; />
> >      http://www.google.com"; />
> >      http://www.epaper.times.india.com"; />
> >    
> > 
> > 
>
> > This my python code
> > from xml.etree import ElementTree
>
> > with open('our.xml', 'rt') as f:
> >      tree = ElementTree.parse(f)
>
> > for node, value in tree.findall('.//TestCase/Input'):
>
> >          url=node.attrib.get('url')
> >          print url
>
> > i want to print the url depending on name="sprint_001".
>
>      for test_case in tree.findall('.//TestCase'):
>          if test_case.get('name') == 'sprint_002':
>             for input_el in test_case:
>                 print input_el.get('url')
>
> Stefan- Hide quoted text -
>
> - Show quoted text -

Hi Stevan
i tried your logic i am not getting any out put for this
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: url fetching from xml depending upon selection

2010-05-18 Thread shanti bhushan
On May 18, 10:18 am, shanti bhushan  wrote:
> I have a sample.XML file
> the code is like this
>
> 
> 
> 
>         My Podcasts
>         Sun, 07 Mar 2010 15:53:26
>
> GMT
>         Sun, 07 Mar 2010 15:53:26
>
> GMT
> 
> 
>   
>     http://first.co.jp"; />
>     http://www.google.com"; />
>     http://www.epaper.times.india.com"; />
>   
>   
>     http://second.co.jp"; />
>     http://www.google.com"; />
>     http://www.epaper.times.india.com"; />
>   
>   
>     http://third.co.jp"; />
>     http://www.google.com"; />
>     http://www.epaper.times.india.com"; />
>   
> 
> 
>
> This my python code
> from xml.etree import ElementTree
>
> with open('our.xml', 'rt') as f:
>     tree = ElementTree.parse(f)
>
> for node, value in tree.findall('.//TestCase/Input'):
>
>         url=node.attrib.get('url')
>         print url
>
> i want to print the url depending on name="sprint_001".
> If i change my option to sprint_002 it should print url for sprint_002


i have tried some new things here

from xml.etree import ElementTree

with open('our.xml', 'rt') as f:
tree = ElementTree.parse(f)

for node in tree.findall('.//TestCase/'):
print node.attrib.keys()
print node.attrib.items()
print node.attrib.get(1)

url=node.attrib.get('url')
print url



but i am not getting idea ... how to achive my motive
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: url fetching from xml depending upon selection

2010-05-17 Thread shanti bhushan
On May 18, 10:18 am, shanti bhushan  wrote:
> I have a sample.XML file
> the code is like this
>
> 
> 
> 
>         My Podcasts
>         Sun, 07 Mar 2010 15:53:26
>
> GMT
>         Sun, 07 Mar 2010 15:53:26
>
> GMT
> 
> 
>   
>     http://first.co.jp"; />
>     http://www.google.com"; />
>     http://www.epaper.times.india.com"; />
>   
>   
>     http://second.co.jp"; />
>     http://www.google.com"; />
>     http://www.epaper.times.india.com"; />
>   
>   
>     http://third.co.jp"; />
>     http://www.google.com"; />
>     http://www.epaper.times.india.com"; />
>   
> 
> 
>
> This my python code
> from xml.etree import ElementTree
>
> with open('our.xml', 'rt') as f:
>     tree = ElementTree.parse(f)
>
> for node, value in tree.findall('.//TestCase/Input'):
>
>         url=node.attrib.get('url')
>         print url
>
> i want to print the url depending on name="sprint_001".
> If i change my option to sprint_002 it should print url for sprint_002



i am trying to do with this code
please correct my code

from xml.etree import ElementTree

with open('our.xml', 'rt') as f:
tree = ElementTree.parse(f)

for node in tree.findall('.//TestCase/Input'):
if name=='Sprint_001':
print node.attrib.get('url')

i want to print only url that comes under name=Sprint_001
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: url fetching from xml depending upon selection

2010-05-17 Thread shanti bhushan
On May 18, 10:18 am, shanti bhushan  wrote:
> I have a sample.XML file
> the code is like this
>
> 
> 
> 
>         My Podcasts
>         Sun, 07 Mar 2010 15:53:26
>
> GMT
>         Sun, 07 Mar 2010 15:53:26
>
> GMT
> 
> 
>   
>     http://first.co.jp"; />
>     http://www.google.com"; />
>     http://www.epaper.times.india.com"; />
>   
>   
>     http://second.co.jp"; />
>     http://www.google.com"; />
>     http://www.epaper.times.india.com"; />
>   
>   
>     http://third.co.jp"; />
>     http://www.google.com"; />
>     http://www.epaper.times.india.com"; />
>   
> 
> 
>
> This my python code
> from xml.etree import ElementTree
>
> with open('our.xml', 'rt') as f:
>     tree = ElementTree.parse(f)
>
> for node, value in tree.findall('.//TestCase/Input'):
>
>         url=node.attrib.get('url')
>         print url
>
> i want to print the url depending on name="sprint_001".
> If i change my option to sprint_002 it should print url for sprint_002

this code print all URL but there is no option to select URLs
depending upon my choice

from xml.etree import ElementTree
with open('our.xml', 'rt') as f:
tree = ElementTree.parse(f)
for node in tree.findall('.//TestCase/Input'):
url=node.attrib.get('url')
print url
-- 
http://mail.python.org/mailman/listinfo/python-list


url fetching from xml depending upon selection

2010-05-17 Thread shanti bhushan
I have a sample.XML file
the code is like this




My Podcasts
Sun, 07 Mar 2010 15:53:26

GMT
Sun, 07 Mar 2010 15:53:26

GMT


  
http://first.co.jp"; />
http://www.google.com"; />
http://www.epaper.times.india.com"; />
  
  
http://second.co.jp"; />
http://www.google.com"; />
http://www.epaper.times.india.com"; />
  
  
http://third.co.jp"; />
http://www.google.com"; />
http://www.epaper.times.india.com"; />
  




This my python code
from xml.etree import ElementTree

with open('our.xml', 'rt') as f:
tree = ElementTree.parse(f)

for node, value in tree.findall('.//TestCase/Input'):

url=node.attrib.get('url')
print url



i want to print the url depending on name="sprint_001".
If i change my option to sprint_002 it should print url for sprint_002
-- 
http://mail.python.org/mailman/listinfo/python-list


reading XML file using python

2010-05-17 Thread shanti bhushan
Hi ,
i am new to python.i want to read the XML file using python it ,by
using DOm or SAX any of them.
I want to read the http://www.google.com(any hyper text) from XML and
print that.
please give me the sample program for this.
regards
Shanti Bhushan
Bangalore,India
-- 
http://mail.python.org/mailman/listinfo/python-list