diff --git a/interface/ri_tk_cmd.py b/interface/ri_tk_cmd.py index 23cdf35..c6eb82f 100644 --- a/interface/ri_tk_cmd.py +++ b/interface/ri_tk_cmd.py @@ -125,6 +125,13 @@ 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 check_address(n): + if (re.match("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$",n) and \ + len([i for i in n.split('.') if (0<= int(i) <=255)])==4): + return True + else: + return False + def network_quit(): ''' network quit ''' ri_data.Network.hostname = display.var_dict['network_host_name'].get() @@ -139,13 +146,14 @@ def network_quit(): if not ri_data.Network.hostname: ri_widget.MessageBox.dict['check_ip_hostname'].show() ri_widget.Sequence.previous() - elif ri_data.Network.configuration == "static" and \ - (not re.match("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$",ri_data.Network.ip) or \ - not re.match("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$",ri_data.Network.mask) or \ - not re.match("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$",ri_data.Network.gateway) or \ - not re.match("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$",ri_data.Network.primary_dns)): + elif (ri_data.Network.configuration == "static" and \ + ((not check_address(ri_data.Network.ip) )or \ + (not check_address(ri_data.Network.mask) )or \ + (not check_address(ri_data.Network.gateway) )or \ + (not check_address(ri_data.Network.primary_dns)) ) ): ri_widget.MessageBox.dict['check_ip_hostname'].show() ri_widget.Sequence.previous() + #IP 0.0.0.0--255.255.255.255 def ncm_dynamic(): ''' when radio button ncm dynamic is checked, several data entry will be set 'disable' '''