Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////network_info.py
- import subprocess
- import json
- import re
- iwconfig = subprocess.Popen(('iwconfig'), stdout=subprocess.PIPE)
- ssid = subprocess.check_output(('grep', 'wlan0'), stdin=iwconfig.stdout)
- ssid = ssid.decode("utf8")
- ssid = ssid.split(":")[1]
- ssid = re.sub('\s+','',ssid)
- if '"' in ssid:
- ssid = ssid.replace('"', '')
- else:
- ssid = None
- with open('/sys/class/net/eth0/carrier', 'r') as myfile:
- ethernet=myfile.read().replace('\n', '')
- if (ethernet == "1"):
- ethernet = "Tilkoblet"
- else:
- ethernet = "Frakoblet"
- data = {}
- data['ssid'] = ssid
- data['ethernet'] = ethernet
- json_data = json.dumps(data)
- print (json_data)
- ////reboot.py
- import os
- print ("Rebooting")
- os.system('sudo shutdown -r now')
- ///////////edit_file.py
- import sys
- import fileinput
- info = sys.argv[1]
- info = info.split(";")
- ##fil = info[0]
- ##finnlinje = info[1]
- ##nylinje = info[2]
- def editFile(fil, finnlinje, nylinje):
- text = finnlinje
- new_text = nylinje
- x = fileinput.input(files=fil, inplace=1)
- for line in x:
- if text in line:
- line = new_text
- sys.stdout.write(line),
- x.close()
- editFile(fil, finnlinje, nylinje)
- print(info)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement