Domotique/Updater.py

39 lines
823 B
Python
Raw Normal View History

2016-09-21 18:44:41 +02:00
#!/usr/bin/env python
from tkinter import *
from tkinter import filedialog
2016-09-21 23:31:14 +02:00
from tkinter.messagebox import *
2016-09-21 18:44:41 +02:00
import subprocess
file = None
def Install():
ip = e.get()
print ("Installing ",file)
print ("At ip ", ip)
2016-09-21 23:31:14 +02:00
2016-09-21 18:44:41 +02:00
if file != None:
subprocess.call(["python", "espota.py", "-i", ip, "-f", file])
2016-09-21 23:31:14 +02:00
else:
showerror("Error", "Select a firmware first")
2016-09-21 18:44:41 +02:00
def askopenfile():
global file
2016-09-21 23:31:14 +02:00
file = filedialog.askopenfilename(title='Select Firmware', filetypes=[('binaries', '*.bin')])
root = Tk()
root.title("Firmware Updater")
2016-09-21 18:44:41 +02:00
button_opt = {'fill': constants.BOTH, 'padx': 5, 'pady': 5}
Button(root, text='Select firmware', command=askopenfile).pack(**button_opt)
e = Entry(root)
e.pack()
e.delete(0, END)
e.insert(0, "192.168.0.XX")
2016-09-21 23:31:14 +02:00
Button(root, text = 'Install', command = Install).pack(pady=20)
2016-09-21 18:44:41 +02:00
2016-09-21 23:31:14 +02:00
root.mainloop()