Changeset 956

Show
Ignore:
Timestamp:
09/05/08 11:14:00 (3 months ago)
Author:
mariodebian
Message:

tcos-configurator (1.5)

  • Now Depends on python-netifaces
  • Change ifaces detection code to use netifaces module
  • Hide como_boot_mode (and label) if only one method is found
Location:
trunk/tcos-configurator
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/tcos-configurator/Makefile

    r903 r956  
    1111clean: 
    1212        find -name "*~" | xargs rm -f 
     13        rm -f tcos-configurator.glade.bak tcos-configurator.gladep 
    1314 
    1415test: 
  • trunk/tcos-configurator/debian/changelog

    r945 r956  
     1tcos-configurator (1.5) unstable; urgency=low 
     2 
     3  * Now Depends on python-netifaces 
     4  * Change ifaces detection code to use netifaces module 
     5  * Hide como_boot_mode (and label) if only one method is found 
     6 
     7 -- Mario Izquierdo (mariodebian) <mariodebian@gmail.com>  Fri, 05 Sep 2008 11:13:31 +0200 
     8 
    19tcos-configurator (1.4) unstable; urgency=low 
    210 
  • trunk/tcos-configurator/debian/control

    r890 r956  
    1212Package: tcos-configurator 
    1313Architecture: all 
    14 Depends: tcosconfig, gksu, python-gtk2, python-glade2,  
     14Depends: tcosconfig, gksu, python-gtk2, python-glade2, python-netifaces,  
    1515         python-configobj, ${misc:Depends}, ${shlibs:Depends}, ${python:Depends} 
    1616Description: PyGTK tool to configure some needed services to get a TCOS server 
  • trunk/tcos-configurator/tcos-configurator

    r945 r956  
    4949from threading import Thread 
    5050 
     51import netifaces 
     52 
    5153import pwd 
    5254 
     
    222224        for widget in ['img_logo', 'combo_interfaces', 'txt_serverip', 'txt_startip',  
    223225                       'txt_endip', 'btn_configure_dhcp', 'combo_boot_mode', 'hbox_dynamic', 
    224                        'ck_static', 'btn_hostname_help', 'txt_hostname_prefix', 'lbl_dhcp']: 
     226                       'ck_static', 'btn_hostname_help', 'txt_hostname_prefix', 'lbl_dhcp', 'label_boot_mode']: 
    225227            self.w[widget]=self.ui.get_widget(widget) 
    226228         
     
    235237        self.populate_select(self.w['combo_boot_mode'], self.BOOT_MODES) 
    236238        self.set_active_in_select(self.w['combo_boot_mode'], self.BOOT_MODES[0][0]) 
     239        if len(self.BOOT_MODES) < 2: 
     240            self.w['combo_boot_mode'].hide() 
     241            self.w['label_boot_mode'].hide() 
    237242         
    238243        self.interfaces=self.getNetInterfaces() 
     
    347352                self.w['lbl_dhcp'].set_markup( _("WARNING:\n<b>Network interface don't have IP</b>") ) 
    348353                self.w['lbl_dhcp'].show() 
    349                 print_debug("iface=%s don't have ip" %iface) 
     354                self.w['txt_serverip'].set_text('') 
     355                self.w['txt_startip'].set_text('') 
     356                self.w['txt_endip'].set_text('') 
     357                print_debug("iface=%s DON'T HAVE IP" %iface) 
    350358        if configured: 
    351359            self.w['lbl_dhcp'].hide() 
    352             self.w['hbox_dynamic'].show() 
    353             self.w['ck_static'].set_active(True) 
     360            self.w['hbox_dynamic'].hide() 
     361            self.w['ck_static'].set_active(False) 
    354362 
    355363    def set_dhcp_modified(self, *args): 
     
    487495    def get_ip_address(self, ifname): 
    488496        print_debug("get_ip_address() ifname=%s" %(ifname) ) 
     497        if not ifname in netifaces.interfaces(): 
     498            return None 
     499        ip=netifaces.ifaddresses(ifname) 
     500        if ip.has_key(netifaces.AF_INET): 
     501            return ip[netifaces.AF_INET][0]['addr'] 
     502        return None 
     503        """ 
     504        old code 
     505        print_debug("get_ip_address() ifname=%s" %(ifname) ) 
    489506        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 
    490507        return socket.inet_ntoa(fcntl.ioctl( 
     
    493510            struct.pack('256s', ifname[:15]) 
    494511        )[20:24]) 
     512        """ 
    495513 
    496514 
    497515    def getNetInterfaces(self): 
     516        interfaces=[] 
     517        for dev in netifaces.interfaces(): 
     518            if dev != "lo" and dev != "sit0" and not dev.startswith("vbox") and not dev.startswith("vmnet") and not dev.startswith("wmaster"): 
     519                ip=self.get_ip_address(dev) 
     520                print_debug("getNetInterfaces() iface=%s data=%s"%(dev,ip)) 
     521                interfaces.append( [dev, ip] ) 
     522        return interfaces 
     523        """ 
     524        old code 
    498525        interfaces=[] 
    499526        for edir in glob.glob("/sys/class/net/*"): 
     
    508535                interfaces.append( [edir, IP]) 
    509536        return interfaces 
     537        """ 
    510538 
    511539    def read_etc_network_interfaces(self): 
  • trunk/tcos-configurator/tcos-configurator.glade

    r890 r956  
    353353 
    354354              <child> 
    355                 <widget class="GtkLabel" id="label19"> 
     355                <widget class="GtkLabel" id="label_boot_mode"> 
    356356                  <property name="visible">True</property> 
    357357                  <property name="label" translatable="yes">Boot mode</property>