Re: [Tutor] How do I do cubic roots and cubic exponents (and higher roots and exponents) in Python?

2006-05-09 Thread Gregor Lingl
Danny Yoo schrieb:

>  
>
>>How do I do cubic (and higher) roots ...
>>
>
>I think you're looking for the '**' operator.  Like addition and 
>multiplication, it can take in two numbers.
>
>##
>  
>
2 ** 2


>4
>  
>
And they also can be floating point numbers

 >>> 2 ** 0.5
1.4142135623730951
 >>> 2 **(1.0/3)
1.2599210498948732
 >>> 1.2599210498948732**3
2.0

:-)

gregor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] web intefaces?

2006-05-09 Thread Alfonso
Chad Crabtree wrote:
> While everything that Alan Guald said is true, there are a couple of
> options for you.  Provided you know HTML (you must), you could
> generate html pragmatically but, knowledge of html is still mandatory.
> Your options are, basically
>
> http://www.cherrypy.org
> Which is an app server that should be fairly easy to package up with,
> say py2exe.
>
> Another option, with CGI (pretty easy) is found in the standard library.
> http://docs.python.org/lib/module-CGIHTTPServer.html
>
> If you do this as a personal app I would make sure to use an alternate
> port number like 11224, or something.
>
> HTH
> Best of Luck.
>
> On 5/6/06, Alfonso <[EMAIL PROTECTED]> wrote:
>> I would like to experiment with web interfaces and python. After some
>> googling, I'm quite confused, does somebody know of a good link about
>> this topic / what do you think that is the best software option to
>> design web user intefaces with python? I mean web interfaces  for
>> common programms (so it's not important to me to have a very robust
>> web server), the web server should run in the machine of the user of
>> the programm.And it should be easy installed, as bundle, when I
>> distribute the programm.
>>
>> Thank very much for your help.
>>
>>
>>
>> __
>> LLama Gratis a cualquier PC del Mundo.
>> Llamadas a fijos y móviles desde 1 céntimo por minuto.
>> http://es.voice.yahoo.com
>> ___
>> Tutor maillist  -  Tutor@python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>
Thank you very much for your answers




__ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] 7bit - 8bit

2006-05-09 Thread János Juhász
Dear All,

I have to convert a binary stream from a monitoring device to another 
format.
The highets bit of  data bytes is replaced by 0 and placed after every 7 
bytes into a  correction byte.
I would like to decode it as simple as possible.
May someone suggest an elegant solution for that ?


Yours sincerely, 
__
Janos Juhasz 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] web intefaces?

2006-05-09 Thread Ron Phillips


I like Karrigell ...http://www.karrigell.com/ for being flexible, complete, lightweight, and easy to learn. I don't know how it scales, but that's not really a consideration for the applications you describe.
 
Ron>>> "Chad Crabtree" <[EMAIL PROTECTED]> 5/8/2006 6:29 PM >>>While everything that Alan Guald said is true, there are a couple ofoptions for you. Provided you know HTML (you must), you couldgenerate html pragmatically but, knowledge of html is still mandatory.Your options are, basicallyhttp://www.cherrypy.org Which is an app server that should be fairly easy to package up with,say py2exe.Another option, with CGI (pretty easy) is found in the standard library.http://docs.python.org/lib/module-CGIHTTPServer.html If you do this as a personal app I would make sure to use an alternateport number like 11224, or something.HTHBest of Luck.On 5/6/06, Alfonso < [EMAIL PROTECTED] > wrote:> I would like to experiment with web interfaces and python. After some googling, I'm quite confused, does somebody know of a good link about this topic / what do you think that is the best software option to design web user intefaces with python? I mean web interfaces for common programms (so it's not important to me to have a very robust web server), the web server should run in the machine of the user of the programm.And it should be easy installed, as bundle, when I distribute the programm.>> Thank very much for your help. __> LLama Gratis a cualquier PC del Mundo.> Llamadas a fijos y móviles desde 1 céntimo por minuto.> http://es.voice.yahoo.com > ___> Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor >
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] opening multiple connections to a port

