[pkg-fso-maint] WiFi-Tool (or GPRS-Tool modified)

Esteban Monge esteban.francisco at gmail.com
Tue Oct 13 18:32:31 UTC 2009


Hello again, I modified the script to:
#!/usr/bin/env python

import os, time, random, gtk, gobject

class wifi:
    def delete_event(self, widget, event=None, data=None):
        gtk.main_quit()
        return False

    def set_status(self, label):
        status = os.system("ifconfig eth0")
        if status == 0:
            status = "WiFi Power On"
            label.set_text(status)
            label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("green"))

        else:
            status = "WiFi Power Off"
            label.set_text(status)
            label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("red"))

        return True

    def wifi_on(self, button):
        os.system("mdbus -s org.freesmartphone.ousaged
/org/freesmartphone/Usage org.freesmartphone.Usage.SetResourcePolicy WiFi
enabled")

    def wifi_off(self, button):
        os.system("mdbus -s org.freesmartphone.ousaged
/org/freesmartphone/Usage org.freesmartphone.Usage.SetResourcePolicy WiFi
disabled")

    def __init__(self):

        # Iniciar la ventana principal
        self.win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.win.connect("delete_event", self.delete_event)

        # Anadir una VBox
        self.vbox = gtk.VBox(homogeneous=False, spacing=1)
        self.win.add(self.vbox)
        self.vbox.show()

        # Anadir el senalador de estatus
        self.status_label = gtk.Label("Status")
        self.vbox.pack_start(self.status_label)
        self.status_label.show()
        gobject.timeout_add (3000, self.set_status, self.status_label)

        # Anadir una Vbox para las etiquetas de informacion
        self.vbox1 = gtk.VBox(homogeneous=False, spacing=1)
        self.vbox.pack_start(self.vbox1)
        self.vbox1.show()

        # Anadir una HBox para los botones
        self.hbox0 = gtk.HBox(homogeneous=False, spacing=5)
        self.vbox.pack_start(self.hbox0)
        self.hbox0.show()

        # Anadir el boton de encendido
        self.wifi = gtk.Button("Turn On WiFi")
        self.hbox0.pack_start(self.wifi)
        self.wifi.connect("clicked", self.wifi_on)
        self.wifi.show()

        # Anadir el boton de apagado
        self.wifioff = gtk.Button("Turn Off WiFi")
        self.hbox0.pack_start(self.wifioff)
        self.wifioff.connect("clicked", self.wifi_off)
        self.wifioff.show()

        # Anadir el boton de salida
        self.button_exit = gtk.Button("Exit")
        self.vbox.pack_start(self.button_exit)
        self.button_exit.connect("clicked", self.delete_event)
        self.button_exit.show()

        self.win.show()

    def main(self):
        gtk.main()

if __name__ == '__main__':
    gui = wifi()
    gui.main()

The change is the use of the Policies of FSO.

Also I modifiy the script to Power On the Bluetooth, I use also Policies of
FSO:

#!/usr/bin/env python

import os, time, random, gtk, gobject

class bluetooth:
    def delete_event(self, widget, event=None, data=None):
        gtk.main_quit()
        return False

    def set_status(self, label):
        status = os.system("hciconfig hci0")
        if status == 0:
            status = "Bluetooth Power On"
            label.set_text(status)
            label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("green"))

        else:
            status = "Bluetooth Power Off"
            label.set_text(status)
            label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("red"))

        return True

    def bluetooth_on(self, button):
        os.system("mdbus -s org.freesmartphone.ousaged
/org/freesmartphone/Usage org.freesmartphone.Usage.SetResourcePolicy
Bluetooth enabled")

    def bluetooth_off(self, button):
        os.system("mdbus -s org.freesmartphone.ousaged
/org/freesmartphone/Usage org.freesmartphone.Usage.SetResourcePolicy
Bluetooth disabled")

    def __init__(self):

        # Iniciar la ventana principal
        self.win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.win.connect("delete_event", self.delete_event)

        # Anadir una VBox
        self.vbox = gtk.VBox(homogeneous=False, spacing=1)
        self.win.add(self.vbox)
        self.vbox.show()

        # Anadir el senalador de estatus
        self.status_label = gtk.Label("Status")
        self.vbox.pack_start(self.status_label)
        self.status_label.show()
        gobject.timeout_add (3000, self.set_status, self.status_label)

        # Anadir una Vbox para las etiquetas de informacion
        self.vbox1 = gtk.VBox(homogeneous=False, spacing=1)
        self.vbox.pack_start(self.vbox1)
        self.vbox1.show()

        # Anadir una HBox para los botones
        self.hbox0 = gtk.HBox(homogeneous=False, spacing=5)
        self.vbox.pack_start(self.hbox0)
        self.hbox0.show()

        # Anadir el boton de encendido
        self.bluetooth = gtk.Button("Turn On Bluetooth")
        self.hbox0.pack_start(self.bluetooth)
        self.bluetooth.connect("clicked", self.bluetooth_on)
        self.bluetooth.show()

        # Anadir el boton de apagado
        self.bluetoothoff = gtk.Button("Turn Off Bluetooth")
        self.hbox0.pack_start(self.bluetoothoff)
        self.bluetoothoff.connect("clicked", self.bluetooth_off)
        self.bluetoothoff.show()

        # Anadir el boton de salida
        self.button_exit = gtk.Button("Exit")
        self.vbox.pack_start(self.button_exit)
        self.button_exit.connect("clicked", self.delete_event)
        self.button_exit.show()

        self.win.show()

    def main(self):
        gtk.main()

if __name__ == '__main__':
    gui = bluetooth()
    gui.main()

Works great for my, maybe I can modify to make a big script to integrate the
three functions, also I want make the packages and more pretty UI. I have
used CC logos for icons, in case of make the package.

Sorry for my english... and hope works for others.

Thanks to all for the ideas... I want more for make a best way to power on
the functions.
-- 
http://nuevaeracr.blogspot.com
Linux user number 478378
Linux machine number 386687
Tec. Esteban Monge Marín
Tel: (506) 8379-3562

“No habrá manera de desarrollarnos y salir de
la pobreza mientras los pocos negocios
grandes de nuestro medio se entreguen a las
economías foráneas y nosotros nos
quedemos con solo negocios de pobre,
mientras en vez de ser propietarios de nuestro
propio país nos convirtamos en un ejército de
empleados del exterior”
José Figueres Ferrer, 1952.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-fso-maint/attachments/20091013/96d8aab9/attachment.htm>


More information about the pkg-fso-maint mailing list