473,411 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

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

Feb 5 '06 #1
1 1423
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
Feb 5 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Stuart McGraw | last post by:
When I run (Python 2.3.3) this script on a MS Windows 2000 machine: import os print "1st popen..." f = os.popen ("echo " + u"\u0054\u0045\u0053\u0054.txt") print f.read () print "2nd popen..."...
1
by: Qiangning Hong | last post by:
I decide to seperate my data collection routine from my data analysis and storage program to a seperate process, so I try to use the new subprocess model in Python 2.4. The main program spawns...
17
by: bastiaannaber | last post by:
I am trying to write a program which uses popen but I have a problem. I want to detect if the program I call with popen has ended. For example: #include <stdio.h> #include <sys/types.h>...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
3
by: Jesse | last post by:
Hi all, I have a problem using wget and Popen. I hope someone can help. -- Problem -- I want to use the command: wget -nv -O "dir/cpan.txt" "http://search.cpan.org" and capture all it's...
14
by: Mohamed Mansour | last post by:
Hey there, this will be somewhat a long post, but any response is appreciated! I have done many PInvoke in the past from C++ to C#, but I did PInvoke within C# not C++/CLI. Can someone explain...
1
by: Brendan Miller | last post by:
I need a portable way to tell what subprocess.Popen will call. For instance on unix systems, Popen will work for files flagged with the executable bit, whereas on windows Popen will work on files...
25
by: Jeremy Banks | last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the Popen class in the subprocess module. Popen sounds like the a suitable name for a function that created a subprocess, but the...
1
by: Mark Shewfelt | last post by:
Hello, I am attempting to use Popen() in a Windows service. I have a small Win32 .exe that I normally run through the os.popen2() function. I've written a class to work with the input and output...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.