what's wrong with my popen reasoning?

Rick Spencer rick at localhost.localdomain
Sun Feb 5 17:56:34 EST 2006


On Sun, 05 Feb 2006 10:39:18 -0800, Rick Spencer wrote:
<snip>

>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

I found some python code that had the answer. 

def connect_clicked(self, widget, data=None):
 if self.wirelessconnection.locked:
  subprocess.call(["network-admin", "-c", "ath0"])

This  makes my app just wait until the network-admin process is gone.

Cheers, Rick





More information about the Python-list mailing list