@@ -29,9 +29,9 @@ def PrintException():
2929 filename = f .f_code .co_filename
3030 print ('Exception in {}, line {}; {}' .format (filename , lineno , exc_obj ))
3131
32- def check_ip (s : str ):
32+ def check_ip (s : str , req = True ):
3333 if s == "" :
34- return False
34+ return not req
3535 spl = s .split ("." )
3636 if len (spl ) != 4 :
3737 sg .Popup ("Wrong IP format.\n Value should be similar to 255.255.255.255" )
@@ -506,6 +506,7 @@ def run(self) -> None:
506506 self .resetGui ()
507507 self .getDevices ()
508508 elif event == "dynamicBut" :
509+ # Clear out IPv4 settings to default to
509510 self .window .Element ('ip' ).update ('' )
510511 self .window .Element ('mask' ).update ('' )
511512 self .window .Element ('gateway' ).update ('' )
@@ -547,10 +548,16 @@ def getConfigs(self):
547548 else :
548549 self .window .Element ('gateway' ).update (conf .getIPv4Gateway ())
549550
550- self .window .Element ('dns' ).update (conf .getDnsIPv4 ())
551- self .window .Element ('dnsAlt' ).update (conf .getDnsAltIPv4 ())
551+ if conf .getDnsIPv4 () == '0.0.0.0' :
552+ self .window .Element ('dns' ).update ('' )
553+ else :
554+ self .window .Element ('dns' ).update (conf .getDnsIPv4 ())
555+ if conf .getDnsAltIPv4 () == '0.0.0.0' :
556+ self .window .Element ('dnsAlt' ).update ('' )
557+ else :
558+ self .window .Element ('dnsAlt' ).update (conf .getDnsAltIPv4 ())
552559 self .window .Element ('networkTimeout' ).update (int (conf .getNetworkTimeout ().total_seconds () * 1000 ))
553- if conf .getMacAddress () == '00:00:00:00:00' :
560+ if conf .getMacAddress () == '00:00:00:00:00:00 ' :
554561 self .window .Element ('mac' ).update ('' )
555562 else :
556563 self .window .Element ('mac' ).update (conf .getMacAddress ())
@@ -665,10 +672,10 @@ def flashConfig(self):
665672 if check_ip (values ['ip' ]) and check_ip (values ['mask' ]) and check_ip (values ['gateway' ]):
666673 conf .setStaticIPv4 (values ['ip' ], values ['mask' ], values ['gateway' ])
667674 else :
668- if check_ip (values ['ip' ]) and check_ip (values ['mask' ]) and check_ip (values ['gateway' ]):
675+ if check_ip (values ['ip' ], req = False ) and check_ip (values ['mask' ], req = False ) and check_ip (values ['gateway' ], req = False ):
669676 conf .setDynamicIPv4 (values ['ip' ], values ['mask' ], values ['gateway' ])
670- if values [ 'dns' ] != "" and values [ 'dnsAlt' ] != "" :
671- conf .setDnsIPv4 (values ['dns' ], values ['dnsAlt' ])
677+
678+ conf .setDnsIPv4 (values ['dns' ], values ['dnsAlt' ])
672679 if values ['networkTimeout' ] != "" :
673680 if int (values ['networkTimeout' ]) >= 0 :
674681 conf .setNetworkTimeout (timedelta (seconds = int (values ['networkTimeout' ]) / 1000 ))
@@ -677,6 +684,8 @@ def flashConfig(self):
677684 if values ['mac' ] != "" :
678685 if check_mac (values ['mac' ]):
679686 conf .setMacAddress (values ['mac' ])
687+ else :
688+ conf .setMacAddress ('00:00:00:00:00:00' )
680689 else :
681690 if values ['usbTimeout' ] != "" :
682691 if int (values ['usbTimeout' ]) >= 0 :
0 commit comments