forked from Qyriad/rocontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
75 lines (55 loc) · 2.63 KB
/
Copy pathapp.py
File metadata and controls
75 lines (55 loc) · 2.63 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
from tkinter import *
from tkinter import messagebox, filedialog
import os, sys
import subprocess
fuseeLauncherDir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "fusee-launcher/") # build path for fusee-launcher dir
fuseeFilePath = os.path.join(fuseeLauncherDir, "fusee-launcher.py") # build path for fusee-launcher file
top = Tk()
top.title("Interface de Fusée")
titleLabel = Label(top, text="Interface de Fusée")
titleLabel.pack()
# fusee error/result code explainer messages
fuseeCodeMessages = ["Done!", "It seems like your Switch isn't plugged in.", "No access to USB. (you should probably re-run the interface script with sudo or Administrator privileges)", "It seems like your Switch isn't on an XHCI backend. Try plugging it in into a USB 3.0 (blue) port.", "Unknown Fusée Gelée error. (try running it on it's own and see what's up)"]
def fusee_exec(payload):
"""
Executes fusée gelée from a payload file path.
Arguments:
* payload - Payload path
Returns: return code
* 0: A-OK
* 1: Your Switch isn't plugged in.
* 2: No access to USB. (re-run w/ sudo, probably)
* 3: The Switch isn't plugged into an XHCI backend.
* 4: Unknown Fusée Gelée error.
"""
result = 0 # default result
p = subprocess.Popen([sys.executable, fuseeFilePath, payload, '--relocator', os.path.join(fuseeLauncherDir, 'intermezzo.bin')], stdout=subprocess.PIPE, stderr=subprocess.PIPE) # run fusée gelée
p.wait() # wait for it to close
output = p.stdout.read().decode("utf-8")
errout = p.stderr.read().decode("utf-8")
print(output)
print(errout)
if output.lower().startswith("no") and p.returncode == 255: # No TegraRCM device found?
result = 1
elif "errno 13" in errout.lower() and p.returncode == 1: # Errno 13: Access Denied (for USB)
result = 2
elif "This device needs to be on an XHCI backend." in output and p.returncode == 0:
result = 3
elif p.returncode != 0:
result = 4
return result
def launch_callback():
payloadpath = filedialog.askopenfilename(title = "Select payload file", filetypes = [("Payload files", "*.bin")])
if len(payloadpath) == 0:
messagebox.showerror("Interface de Fusée", "Please select a file.")
return
res = fusee_exec(payloadpath)
if res == 0:
messagebox.showinfo("Interface de Fusée", fuseeCodeMessages[res])
else:
messagebox.showerror("Interface de Fusée", fuseeCodeMessages[res])
launchButton = Button(top, text="Launch", command=launch_callback)
launchButton.pack()
if __name__ == "__main__":
top.mainloop()