what's wrong with my popen reasoning?

Michael Williams mwilliams at mgreg.com
Sun Feb 5 16:10:34 EST 2006


Hello,

I would possibly look into using Pexpect (http:// 
pexpect.sourceforge.net/) and the python "time" module for things of  
this nature.  It gives you a bit more granular control over what  
happens when.

Regards,
Michael


On Feb 5, 2006, at 2:57 PM, python-list-request at python.org wrote:

> From: Rick Spencer <rick at localhost.localdomain>
> Date: February 5, 2006 1:39:18 PM EST
> To: python-list at python.org
> Subject: what's wrong with my popen reasoning?
>
>
> Hi all,
>
> I am very new to Python programming. I am writing a program to manage
> wireless connections, this is for GNOME on Linux. I present the  
> user with
> a "connect" button. I want to handle the connection for them slightly
> different depending on whether or not the wireless access point  
> they are
> trying to connect to is secure. In either case, I have a similar  
> question.
>
> In the first case, the wireless access point is secured. I want to  
> bring
> up the GNOME applet for configuring a wireless access interface.  I  
> can
> pass the command line commands to bring it up, but I can't figure  
> out how
> to bring it up in a modal fashion, so that my Python program waits  
> for the
> user to dismiss it before my program gets control again.
>
> In the second case, the access point is not secured. I just want to  
> fire
> off the command line utility (iwconfig) for connecting. In this  
> case, I
> want my program to wait until iwconfig is done before continuing on. I
> figure that I could just write a line of code to read in from the  
> console,
> but I thought there might be a more pythonic way of doing it.
>
> Here's my function so far, with variables replaced with constants  
> to make
> it easier to read:
>
> def connect_clicked(self, widget, data=None):
>  if locked:
>   os.popen("sudo network-admin -c ath0")
>   self.emit('connection-attempted', "ath0")
>
>  else:
>   os.popen("sudo iwconfig ath0 ap 00:0F:B3:31:CB:01")
>  self.emit('connection-attempted', "ath0")
>
> Thanks much!
>
> Cheers, Rick
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060205/96cbb62f/attachment.html>


More information about the Python-list mailing list