2010-09-09, 20:40
I am trying to use a script within my plugin to prepopulate items in the settings based on the local host, the script itself works up to the point of actually putting the returned data into the designated setting I have specified.
Here is my code:
Help would be appreciated. Thanks!
Here is my code:
Code:
import subprocess, platform
ipaddr=''
arg='ip route list'
p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE)
data = p.communicate()
sdata = data[0].split()
ipaddr = sdata[ sdata.index('src')+1 ]
#netdev = sdata[ sdata.index('dev')+1 ]
localhost = '' + ipaddr
self.settings.setSetting(id="localhost", value=""+localhost+"" )
Help would be appreciated. Thanks!