Advertisement
Guest User

Untitled

a guest
Aug 26th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. import os
  2. import subprocess
  3. from tkinter import *
  4.  
  5. ##This application is written by Umut Can Alaçam, you can change and improve it then you can share it!
  6.  
  7.  
  8. user = os.getuid();
  9. if user != 0:
  10. print("You have to run this application as root! Try 'sudo su' command.");
  11. exit();
  12.  
  13. fo = open("cache.abs", mode="r+")
  14. fo.seek(0, 0)
  15. cache = fo.read().splitlines()
  16. fo.close()
  17. netlist = os.listdir('/sys/class/net/')
  18. print(cache)
  19.  
  20. # pencere
  21. pencere = Tk();
  22. pencere.title("Create AP GUI")
  23. net1 = StringVar()
  24. net1.set(netlist[0])
  25. net2 = StringVar()
  26. net2.set(netlist[0])
  27. pencere.columnconfigure(2, weight=1)
  28. pencere.rowconfigure(4, weight=1)
  29.  
  30.  
  31. def savechanges():
  32. global fo
  33. fo = open("cache.abs", mode="w")
  34.  
  35. try:
  36. fo.write(entryssid.get()+"\n"+entrypass.get())
  37. print("Cache file updated!")
  38. except:
  39. print("ERROR: Couldn't write cache file!")
  40. pass;
  41.  
  42.  
  43. def starthotspot():
  44. command = "sudo create_ap " + net1.get() + ' ' + net2.get() + " " + entryssid.get() + " " + entrypass.get();
  45. print("Process started...\n\n");
  46. savechanges();
  47. subprocess.call(command, shell=True);
  48. pencere.update();
  49.  
  50.  
  51. labelfrom = Label(text="Source:", width="20", padx=10, pady=10);
  52. listfrom = OptionMenu(pencere, net1, *netlist);
  53. listto = OptionMenu(pencere, net2, *netlist);
  54. listfrom.config(width=15);
  55. listto.config(width=15);
  56. labelstatus = Label(text="Hotspot is not working", padx=10, pady=10);
  57. labelto = Label(text="Share via:", padx=10, pady=10);
  58. entryssidlabel = Label(text="SSID:", padx=10, pady=10);
  59. entrypasslabel = Label(text="Password:", padx=10, pady=10);
  60. entrypass = Entry();
  61. entryssid = Entry();
  62. buttonstart = Button(text="Start", command=starthotspot);
  63. buttonstart.config(width=25)
  64.  
  65. # GRID
  66.  
  67. labelfrom.grid(row=0, column=0)
  68. listfrom.grid(row=0, column=1)
  69. labelto.grid(row=1, column=0)
  70. listto.grid(row=1, column=1)
  71. entryssidlabel.grid(row=2, column=0, ipady=5)
  72. entrypasslabel.grid(row=3, column=0, ipady=5)
  73. entrypass.grid(row=3, column=1)
  74. entryssid.grid(row=2, column=1)
  75. buttonstart.grid(row=4, columnspan=3)
  76.  
  77. # INSERT
  78. try:
  79. entryssid.insert(0, cache[0])
  80. entrypass.insert(0, cache[1])
  81. except:
  82. print("Cannot read cache!")
  83. mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement