Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. {
  2. "security" : "WEP",
  3. "SSID" : "Pilve4Welcome",
  4. "password" : "RetFlat4"
  5. }
  6.  
  7. {
  8. "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",
  9. "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\"",
  10. "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",
  11. "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"
  12. }
  13.  
  14. import json
  15.  
  16. class NetworkInterfaceChanger:
  17. def __init__():
  18. pass
  19.  
  20.  
  21. def loadInterfaceScripts():
  22. pass
  23.  
  24.  
  25. def change(type, name, psw):
  26.  
  27. file = "NetworkInterfaceScripts.json"
  28. f = open("/etc/network/interfaces", "w")
  29.  
  30. with open(file) as configFile:
  31. try:
  32. data = json.load(configFile)
  33. except ValueError:
  34. print('wrong JSON')
  35.  
  36.  
  37. text = data[type]
  38. text = text.replace("NAME", name)
  39. text = text.replace("PASSWORD", psw)
  40.  
  41. f.write(text)
  42. f.close()
  43.  
  44. with open("Configuration/NetworkConfig.json") as cfgFile:
  45. param = json.load(cfgFile)
  46. change(param["security"], param["SSID"], param["password"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement