some bug fixes

This commit is contained in:
ori agranat
2019-08-20 23:10:43 +03:00
parent d23150dff9
commit fa49aabf74
3 changed files with 11 additions and 5 deletions

View File

@@ -51,6 +51,9 @@ class SettingsManager(metaclass=Singleton):
self.settings_path = os.path.join(os.getcwd(), "settings")
self.cams_path = os.path.join(self.settings_path, "cams")
self._init_general_settings()
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'])
self._init_cameras_info()
self._init_usb_cameras()
self._init_cameras()

View File

@@ -6,6 +6,7 @@ class ChangeIP:
def __init__(self, connection_type, ip, netmask, gateway, hostname):
adapter = self.find_adapter()
self.shutdown_adapter(adapter)
if connection_type == "DHCP":
self.change_to_dhcp(adapter=adapter)
@@ -13,7 +14,7 @@ class ChangeIP:
self.change_to_static(adapter=adapter, ip=ip, netmask=netmask, gateway=gateway)
self.change_hostname(hostname=hostname)
self.restart_adapter(adapter=adapter)
self.start_adapter(adapter)
@staticmethod
def change_to_dhcp(adapter):
@@ -22,11 +23,13 @@ class ChangeIP:
@staticmethod
def change_to_static(adapter, ip, netmask, gateway):
subprocess.call(['ifconfig', adapter, ip, 'netmask', netmask])
subprocess.call(['route add default gw', gateway, adapter])
subprocess.call(['route', 'add', 'default', 'gw', gateway, adapter])
@staticmethod
def restart_adapter(adapter):
def shutdown_adapter(adapter):
subprocess.call(['ifconfig', adapter, 'down'])
@staticmethod
def start_adapter(adapter):
subprocess.call(['ifconfig', adapter, 'up'])
@staticmethod
@@ -39,4 +42,4 @@ class ChangeIP:
@staticmethod
def change_hostname(hostname):
subprocess.call(['hostnamectl set-hostname', hostname])
subprocess.call(['hostnamectl', 'set-hostname', hostname])

View File

@@ -37,7 +37,7 @@ export const store = new Vuex.Store({
team_number:0,
connection_type:"DHCP",
ip:"",
gateWay:"",
gateway:"",
netmask:"",
hostname:"",
//live info