-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkForPwnedGUI.pyw
90 lines (64 loc) · 2.94 KB
/
checkForPwnedGUI.pyw
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
import wx
import wx.adv
import checkForPwnedShared
import os
class UI(wx.Frame):
def __init__(self, parent, title):
super(UI, self).__init__(parent, title=title)
self.InitUI()
self.Centre()
def InitUI(self):
self.SetInitialSize((385, 300))
self.panel = wx.Panel(self)
self.fileTxt = wx.StaticText(self.panel, -1, "File location:")
self.fileBrowse = wx.FilePickerCtrl(self.panel, -1)
self.nameColTxt = wx.StaticText(self.panel, -1, "Name Col:")
self.nameColCtrl = wx.SpinCtrl(self.panel, -1)
self.pwColTxt = wx.StaticText(self.panel, -1, "Password Col:")
self.pwColCtrl = wx.SpinCtrl(self.panel, -1)
self.headerColTxt = wx.StaticText(self.panel, -1, "Header Col:")
self.headerColYes = wx.RadioButton(
self.panel, -1, label='Yes', style=wx.RB_GROUP)
self.headerColNo = wx.RadioButton(self.panel, -1, label='No')
self.runButton = wx.Button(self.panel, -1, "Run")
self.runButton.Bind(wx.EVT_BUTTON, self.runCheck)
gridSizer = wx.GridSizer(rows=5, cols=3, hgap=10, vgap=10)
radioSizer = wx.BoxSizer(wx.HORIZONTAL)
radioSizer.Add(self.headerColYes, 0, wx.ALL, 5)
radioSizer.Add(self.headerColNo, 0, wx.ALL, 5)
fileSizer = wx.BoxSizer(wx.HORIZONTAL)
nameColSizer = wx.BoxSizer(wx.HORIZONTAL)
pwColSizer = wx.BoxSizer(wx.HORIZONTAL)
headerColSizer = wx.BoxSizer(wx.HORIZONTAL)
gridSizer.Add(self.fileTxt, 0, wx.ALL, 10)
gridSizer.Add(self.fileBrowse, 1, wx.ALL | wx.ALIGN_LEFT, 10)
gridSizer.Add((1, -1), proportion=1)
gridSizer.Add(self.nameColTxt, 0, wx.ALL, 10)
gridSizer.Add(self.nameColCtrl, 0, wx.ALL | wx.ALIGN_LEFT, 10)
gridSizer.Add((1, -1), proportion=1)
gridSizer.Add(self.pwColTxt, 0, wx.ALL, 10)
gridSizer.Add(self.pwColCtrl, 0, wx.ALL | wx.ALIGN_LEFT, 10)
gridSizer.Add((1, -1), proportion=1)
gridSizer.Add(self.headerColTxt, 0, wx.ALL, 10)
gridSizer.Add(radioSizer, 0, wx.ALL | wx.ALIGN_LEFT, 10)
gridSizer.Add((1, -1), proportion=1)
gridSizer.Add((1, -1), proportion=1)
gridSizer.Add((1, -1), proportion=1)
gridSizer.Add(self.runButton, 0, wx.ALL, 10)
self.panel.SetSizerAndFit(gridSizer)
def runCheck(self, event):
try:
if not os.path.isfile(self.fileBrowse.GetPath()):
raise ValueError('Invalid file path. Please try again.')
resp = checkForPwnedShared.checkCSV(self.fileBrowse.GetPath(
), self.nameColCtrl.GetValue(), self.pwColCtrl.GetValue(), self.headerColYes.GetValue())
wx.MessageBox(resp, 'Pwned Results', wx.OK)
except ValueError as e:
wx.MessageBox(str(e), 'Pwned Results', wx.OK)
def main():
app = wx.App()
ex = UI(None, title='Check for Pwned')
ex.Show()
app.MainLoop()
if __name__ == '__main__':
main()