-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
49 lines (37 loc) · 1.52 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
import sys
import subprocess
from tkinter import *
if os.geteuid() == 0:
print("We're root!")
root = Tk()
root.title("Py Proxy Updater")
def changebtn():
file = open(r"/etc/apt/apt.conf", "w+")
data = [f'Acquire::http::proxy "http://{addressvalue.get()}:{portvalue.get()}";\n',f'Acquire::https::proxy "https://{addressvalue.get()}:{portvalue.get()}";\n',f'Acquire::ftp::proxy "ftp://{addressvalue.get()}:{portvalue.get()}";\n',f'Acquire::socks::proxy "socks://{addressvalue.get()}:{portvalue.get()}";\n' ]
file.writelines(data)
print(f'Address : {addressvalue.get()}')
print(f'Port : {portvalue.get()}')
root.destroy()
def resetbtn():
file = open(r"/etc/apt/apt.conf", "w+")
data = ""
file.write(data)
print("Proxy removed successfully")
root.destroy()
## for screen size
root.geometry("300x100")
heading = Label(text="")
user=Label(text="Enter Address :").grid(row=1,column=0)
passwd=Label(text="Enter Port :").grid(row=2)
addressvalue = StringVar()
portvalue = StringVar()
addressentry = Entry(root, textvariable=addressvalue).grid(row=1,column=1)
portentry = Entry(root, textvariable=portvalue).grid(row=2,column=1)
Button(text="Reset",command=resetbtn).grid(row=3, column=0)
Button(text="Change",command=changebtn).grid(row=3, column=1)
root.mainloop()
else:
print("Root access is required.")
subprocess.call(['sudo', 'python3', *sys.argv])
sys.exit()