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
This commit is contained in:
@@ -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 *
|
||||
|
||||
|
||||
|
||||
@@ -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 = {}
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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' '''
|
||||
|
||||
|
||||
@@ -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 '''
|
||||
|
||||
Reference in New Issue
Block a user