2006-05-09 Thread Payal Rathod
Hi,
I have to see how many open connection can a particular service handle.
So, I want to similuate something like this but using Python.
telnet  

I will be keeping these connections open for around 60 seconds. Can 
anyone tell me how do I start with this in Python? I read a bit about 
telnetlib, but unable to figure how to open multiple simeltaneous 
connections.

With warm regards,
-Payal

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] opening multiple connections to a port

2006-05-09 Thread Kent Johnson
Payal Rathod wrote:
> Hi,
> I have to see how many open connection can a particular service handle.
> So, I want to similuate something like this but using Python.
> telnet  
> 
> I will be keeping these connections open for around 60 seconds. Can 
> anyone tell me how do I start with this in Python? I read a bit about 
> telnetlib, but unable to figure how to open multiple simeltaneous 
> connections.

If you create and open multiple instances of telnetlib.Telnet you should 
have multiple connections to the host.

Of course for this test to give meaningful results the machine running 
the test must be able to open more outgoing ports than the number of 
connections supported by the host, or you will have to use multiple 
client machines.

Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] 7bit - 8bit

2006-05-09 Thread Kent Johnson
János Juhász wrote:
> Dear All,
> 
> I have to convert a binary stream from a monitoring device to another 
> format.
> The highets bit of  data bytes is replaced by 0 and placed after every 7 
> bytes into a  correction byte.
> I would like to decode it as simple as possible.
> May someone suggest an elegant solution for that ?

By decode, do you mean go from the 7bit representation to the 8-bit binary?

A few things you may need:
To convert a string to a list of integer values use a list comprehension 
and ord():
[ ord(c) for c in s ]
or map():
map(ord, s)

To extract or set bits use the bitwise logical operators & and |

To assemble a list of integers back into a string use chr(), list comp 
or map(), and join():
''.join([chr(b) for b in bytes])
or
''.join(map(chr, bytes))

HTH
Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Should I use generators here?

2006-05-09 Thread Kent Johnson
Kent Johnson wrote:
> Generators are not an optimization technique so much as a way to 
> structure code that includes iteration.

This recipe is a good example of how using a simple generator can 
encapsulate a bit of processing that might be awkward to include in a 
larger processing loop. Generators are really useful when you want to 
process items in a sequence, producing a new sequence, and the 
processing requires maintaining some state. A generator lets you 
encapsulate the state and the logic using the state into a function that 
is usable by client code as a simple sequence.

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496682

Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] web intefaces?

2006-05-09 Thread Alfonso
Ron Phillips wrote:
> I like Karrigell ...http://www.karrigell.com/ for being flexible,
> complete, lightweight, and easy to learn. I don't know how it scales,
> but that's not really a consideration for the applications you describe.
>  
> Ron
>
> >>> "Chad Crabtree" <[EMAIL PROTECTED]> 5/8/2006 6:29 PM >>>
> While everything that Alan Guald said is true, there are a couple of
> options for you. Provided you know HTML (you must), you could
> generate html pragmatically but, knowledge of html is still mandatory.
> Your options are, basically
>
> _http://www.cherrypy.org _
> Which is an app server that should be fairly easy to package up with,
> say py2exe.
>
> Another option, with CGI (pretty easy) is found in the standard library.
> _http://docs.python.org/lib/module-CGIHTTPServer.html_
>
> If you do this as a personal app I would make sure to use an alternate
> port number like 11224, or something.
>
> HTH
> Best of Luck.
>
> On 5/6/06, Alfonso <_ [EMAIL PROTECTED]
> _ > wrote:
> > I would like to experiment with web interfaces and python. After
> some googling, I'm quite confused, does somebody know of a good link
> about this topic / what do you think that is the best software option
> to design web user intefaces with python? I mean web interfaces for
> common programms (so it's not important to me to have a very robust
> web server), the web server should run in the machine of the user of
> the programm.And it should be easy installed, as bundle, when I
> distribute the programm.
> >
> > Thank very much for your help.
> >
> >
> >
> > __
> > LLama Gratis a cualquier PC del Mundo.
> > Llamadas a fijos y móviles desde 1 céntimo por minuto.
> > _http://es.voice.yahoo.com _
> > ___
> > Tutor maillist - [EMAIL PROTECTED] _
> > _http://mail.python.org/mailman/listinfo/tutor_
> >
>
> 
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>   
Thank you Ron, I will have a look at that too


__ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Summing part of a list

2006-05-09 Thread Matthew Webber
I have a list that looks a bit like this -
 
[(u'gbr', 30505), (u'fra', 476), (u'ita', 364), (u'ger', 299),
(u'fin', 6), (u'ven', 6), (u'chi', 3), (u'hun', 3), (u'mar', 3),
(u'lux', 2), (u'smo', 2), (u'tch', 2), (u'aho', 1), (u'ber', 1)]

The list items are tuples, the first item of which is a country code, and
the second of which is a numeric count. The list is guarenteed SORTED in
descending order of the numeric count.

What I need is a list with all the members whose count is less than 3
replaced by a single member with the counts added together. In this case, I
want :
[(u'gbr', 30505), (u'fra', 476), (u'ita', 364), (u'ger', 299),
(u'fin', 6), (u'ven', 6), (u'OTHER', 17)]

Any ideas about neat ways to do this? The simplest way is to just build the
new list with a basic loop over the original list. A slightly more
sophisticated way is to split the original list using a list comprehension
with an IF clause.

I have the feeling that there's probably really neat and more Pythonic way -
there are possibilities like zip, map, itertools. Any hints about what to
look at? Remember that the list is sorted already. If you can point me in
the right direction, I'm sure I can work out the specifics of the code.

Thanks
Matthew



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Summing part of a list

2006-05-09 Thread Kent Johnson
Matthew Webber wrote:
> I have a list that looks a bit like this -
>  
> [(u'gbr', 30505), (u'fra', 476), (u'ita', 364), (u'ger', 299),
> (u'fin', 6), (u'ven', 6), (u'chi', 3), (u'hun', 3), (u'mar', 3),
> (u'lux', 2), (u'smo', 2), (u'tch', 2), (u'aho', 1), (u'ber', 1)]
> 
> The list items are tuples, the first item of which is a country code, and
> the second of which is a numeric count. The list is guarenteed SORTED in
> descending order of the numeric count.
> 
> What I need is a list with all the members whose count is less than 3
> replaced by a single member with the counts added together. In this case, I
> want :
> [(u'gbr', 30505), (u'fra', 476), (u'ita', 364), (u'ger', 299),
> (u'fin', 6), (u'ven', 6), (u'OTHER', 17)]
> 
> Any ideas about neat ways to do this? The simplest way is to just build the
> new list with a basic loop over the original list. A slightly more
> sophisticated way is to split the original list using a list comprehension
> with an IF clause.
> 
> I have the feeling that there's probably really neat and more Pythonic way -
> there are possibilities like zip, map, itertools. Any hints about what to
> look at? Remember that the list is sorted already. If you can point me in
> the right direction, I'm sure I can work out the specifics of the code.

Hmm, must be generator day today. Here is a generator that does what you 
want:

In [1]: data = [(u'gbr', 30505), (u'fra', 476), (u'ita', 364), (u'ger', 
299),
...: (u'fin', 6), (u'ven', 6), (u'chi', 3), (u'hun', 3), (u'mar', 3),
...: (u'lux', 2), (u'smo', 2), (u'tch', 2), (u'aho', 1), (u'ber', 1)]

In [10]: def summarize(data):
: sum = 0
: othersFound = False
: for item in data:
: if item[1] > 3:
: yield item
: else:
: sum += item[1]
: othersFound = True
: if othersFound:
: yield ('OTHER', sum)
:

In [11]: print list(summarize(data))
[(u'gbr', 30505), (u'fra', 476), (u'ita', 364), (u'ger', 299), (u'fin', 
6), (u'ven', 6), ('OTHER', 17)]

