This repository has been archived by the owner on Aug 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathclient_gui.py
123 lines (86 loc) · 4.52 KB
/
client_gui.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
# Copyright Notice:
# Copyright 2016-2019 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/Redfish-Service-Conformance-Check/blob/main/LICENSE.md
from tkinter import *
from PIL import ImageTk, Image
import tkinter as tk
import tkinter.messagebox as tm
import os
import json
class LoginFrame(Frame):
def __init__(self, root):
super().__init__(root)
self.label_1 = Label(self, text="Display Name")
self.label_2 = Label(self, text="DnsName")
self.label_3 = Label(self, text="LoginName")
self.label_4 = Label(self, text="Password")
self.entry_1 = Entry(self)
self.entry_2 = Entry(self)
self.entry_3 = Entry(self)
self.entry_4 = Entry(self, show="*")
self.label_1.grid(row=0, sticky=E)
self.label_2.grid(row=1, sticky=E)
self.entry_1.grid(row=0, column=1)
self.entry_2.grid(row=1, column=1)
self.label_3.grid(row=2, sticky=E)
self.label_4.grid(row=3, sticky=E)
self.entry_3.grid(row=2, column=1)
self.entry_4.grid(row=3, column=1)
self.submitbtn = Button(self, text="Submit", command = self._submit_btn_clicked)
self.submitbtn.grid(columnspan=2)
self.pack()
def _submit_btn_clicked(self):
#print("Clicked")
displayName = self.entry_1.get()
dnsName = self.entry_2.get()
loginName = self.entry_3.get()
password = self.entry_4.get()
#item = {'DisplayName': displayName, 'DnsName': dnsName, 'LoginName':loginName, 'Password':password}
config = json.loads(open('properties.json').read())
config["RedfishServiceCheckTool_SUTConfiguration"]["SUTs"][0]["DisplayName"] = displayName
config["RedfishServiceCheckTool_SUTConfiguration"]["SUTs"][0]["DnsName"] = dnsName
config["RedfishServiceCheckTool_SUTConfiguration"]["SUTs"][0]["LoginName"] = loginName
config["RedfishServiceCheckTool_SUTConfiguration"]["SUTs"][0]["Password"] = password
with open('properties.json','w') as f:
f.write(json.dumps(config))
with open('properties.json', 'r') as f:
config = json.load(f)
config["RedfishServiceCheckTool_SUTConfiguration"]["SUTs"][0]["DisplayName"] = displayName
config["RedfishServiceCheckTool_SUTConfiguration"]["SUTs"][0]["DnsName"] = dnsName
config["RedfishServiceCheckTool_SUTConfiguration"]["SUTs"][0]["LoginName"] = loginName
config["RedfishServiceCheckTool_SUTConfiguration"]["SUTs"][0]["Password"] = password
with open('properties.json','w') as f:
json.dump(config, f)
t = tk.Toplevel(self)
a = tk.Label(t, text = "WELCOME " + displayName)
l = tk.Button(t, text = "Run Conformance Test", command = self._run_btn_clicked)
m = tk.Button(t, text = "Clear Entries", command = self._clear_btn_clicked)
a.pack(side="top", fill="both", expand=True, padx=100, pady=100)
l.pack()
m.pack(side = "bottom", padx=50, pady=50)
def _run_btn_clicked(self):
os.system('python3.4 rf_client.py')
def _clear_btn_clicked(self):
config = json.loads(open('properties.json').read())
config["RedfishServiceCheckTool_SUTConfiguration"]["SUTs"][0]["DisplayName"] = ""
config["RedfishServiceCheckTool_SUTConfiguration"]["SUTs"][0]["DnsName"] = ""
config["RedfishServiceCheckTool_SUTConfiguration"]["SUTs"][0]["LoginName"] = ""
config["RedfishServiceCheckTool_SUTConfiguration"]["SUTs"][0]["Password"] = ""
with open('properties.json','w') as f:
f.write(json.dumps(config))
with open('properties.json', 'r') as f:
config = json.load(f)
config["RedfishServiceCheckTool_SUTConfiguration"]["SUTs"][0]["DisplayName"] = ""
config["RedfishServiceCheckTool_SUTConfiguration"]["SUTs"][0]["DnsName"] = ""
config["RedfishServiceCheckTool_SUTConfiguration"]["SUTs"][0]["LoginName"] = ""
config["RedfishServiceCheckTool_SUTConfiguration"]["SUTs"][0]["Password"] = ""
with open('properties.json','w') as f:
json.dump(config, f)
root = Tk()
lf = LoginFrame(root)
root.title("Redfish Conformance Test Tool")
path = os.getcwd()+ '/image.jpg'
img = ImageTk.PhotoImage(Image.open(path))
panel = tk.Label(root, image = img)
panel.pack(side = "bottom", fill = "both", expand = "yes")
root.mainloop()