Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import subprocess
- from tkinter import *
- ##This application is written by Umut Can Alaçam, you can change and improve it then you can share it!
- user = os.getuid();
- if user != 0:
- print("You have to run this application as root! Try 'sudo su' command.");
- exit();
- fo = open("cache.abs", mode="r+")
- fo.seek(0, 0)
- cache = fo.read().splitlines()
- fo.close()
- netlist = os.listdir('/sys/class/net/')
- print(cache)
- # pencere
- pencere = Tk();
- pencere.title("Create AP GUI")
- net1 = StringVar()
- net1.set(netlist[0])
- net2 = StringVar()
- net2.set(netlist[0])
- pencere.columnconfigure(2, weight=1)
- pencere.rowconfigure(4, weight=1)
- def savechanges():
- global fo
- fo = open("cache.abs", mode="w")
- try:
- fo.write(entryssid.get()+"\n"+entrypass.get())
- print("Cache file updated!")
- except:
- print("ERROR: Couldn't write cache file!")
- pass;
- def starthotspot():
- command = "sudo create_ap " + net1.get() + ' ' + net2.get() + " " + entryssid.get() + " " + entrypass.get();
- print("Process started...\n\n");
- savechanges();
- subprocess.call(command, shell=True);
- pencere.update();
- labelfrom = Label(text="Source:", width="20", padx=10, pady=10);
- listfrom = OptionMenu(pencere, net1, *netlist);
- listto = OptionMenu(pencere, net2, *netlist);
- listfrom.config(width=15);
- listto.config(width=15);
- labelstatus = Label(text="Hotspot is not working", padx=10, pady=10);
- labelto = Label(text="Share via:", padx=10, pady=10);
- entryssidlabel = Label(text="SSID:", padx=10, pady=10);
- entrypasslabel = Label(text="Password:", padx=10, pady=10);
- entrypass = Entry();
- entryssid = Entry();
- buttonstart = Button(text="Start", command=starthotspot);
- buttonstart.config(width=25)
- # GRID
- labelfrom.grid(row=0, column=0)
- listfrom.grid(row=0, column=1)
- labelto.grid(row=1, column=0)
- listto.grid(row=1, column=1)
- entryssidlabel.grid(row=2, column=0, ipady=5)
- entrypasslabel.grid(row=3, column=0, ipady=5)
- entrypass.grid(row=3, column=1)
- entryssid.grid(row=2, column=1)
- buttonstart.grid(row=4, columnspan=3)
- # INSERT
- try:
- entryssid.insert(0, cache[0])
- entrypass.insert(0, cache[1])
- except:
- print("Cannot read cache!")
- mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement