-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolstice_Commands.py
274 lines (193 loc) · 8.42 KB
/
Solstice_Commands.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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
from __future__ import print_function
import pyautogui
from tkinter import *
from tkinter import ttk
import sys
from sys import version
import time
import datetime
import requests
import pdb
import itertools
import webbrowser
#Function to get screen key and pod name and keep them in variables
#Function also opens a web browser with the IP address
def get_pod_info(*args):
try:
#get IP address from user
value = ip_address.get()
#set password for pod - comment out if there is no password
admin_password = '*PASSWORD!'
#URL to get config info from pod
myconfigurl = 'http://'+value+'/api/config?password='+admin_password
#json headers
headers = {'content-type': 'application/json'}
#GET from pod
rc = requests.get(myconfigurl, headers = headers)
#parse json to lib
rconfig = rc.json()
#parse screen code from lib
screen_code.set(int(rconfig.get('m_authenticationCuration',{}).get('sessionKey')))
#parse pod name from lib
podname.set(rconfig.get('m_displayInformation',{}).get('m_displayName'))
except ValueError:
pass
def connect_to_pod(*args):
try:
#get IP address from user
value = ip_address.get()
#produce pod http link from user IP address
pod_screen_code_link = 'https://'+value+':6443'
#open web browser with url for pod
webbrowser.get('windows-default').open(pod_screen_code_link)
except ValueError:
pass
def pod_look_in(*args):
try:
#get IP address from user
value = ip_address.get()
admin_password = '*PASSWORD!'
#URL to get config info from pod
myconfigurl = 'http://'+value+'/api/config?password='+admin_password
#json headers
headers = {'content-type': 'application/json'}
#GET from pod
rc = requests.get(myconfigurl, headers = headers)
#parse json to lib
rconfig = rc.json()
#parse screen code from lib
screen_code.set(int(rconfig.get('m_authenticationCuration',{}).get('sessionKey')))
#produce pod http link from user IP address
pod_lookin_link = 'http://'+value+'/Look-in'
# ?Key='+screen_code.get()
#open web browser with url for pod
webbrowser.get('windows-default').open(pod_lookin_link)
except ValueError:
pass
def pod_reboot(*args):
try:
#get IP address from user
value = ip_address.get()
admin_password = '*PASSWORD!'
#produce pod http link from user IP address
pod_reboot_link = 'http://'+value+'/api/control/reboot?password='+admin_password
#open web browser with url for pod
webbrowser.get('windows-default').open(pod_reboot_link)
time.sleep(5)
pyautogui.hotkey('ctrl', 'w')
except ValueError:
pass
def pod_boot_users(*args):
try:
#get IP address from user
value = ip_address.get()
admin_password = '*PASSWORD!'
#produce pod http link from user IP address
pod_boot_users_link = 'http://'+value+'/api/control/boot?password='+admin_password
#open web browser with url for pod
webbrowser.get('windows-default').open(pod_boot_users_link)
time.sleep(5)
pyautogui.hotkey('ctrl', 'w')
except ValueError:
pass
def pod_clear(*args):
try:
#get IP address from user
value = ip_address.get()
admin_password = '*PASSWORD!'
#produce pod http link from user IP address
pod_clear_link = 'http://'+value+'/api/control/clear?password='+admin_password
#open web browser with url for pod
webbrowser.get('windows-default').open(pod_clear_link)
time.sleep(5)
pyautogui.hotkey('ctrl', 'w')
except ValueError:
pass
def pod_restart(*args):
try:
#get IP address from user
value = ip_address.get()
admin_password = '*PASSWORD!'
#produce pod http link from user IP address
pod_restart_link = 'http://'+value+'/api/control/restart?password='+admin_password
#open web browser with url for pod
webbrowser.get('windows-default').open(pod_restart_link)
time.sleep(5)
pyautogui.hotkey('ctrl', 'w')
except ValueError:
pass
def get_logs(*args):
try:
#get IP address from user
value = ip_address.get()
admin_password = '*PASSWORD!'
#produce pod http link from user IP address
pod_logs = 'http://'+value+'/diag/logs.zip?password='+admin_password
#open web browser with url for pod
webbrowser.get('windows-default').open(pod_logs)
time.sleep(5)
pyautogui.hotkey('ctrl', 'w')
except ValueError:
pass
def set_edid_1080p(*args):
try:
#get IP address from user
value = ip_address.get()
admin_password = '*PASSWORD!'
#produce pod http link from user IP address
pod_edid_1080p = 'http://'+value+'/diag/displaymode?mode=16?password='+admin_password
#open web browser with url for pod
webbrowser.get('windows-default').open(pod_edid_1080p)
time.sleep(5)
pyautogui.hotkey('ctrl', 'w')
except ValueError:
pass
def pod_key_reset(*args):
try:
#get IP address from user
value = ip_address.get()
admin_password = '*PASSWORD!'
#produce pod http link from user IP address
pod_key_reset_link = 'http://'+value+'/api/control/resetkey?password='+admin_password
#open web browser with url for pod
webbrowser.get('windows-default').open(pod_key_reset_link)
time.sleep(5)
pyautogui.hotkey('ctrl', 'w')
except ValueError:
pass
root = Tk()
root.title("Solstice Pod Info and Commands")
mainframe = ttk.Frame(root, padding="20 20 20 20")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
ip_address = StringVar()
ip_address_entry = ttk.Entry(mainframe, width=15, textvariable=ip_address)
ip_address_entry.grid(column=2, row=1, sticky=(W, E))
ttk.Button(mainframe, text="Get Pod Info", command=get_pod_info).grid(column=3, row=1, sticky=W)
ttk.Button(mainframe, text="Connect to Pod", command=connect_to_pod).grid(column=4, row=1, sticky=W)
ttk.Button(mainframe, text="Browser Look In", command=pod_look_in).grid(column=5, row=1, sticky=W)
ttk.Label(mainframe, text="Pod Commands:").grid(column=4, row=2, sticky=W)
ttk.Button(mainframe, text="Reboot Pod", command=pod_reboot).grid(column=4, row=3, sticky=W)
ttk.Button(mainframe, text="Clear All Posts", command=pod_clear).grid(column=4, row=4, sticky=W)
ttk.Button(mainframe, text="Reset Screen Key", command=pod_key_reset).grid(column=4, row=5, sticky=W)
ttk.Button(mainframe, text="Software Restart", command=pod_restart).grid(column=5, row=4, sticky=W)
ttk.Button(mainframe, text="Boot All Users", command=pod_boot_users).grid(column=5, row=3, sticky=W)
ttk.Button(mainframe, text="Get Pod Logs", command=get_logs).grid(column=4, row=6, sticky=W)
ttk.Button(mainframe, text="Set Pod EDID to 1080p", command=set_edid_1080p).grid(column=5, row=5, sticky=W)
podname = StringVar()
ttk.Label(mainframe, textvariable=podname).grid(column=2, row=2, sticky=(W, E))
screen_code = StringVar()
ttk.Label(mainframe, textvariable=screen_code).grid(column=2, row=3, sticky=(W, E))
screen_code_string = str(screen_code)
ttk.Label(mainframe, text="Enter the pod's IP address:").grid(column=1, row=1, sticky=W)
ttk.Label(mainframe, text="The Pod name is:").grid(column=1, row=2, sticky=W)
ttk.Label(mainframe, text="The Screen Code is:").grid(column=1, row=3, sticky=W)
ttk.Label(mainframe, text="If a three digit number is returned,\nadd a 0 to the front of the code").grid(column=2, row=4, sticky=W)
ttk.Label(mainframe, text="All Pod Commands will open a new\ntab in your default web browser").grid(column=2, row=5, sticky=W)
ttk.Label(mainframe, text="When the tab opens, please wait until you\nsee the tab close itself before you continue").grid(column=2, row=6, sticky=W)
for child in mainframe.winfo_children():
child.grid_configure(padx=5, pady=5)
ip_address_entry.focus()
root.bind("<Return>", get_pod_info)
root.mainloop()