In [12]: print list(summarize(data[:4]))
[(u'gbr', 30505), (u'fra', 476), (u'ita', 364), (u'ger', 299)]

The loop yields all the pairs that have values bigger than three. When 
the end of the loop is reached, if there were any residuals the 'OTHER' 
item is yielded. (If the values are always >0 you could get rid of the 
othersFound flag and just use sum as the flag.)

You could probably work out a solution using itertools.groupby() also, 
or you could use two list comps, one filtering for value>3 and one 
filtering for value < 3. This gives a one-line solution but it iterates 
the list twice. List comps are fast enough that this might actually be 
faster than the generator solution:

In [5]: [ item for item in data if item[1] > 3 ] + [('OTHER', 
sum([item[1] for item in data if item[1] <= 3]))]
Out[5]:
[(u'gbr', 30505),
  (u'fra', 476),
  (u'ita', 364),
  (u'ger', 299),
  (u'fin', 6),
  (u'ven', 6),
  ('OTHER', 17)]

Neither of these solutions rely on the list being sorted. In fact I 
originally wrote a generator that did rely on the list sort and it was 
longer than the one I show here!

HTH
Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Summing part of a list

2006-05-09 Thread Bob Gailer
Matthew Webber wrote:
> I have a list that looks a bit like this -
>  
> [(u'gbr', 30505), (u'fra', 476), (u'ita', 364), (u'ger', 299),
> (u'fin', 6), (u'ven', 6), (u'chi', 3), (u'hun', 3), (u'mar', 3),
> (u'lux', 2), (u'smo', 2), (u'tch', 2), (u'aho', 1), (u'ber', 1)]
>
> The list items are tuples, the first item of which is a country code, and
> the second of which is a numeric count. The list is guarenteed SORTED in
> descending order of the numeric count.
>
> What I need is a list with all the members whose count is less than 3
>   
Do you mean less than 4? That's how your example works.
> replaced by a single member with the counts added together. In this case, I
> want :
> [(u'gbr', 30505), (u'fra', 476), (u'ita', 364), (u'ger', 299),
> (u'fin', 6), (u'ven', 6), (u'OTHER', 17)]
>
> Any ideas about neat ways to do this? 
cnt = 0
for pos, item in enumerate(yourList[::-1]):
  if item[1] >= 4: break
  cnt += item[1]
yourList = yourList[:len(yourList)-pos] + (u'OTHER', cnt)
> The simplest way is to just build the
> new list with a basic loop over the original list. A slightly more
> sophisticated way is to split the original list using a list comprehension
> with an IF clause.
>
> I have the feeling that there's probably really neat and more Pythonic way -
> there are possibilities like zip, map, itertools. Any hints about what to
> look at? Remember that the list is sorted already. If you can point me in
> the right direction, I'm sure I can work out the specifics of the code.
>
> Thanks
> Matthew
>
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>   

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Summing part of a list

2006-05-09 Thread Matthew Webber
To expand on my original posting, I came up with this code which works ok :

count_country_aggregated = [cc for cc in count_country if cc[1]>3]
count_country_aggregated.append(('OTHER',sum([cc[1] for cc in count_country
if cc[1]<=3])))

But it uses 2 list comprehensions (therefore 2 passes of the original list).
Surely there is a neater way. 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Matthew Webber
Sent: 09 May 2006 17:22
To: tutor@python.org
Subject: [Tutor] Summing part of a list

I have a list that looks a bit like this -
 
[(u'gbr', 30505), (u'fra', 476), (u'ita', 364), (u'ger', 299),
(u'fin', 6), (u'ven', 6), (u'chi', 3), (u'hun', 3), (u'mar', 3),
(u'lux', 2), (u'smo', 2), (u'tch', 2), (u'aho', 1), (u'ber', 1)]

The list items are tuples, the first item of which is a country code, and
the second of which is a numeric count. The list is guarenteed SORTED in
descending order of the numeric count.

What I need is a list with all the members whose count is less than 3
replaced by a single member with the counts added together. In this case, I
want :
[(u'gbr', 30505), (u'fra', 476), (u'ita', 364), (u'ger', 299),
(u'fin', 6), (u'ven', 6), (u'OTHER', 17)]

