Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "security" : "WEP",
- "SSID" : "Pilve4Welcome",
- "password" : "RetFlat4"
- }
- {
- "OPEN" : "auto lo\n\niface lo inet loopback\niface eth0 inet dhcp\n\nallow-hotplug wlan0\nauto wlan0\niface wlan0 inet dhcp\n\twireless-essid NAME\n\twireless-mode managed",
- "WPA" : "auto lo\n\niface lo inet loopback\niface eth0 inet dhcp\n\nallow-hotplug wlan0\nauto wlan0\niface wlan0 inet dhcp\n\twpa-ssid \"NAME\"\n\twpa-psk \"PASSWORD\"",
- "WPA_STATIC_IP" : "auto lo\n\niface lo inet loopback\niface eth0 inet dhcp\n\nallow-hotplug wlan0\nauto wlan0\n\twpa-ssid \"NAME\"\n\twpa-psk \"PASSWORD\"\naddress IP\nnetmask NETMASK\ngateway GATEWAY",
- "WEP" : "auto lo\n\niface lo inet loopback\niface eth0 inet dhcp\n\nallow-hotplug wlan0\nauto wlan0\niface wlan0 inet dhcp\n\twireless-essid NAME\n\twireless-key PASSWORD"
- }
- import json
- class NetworkInterfaceChanger:
- def __init__():
- pass
- def loadInterfaceScripts():
- pass
- def change(type, name, psw):
- file = "NetworkInterfaceScripts.json"
- f = open("/etc/network/interfaces", "w")
- with open(file) as configFile:
- try:
- data = json.load(configFile)
- except ValueError:
- print('wrong JSON')
- text = data[type]
- text = text.replace("NAME", name)
- text = text.replace("PASSWORD", psw)
- f.write(text)
- f.close()
- with open("Configuration/NetworkConfig.json") as cfgFile:
- param = json.load(cfgFile)
- change(param["security"], param["SSID"], param["password"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement