mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-29 02:21:41 +00:00
integrated ip handler
This commit is contained in:
@@ -193,7 +193,7 @@ class SettingsManager(metaclass=Singleton):
|
||||
self.save_settings()
|
||||
|
||||
# after all values has been set change settings
|
||||
ChangeIP(hostname=self.general_settings['hostname'], ip=self.general_settings['ip'],
|
||||
ChangeIP(connection_type=self.general_settings['connection_type'] ,hostname=self.general_settings['hostname'], ip=self.general_settings['ip'],
|
||||
netmask=self.general_settings['netmask'], gateway=self.general_settings['gateway'])
|
||||
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@ import netifaces
|
||||
|
||||
|
||||
class ChangeIP:
|
||||
def __init__(self, ip_type, ip, netmask, gateway, hostname):
|
||||
def __init__(self, connection_type, ip, netmask, gateway, hostname):
|
||||
|
||||
adapter = self.find_adapter()
|
||||
|
||||
if ip_type == "DHCP":
|
||||
if connection_type == "DHCP":
|
||||
self.change_to_dhcp(adapter=adapter)
|
||||
elif ip_type == "Static":
|
||||
elif connection_type == "Static":
|
||||
self.change_to_static(adapter=adapter, ip=ip, netmask=netmask, gateway=gateway)
|
||||
|
||||
self.change_hostname(hostname=hostname)
|
||||
@@ -17,7 +17,7 @@ class ChangeIP:
|
||||
|
||||
@staticmethod
|
||||
def change_to_dhcp(adapter):
|
||||
subprocess.call(['dhclient -r', adapter])
|
||||
subprocess.call(['dhclient',"-r", adapter])
|
||||
|
||||
@staticmethod
|
||||
def change_to_static(adapter, ip, netmask, gateway):
|
||||
@@ -39,4 +39,4 @@ class ChangeIP:
|
||||
|
||||
@staticmethod
|
||||
def change_hostname(hostname):
|
||||
subprocess.call(['hostnamectl set-hostname', "Chameleon-Vision-{}".format(hostname)])
|
||||
subprocess.call(['hostnamectl', 'set-hostname', "Chameleon-Vision-" + hostname])
|
||||
|
||||
@@ -48,8 +48,8 @@ class ChameleonWebSocket(tornado.websocket.WebSocketHandler):
|
||||
for key in message_dic:
|
||||
self.actions.get(key, self.actions["change_pipeline_values"])(message_dic)
|
||||
print(message)
|
||||
except:
|
||||
print("crash " + message)
|
||||
except Exception as e:
|
||||
print("crash " + e)
|
||||
|
||||
def on_close(self):
|
||||
self.settings_manager.save_settings()
|
||||
|
||||
Reference in New Issue
Block a user