rockymeza / wifi

[unmaintained] WiFi tools for linux

Home Page:http://pypi.python.org/pypi/wifi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

subprocess.CalledProcessError: Command '['/sbin/ifdown', 'wlan0']' returned non-zero exit status 1

Develoman opened this issue · comments

commented

Hi @rockymeza ,

Im working in.

Ubuntu 14.04
wifi 0.3.4
python 2.7

I get this Bug:

Traceback (most recent call last):
  File "/home/.../workspace/client-wifi-configuration/wifimanage/linux/__init__.py", line 39, in <module>
    scheme.activate()
  File "/home/.../workspace/client-wifi-configuration/venv/local/lib/python2.7/site-packages/wifi/scheme.py", line 155, in activate
    subprocess.check_output(['/sbin/ifdown', self.interface], stderr=subprocess.STDOUT)
  File "/usr/lib/python2.7/subprocess.py", line 573, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['/sbin/ifdown', 'wlan0']' returned non-zero exit status 1

and the code:

    cell  =  Cell.all('wlan0')[ 0 ]
    scheme  =  Scheme.for_cell('wlan0','home', cell,'pw')
    scheme.save() #success save scheme in /etc/network/interfaces
    scheme.activate()

the scheme :

iface wlan0-home inet dhcp
    wpa-psk 2252012b5441f871ad6e27192d0a9d81797fded0be25525d9fb2c9e86333c772
    wpa-ssid ....
    wireless-channel auto

And the output console:

>>> import wifi.subprocess_compat as subprocess
>>> subprocess.check_output(["ls", "-l", "/dev/null"])
'crw-rw-rw- 1 root root 1, 3 \xd9\x8a\xd9\x88\xd9\x86  7 09:05 /dev/null\n'
>>> subprocess.check_output(["/bin/sh", "-c","ls -l fgt.txt ; exit 0"],stderr=subprocess.STDOUT)
"ls: impossible d'acc\xc3\xa9der \xc3\xa0 fgt.txt: Aucun fichier ou dossier de ce type\n"
commented

Done, i use eclipse under user permission whereas commands ifup/ifdown must run with root permission .so, i run eclispe with root using "gksu eclispe" , so the ifdown and ifup are perfectly executed the script subprocess.check_output.
Thx

Are you running wifi from eclipse?

-rocky
2015年6月12日 上午3:30于 "Develoman" notifications@github.com写道:

Closed #69 #69.


Reply to this email directly or view it on GitHub
#69 (comment).

commented

Yes
first of all, i test commands if(down/up) in console with user so failed result
in second time i test it with root user , then it's running
ex: sudo ifdown wlan0
and sudo ifup --force wlan0
(wlan0 must be configured)

By running eclipse with gksu eclipse (root mode) and add sleep time just after check_output in activate method to take enough time to down ... the wifi run perfectly
(without network manager)

eclipse wifi connect

Great, I'm happy that it worked