Any ideas about neat ways to do this? The simplest way is to just build the
new list with a basic loop over the original list. A slightly more
sophisticated way is to split the original list using a list comprehension
with an IF clause.

I have the feeling that there's probably really neat and more Pythonic way -
there are possibilities like zip, map, itertools. Any hints about what to
look at? Remember that the list is sorted already. If you can point me in
the right direction, I'm sure I can work out the specifics of the code.


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Call for volunteer to help revise images for One Day of IDLE Toying

2006-05-09 Thread Danny Yoo
> One of the major complaints that people have made about the "One Day of IDLE 
> Toying" tutorial I've written is that the screenshots are badly outdated.
>
>http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/
>
> I was curious if anyone wanted to volunteer to provide fresh, updated 
> Windows XP screenshots to replace the ones on the IDLE tutorial.

Thanks everyone!  I got some screenshots from Alan Gauld, and will revise 
the main page later today with the updated images.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] web intefaces?

2006-05-09 Thread Christian Wyglendowski

> > >>> "Chad Crabtree" <[EMAIL PROTECTED]> 5/8/2006 6:29 PM >>>
> > While everything that Alan Guald said is true, there are a 
> couple of 
> > options for you. Provided you know HTML (you must), you 
> could generate 
> > html pragmatically but, knowledge of html is still mandatory.
> > Your options are, basically
> >
> > _http://www.cherrypy.org _ Which 
> is an app 
> > server that should be fairly easy to package up with, say py2exe.

If you do go with CherryPy, check out this recipe I submitted to the
online Python Cookbook:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/442481

It was written for CherryPy 2.1 but should still work with the current
2.2 release.

Christian
http://www.dowski.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Summing part of a list

2006-05-09 Thread Matthew Webber
Thanks Kent, I liked the generator solution (I knew there had to be
something like that).

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Kent Johnson
Sent: 09 May 2006 17:54
Cc: tutor@python.org
Subject: Re: [Tutor] Summing part of a list

<< snip >> 

Hmm, must be generator day today. Here is a generator that does what you 
want:

In [1]: data = [(u'gbr', 30505), (u'fra', 476), (u'ita', 364), (u'ger', 
299),
...: (u'fin', 6), (u'ven', 6), (u'chi', 3), (u'hun', 3), (u'mar', 3),
...: (u'lux', 2), (u'smo', 2), (u'tch', 2), (u'aho', 1), (u'ber', 1)]

In [10]: def summarize(data):
: sum = 0
: othersFound = False
: for item in data:
: if item[1] > 3:
: yield item
: else:
: sum += item[1]
: othersFound = True
: if othersFound:
: yield ('OTHER', sum)
:

In [11]: print list(summarize(data))
[(u'gbr', 30505), (u'fra', 476), (u'ita', 364), (u'ger', 299), (u'fin', 
6), (u'ven', 6), ('OTHER', 17)]

<< snip >>


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] web intefaces?

2006-05-09 Thread Andre Roberge
On 5/9/06, Christian Wyglendowski <[EMAIL PROTECTED]> wrote:
[on creating a web app...]
>
> If you do go with CherryPy, check out this recipe I submitted to the
> online Python Cookbook:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/442481
>
> It was written for CherryPy 2.1 but should still work with the current
> 2.2 release.
>
I second this, absolutely. I have started creating such an app
["Crunchy Frog"] using CherryPy.  There are 10 tutorial examples
included in the distribution, which are a big help to get started.
André

P.S. Thank you Christian for your CherryPy newbie friendly recipe!
> Christian
> http://www.dowski.com
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] web intefaces?

2006-05-09 Thread Python
On Mon, 2006-05-08 at 18:29 -0400, Chad Crabtree wrote:
> While everything that Alan Guald said is true, there are a couple of
> options for you.  Provided you know HTML (you must), you could
> generate html pragmatically but, knowledge of html is still mandatory.
>  Your options are, basically
> 
> http://www.cherrypy.org
> Which is an app server that should be fairly easy to package up with,
> say py2exe.

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/442481

