Updater: Cleaning

This commit is contained in:
Mathieu Maret 2016-09-21 23:31:14 +02:00
parent b43feb922d
commit ed0364eb7a

21
Updater.py Normal file → Executable file
View File

@ -1,6 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
from tkinter import * from tkinter import *
from tkinter import filedialog from tkinter import filedialog
from tkinter.messagebox import *
import subprocess import subprocess
file = None file = None
@ -9,18 +11,19 @@ def Install():
ip = e.get() ip = e.get()
print ("Installing ",file) print ("Installing ",file)
print ("At ip ", ip) print ("At ip ", ip)
if file != None: if file != None:
subprocess.call(["python", "espota.py", "-i", ip, "-f", file]) subprocess.call(["python", "espota.py", "-i", ip, "-f", file])
else:
showerror("Error", "Select a firmware first")
def askopenfile(): def askopenfile():
global file global file
filename = filedialog.askopenfile(mode='r', filetypes=[('binaries', '*.bin')]) file = filedialog.askopenfilename(title='Select Firmware', filetypes=[('binaries', '*.bin')])
file = filename.name
root = Tk()
root = Tk() root.title("Firmware Updater")
Ip = Text(root)
button_opt = {'fill': constants.BOTH, 'padx': 5, 'pady': 5} button_opt = {'fill': constants.BOTH, 'padx': 5, 'pady': 5}
Button(root, text='Select firmware', command=askopenfile).pack(**button_opt) Button(root, text='Select firmware', command=askopenfile).pack(**button_opt)
@ -30,8 +33,6 @@ e.pack()
e.delete(0, END) e.delete(0, END)
e.insert(0, "192.168.0.XX") e.insert(0, "192.168.0.XX")
buttonInstall = Button(root, text = 'Install', command = Install) Button(root, text = 'Install', command = Install).pack(pady=20)
buttonInstall.pack(pady=20, padx = 20)
root.mainloop()
root.mainloop()