From d8d7bb036d4ec1c1af693873b956b3a5e41527c0 Mon Sep 17 00:00:00 2001 From: fling Date: Thu, 9 Dec 2010 09:17:52 +0800 Subject: [PATCH] modified: ri_cmd.py modified: ri_data.py modified: ri_tk.py modified: ri_tk_cmd.py modified: ri_widget.py add network check ip and hostname funcation --- interface/ri_cmd.py | 23 +++-------------------- interface/ri_data.py | 7 ------- interface/ri_tk.py | 11 +++++++---- interface/ri_tk_cmd.py | 12 +++++++++++- interface/ri_widget.py | 4 ++-- 5 files changed, 23 insertions(+), 34 deletions(-) diff --git a/interface/ri_cmd.py b/interface/ri_cmd.py index 49d1e06..08f3354 100644 --- a/interface/ri_cmd.py +++ b/interface/ri_cmd.py @@ -4,8 +4,6 @@ import ri_widget import os import ri_tk -from ri_data import Network -from ri_tk_cmd import network_quit as network_update def quit(): ''' correspond to quit button ''' @@ -30,30 +28,15 @@ def previous(): def next(): ''' correspond to next button ''' q, t = ri_widget.Sequence.current() - - if not check_date(t): - return - wid_name = ri_widget.Sequence.next() if wid_name is not None: - ri_widget.Widget.dict[t].hide() + ri_widget.Widget.dict[t].hide(t) ri_widget.Widget.dict[wid_name].show() else: code = ri_widget.MessageBox.dict["next"].show() if code == True: os.execl('/usr/bin/python','python','ri_install.py', "-d","tk","-l",ri_tk.language) - -def check_date(operate): - '''check date ''' - if operate == "network" : - network_update() - if not Network.hostname: - ri_widget.MessageBox.dict['check_ip_hostname'].show() - return False - if Network.configuration == "static" and not Network.check_ip() : - ri_widget.MessageBox.dict['check_ip_hostname'].show() - return False - return True - from ri_tk_cmd import * + + diff --git a/interface/ri_data.py b/interface/ri_data.py index 20cd39a..ac7e88c 100644 --- a/interface/ri_data.py +++ b/interface/ri_data.py @@ -450,13 +450,6 @@ p_node - xml node (parent node)''' to_xml_attr(doc, ntwk, Network, nm) p_node.appendChild(ntwk) - @staticmethod - def check_ip() : - """check network ip""" - if Network.ip and Network.mask and Network.gateway and Network.primary_dns: - return True - return False - class Group: ''' software package group ''' dict = {} diff --git a/interface/ri_tk.py b/interface/ri_tk.py index a07b0d1..c4ebb1e 100644 --- a/interface/ri_tk.py +++ b/interface/ri_tk.py @@ -154,18 +154,21 @@ def create_widget_sub(w, p_win): # while destroying a widget, only destroy one. Tk functions will # destroy all descendant. # so init is a little different from quit. -def process_action_quit(w): +def process_action_quit(w,step=''): ''' process action quit ''' if 'action' in dir(w) and 'quit' in w.action.dict: - getattr(sys.modules['ri_cmd'], w.action.dict['quit'])() + if step == 'network': + getattr(sys.modules['ri_cmd'], w.action.dict['quit'])(step) + else: + getattr(sys.modules['ri_cmd'], w.action.dict['quit'])() if 'widgets' in dir(w): for sub_w in w.widgets: process_action_quit(sub_w) -def destroy_widget(w): +def destroy_widget(w,step=''): ''' w - Widget instance ''' - process_action_quit(w) + process_action_quit(w,step) w.tk_widget.destroy() def create_message_box(w): diff --git a/interface/ri_tk_cmd.py b/interface/ri_tk_cmd.py index 1c29253..749d6fc 100644 --- a/interface/ri_tk_cmd.py +++ b/interface/ri_tk_cmd.py @@ -116,7 +116,7 @@ def network_init(): display.var_dict['network_primary_dns']. set(value=ri_data.Network.primary_dns) display.var_dict['network_secondary_dns'].set(value=ri_data.Network.secondary_dns) -def network_quit(): +def network_quit(step=''): ''' network quit ''' ri_data.Network.hostname = display.var_dict['network_host_name'].get() ri_data.Network.configuration = display.var_dict['network_config_method'].get() @@ -127,6 +127,16 @@ def network_quit(): ri_data.Network.primary_dns = display.var_dict['network_primary_dns'].get() ri_data.Network.secondary_dns = display.var_dict['network_secondary_dns'].get() + if step == "network": + if not ri_data.Network.hostname: + ri_widget.MessageBox.dict['check_ip_hostname'].show() + if ri_data.Network.configuration == "static" and \ + not ri_data.Network.ip and \ + not ri_data.Network.mask and \ + not ri_data.Network.gateway and \ + not ri_data.Network.primary_dns : + ri_widget.MessageBox.dict['check_ip_hostname'].show() + def ncm_dynamic(): ''' when radio button ncm dynamic is checked, several data entry will be set 'disable' ''' diff --git a/interface/ri_widget.py b/interface/ri_widget.py index 674f869..846bcb4 100644 --- a/interface/ri_widget.py +++ b/interface/ri_widget.py @@ -89,8 +89,8 @@ class Widget: Widget.current_widget = self display.create_widget(self) - def hide(self): - display.destroy_widget(self) + def hide(self,step=''): + display.destroy_widget(self,step) class MessageBox: ''' implement dialog in interface.xml '''