This is an example of configuring a cherrypy application so that it runs
and starts the browser.  It's a convenient way to make sure that the web
application is running before the browser tries to access it.  It also
shows how a cherrypy application can stop itself.

-- 
Lloyd Kvam
Venix Corp

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] help with erros using subprocess module

2006-05-09 Thread Jerome Jabson
Hi,

I've been trying to write a wrapper around some shells
scripts using the subprocess module. But I'm getting
errors I quite don't know how to debug. I've only been
writing Python for a few months and starting processes
are new to me. Here's my code:

import os
import re
import subprocess


 Definition 


def proc(cmd_in):
   cmd = cmd_in
   os.chdir("/home/qauser/jerome")
   outFile = os.path.join(os.curdir, "output.log")
   outptr = file(outFile, "w")
   errFile = os.path.join(os.curdir, "error.log")
   errptr = file(errFile, "w")
   retval = subprocess.call(cmd, 0, None, None,
outptr, errptr)
   errptr.close()
   outptr.close()
   if not retval == 0:
  errptr = file(errFile, "r")
  errData = errptr.read()
  errptr.close()
  raise Exception("Error executing command: " +
repr(errData))

def setup():
   print "=== Starting Setup ==="
   proc("/home/qauser/jerome/qaSetup.sh")
   print "=== Setup  Complete ==="

def run_junit():
   file_in =
open("/home/qauser/automation/testdata/junit_master_file",
"r")
   match = re.compile('#+')
   work_list = []
   for line in file_in:
  work = line
  work = work.rstrip('\n')
  if match.search(work):
 found = False
  else:
 found = True
  if found == True:
 work_list = work.split(',')
 arg1 = work_list[0]
 arg2 = work_list[1]
 arg3 = work_list[2]
 arg4 = work_list[3]
 cmd = "/home/qauser/jerome/qaRun.sh %s %s %s
%s"
 cmdstr = cmd % (arg1,arg2,arg3,arg4)
 print "=== Starting JUnit Run ==="
 proc(cmdstr)
 print "=== JUnit Run Complete ==="



##  Main  ##


setup()
run_junit()

The setup() def seems to work great, but the
run_junit() seems to have problems. I believe due to
the params I'm passing. Here are the errors I'm
getting:

[EMAIL PROTECTED] automation]$ ./runJunit.py 
=== Starting JUnit Run ===
Traceback (most recent call last):
  File "/home/qauser/automation/runJunit.py", line 63,
in ?
run_junit()
  File "/home/qauser/automation/runJunit.py", line 54,
in run_junit
proc(cmdstr)
  File "/home/qauser/automation/runJunit.py", line 18,
in proc
retval = subprocess.call(cmd, 0, None, None,
outptr, errptr)
  File
"/opt/python-2.4.3/lib/python2.4/subprocess.py", line
412, in call
return Popen(*args, **kwargs).wait()
  File
"/opt/python-2.4.3/lib/python2.4/subprocess.py", line
542, in __init__
errread, errwrite)
  File
"/opt/python-2.4.3/lib/python2.4/subprocess.py", line
975, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

I can't seem to figure out what file or directory is
missing. 

Your help is greatly appreciated,
Jerome

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] question regarding subprocess.Popen

2006-05-09 Thread Yi Qiang
Hi list,
I am launching another python program in my python daemon like this:

 pobj = subprocess.Popen(tlsmd,
 stdin = subprocess.PIPE,
 stdout = subprocess.PIPE,
 stderr = subprocess.STDOUT,
 close_fds = True,
 bufsize = 0)

I want to detect when the process has exited abnormally (or when I 
ctrl+c it)so I thought I could use pobj.returncode.  However after 
fiddling with it for a while my KeyboardInterrupt does not seem to be 
sent to pobj (i tried re-raising a KeyboardInterrupt there as well) nor 
did testing for pobj.returncode yield any results.
Any ideas?

Thanks
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor