post data using curl

2007-02-12 Thread elrondrules
hi

need some help from the experts in this group as to how to do the
following

i have a http listener (A) that has subscribed to a process (B) and
listening on a port..
now based on some command line arguments i need to send a xml file to
the process B using curl..

is there a way to do this in python..

thx for the help

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


Re: need help to kill a process

2007-02-07 Thread elrondrules
On Feb 6, 8:24 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Tue, 06 Feb 2007 22:59:40 -0300, <[EMAIL PROTECTED]> escribió:
>
>
>
>
>
> > this is my code snip.
> > within my python script I have the following commands..
>
> > 
>
> > import os
> > ...
> > os.system ("cd /home; ./TestTool &")
> > os.system ("cd /usr/; sh run.sh load.xml &")
>
> > 
>
> > I need to kill these 2 process after a particular job is done.. is
> > there any way to get the pids of these process and if so how do i
> > invoke the kill command through os.system..
>
> > or else is there anyother way to do this...
>
> If you're using Python>=2.4 you could use the subprocess module.
>
> import subprocess
> child1 = subprocess.Popen(["./TestTool"], cwd="/home")
> child2 = subprocess.Popen(["sh","run.sh","load.xml"], cwd="/usr")
>
> Popen objects have a pid attribute. You don't have to use os.system to  
> kill them; use os.kill instead.
> You'll notice that I leave out the final &, because I don't know how to  
> start a background process without using the shell. But I think you can  
> use: bg [pid], afterwards, to get the same result.
>
> --
> Gabriel Genellina- Hide quoted text -
>
> - Show quoted text -

thx for the reply
os.kill worked fine for the first process.. for the second one the
kill managed to kill the shell but the application is still running..

is there any other work around for this..

thanks

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


need help to kill a process

2007-02-06 Thread elrondrules
Hi

Am new to python and need your help!!

this is my code snip.
within my python script I have the following commands..



import os
...
os.system ("cd /home; ./TestTool &")
os.system ("cd /usr/; sh run.sh load.xml &")



I need to kill these 2 process after a particular job is done.. is
there any way to get the pids of these process and if so how do i
invoke the kill command through os.system..

or else is there anyother way to do this...

thanks

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


script not opening applications

2007-02-01 Thread elrondrules
hi

i have a html as follows:






my hello.py is as follows



import os

os.system ("export DISPLAY=10.0.1.1:0.0")
os.system ("./Test &") #Testtool opens a new window



What I expected this to do was once I click "Run Test" it should run
the hello.py script and open a new window for the Test application.
both the hello.py and the test application are in the cgi-bin
directory

If I run the hello.py in the command line it works fine but not
through the html...

Any idea as to whats missing..

Thanks

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


Re: Convert raw data to XML

2007-01-30 Thread elrondrules
On Jan 30, 12:05 pm, John Nagle <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > On Jan 29, 8:54 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
>
> >>En Mon, 29 Jan 2007 23:42:07 -0300, <[EMAIL PROTECTED]> escribió:
> > the reason I wanted to write it as a file was to parse the file, look
> > for a specific attribute and execute a set of commands based on the
> > value of the attribute.. also i needed to display the output of the
> > http post in a more readable format..
>
> That's straightforward.  You confused people by asking the
> wrong question.  You wrote "Convert raw data to XML", but what
> you want to do is parse XML and extract data from it.
>
> This will do what you want:
>
>http://www.crummy.com/software/BeautifulSoup/
>
> For starters, try
>
> from BeautifulSoup import BeautifulStoneSoup
> xmlstring = somexml ## get your XML into here as one big string
> soup = BeautifulStoneSoup(xmlstring)# parse XML into tree
> print soup.prettify()   # print out in indented format
>
> "soup" is a tree structure representing the XML, and there are
> functions to easily find items in the tree by tag name, attribute,
> and such.  Work on the tree, not a file with the text of the indented
> output.
>
> John Nagle

is there any other way to do this without using BeautifulStoneSoup.. 
using existing minidom or ext..
i dont want to install anything new

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


Re: Convert raw data to XML

2007-01-30 Thread elrondrules
On Jan 29, 8:54 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Mon, 29 Jan 2007 23:42:07 -0300, <[EMAIL PROTECTED]> escribió:
>
> > For example the raw data is as follows
>
> > SomeText  > Description>PassorFail
>
> > without spaces or new lines. I need this to be written into an XML
> > file as
> > [same content but nicely indented]
>
> Is the file supposed to be processed by humans? If not, just write it as  
> you receive it.
> Spaces and newlines and indentation are mostly irrelevant on an xml file.
>
> --
> Gabriel Genellina

the reason I wanted to write it as a file was to parse the file, look 
for a specific attribute and execute a set of commands based on the 
value of the attribute.. also i needed to display the output of the 
http post in a more readable format..


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


Convert raw data to XML

2007-01-29 Thread elrondrules
Hi

I am running a HTTP server which receives post from a process.
In my do_POST method am receiving raw data.

I know that this raw data has a valid XML content and I need to 
convert this into an XML file.

Are there any routines to do this.. if not how to write one..

For example the raw data is as follows

SomeText PassorFail

without spaces or new lines. I need this to be written into an XML 
file as



   
  
  
 SomeText
  
  
 PassorFail
  
  


The tags in the raw data are not the same alaways.. Hence I need a 
generic routine that does the trick

Any pointers for this issue would help

Thanks

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


help with subscription to a process

2007-01-26 Thread elrondrules
Hi

I am new to python and hence need some help

i have a process A that posts events as XML docs.
I need to create a listener to this process that subscribes to the
process A and as and when a XML doc is posted parse it.
I have creted an interface where if I specify the port number on which
the listener is running the process A will automatically start posting
events.

The place I need help is to create a listener and a way of parsing the
XML docs. If you can give me some starting points or docs/resources
that will be great..

Thanks

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


Http listener

2007-01-25 Thread elrondrules
Hi

Am new to python and I am trying to do the following:

1. Write a Http Listener (listening on a particular port) that
subscribes to a process.
2. This process posts events as xml docs.
3. Parse the xml docs as and when they are posted.

Am trying to find any resources that helps me to do write the Http
Listener.. 
any starting pointers would be helpful

thx

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


Match 2 words in a line of file

2007-01-18 Thread elrondrules
Hi

Am pretty new to python and hence this question..

I have file with an output of a process. I need to search this file one
line at a time and my pattern is that I am looking for the lines that
has the word 'event' and the word 'new'.

Note that i need lines that has both the words only and not either one
of them..

how do i write a regexp for this.. or better yet shd i even be using
regexp or is there a better way to do this

thanks

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