1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-21 05:18:02 +01:00

curses/configscript_curses.py: ADDED. Script configurator. More or less done.

curses/wicd-curses.py:
  Added suport for the script configurator
curses/README, in/man=wicd-curses.8.in:
  Script configurator now active
setup.py: Install configscript_curses.py with the rest of the stuff
This commit is contained in:
Andrew Psaltis
2009-01-17 20:10:10 -05:00
parent f01f10d33f
commit ce64ce0aa2
6 changed files with 195 additions and 3 deletions

View File

@@ -45,7 +45,8 @@ from dbus import version as dbus_version
import gobject
# Other important wicd-related stuff
import wicd.misc as misc
from wicd import wpath
from wicd import misc
from wicd import dbusmanager
# Internal Python stuff
@@ -58,6 +59,10 @@ from prefs_curses import PrefsDialog
import netentry_curses
from netentry_curses import WirelessSettingsDialog, WiredSettingsDialog,error
# Stuff about getting the script configurer running
from grp import getgrgid
from os import getgroups,system
language = misc.get_language_list_gui()
########################################
@@ -245,6 +250,36 @@ def help_dialog(body):
help = TextDialog(theText,15,62,header=('header',"Wicd-Curses Help"))
help.run(ui,body)
def run_configscript(netname,nettype):
loop.quit()
ui.stop()
argv = netname + ' ' +nettype
#cmd = '/usr/lib/configscript_curses.py '+argv
cmd = wpath.lib+'configscript_curses.py '+argv
# Check whether we can sudo. Hopefully this is complete
glist = []
for i in getgroups():
glist.append(getgrgid(i)[0])
if 'root' in glist:
precmd = ''
precmdargv = ''
postcmd = ''
elif 'admin' in glist or 'wheel' in glist:
precmd = 'sudo'
precmdargv = ''
postcmd = ''
else:
precmd = 'su'
precmdargv = ' -c "'
postcmd = '"'
print "Calling command: " + precmd + precmdargv + cmd + postcmd
sys.stdout.flush()
system(precmd+precmdargv+cmd+postcmd)
raw_input("Press enter!")
main()
########################################
##### URWID SUPPORT CLASSES
########################################
@@ -698,6 +733,16 @@ class appGUI():
self.raise_hidden_network_dialog()
if "H" in keys:
help_dialog(self.frame)
if "S" in keys:
focus = self.thePile.get_focus()
if focus == self.wiredCB:
nettype = 'wired'
netname = self.wiredCB.get_body().get_selected_profile()
else:
nettype = 'wireless'
netname = str(self.wiredLB.get_focus()[1])
run_configscript(netname,nettype)
for k in keys:
if urwid.is_mouse_event(k):
event, button, col, row = k