-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkForPwnedCmd.py
84 lines (78 loc) · 2.46 KB
/
checkForPwnedCmd.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
import checkForPwnedShared
import tkinter as tk
from tkinter import filedialog
import os
import sys
import time
def inputWithInterrupt(msg):
try:
return input(msg)
except KeyboardInterrupt:
print('Process interrupted by user.')
raise SystemExit
while True:
try:
while True:
try:
fileName = inputWithInterrupt(
'File location (enter "browse" to open file dialog):\n')
if fileName == 'browse':
root = tk.Tk()
root.withdraw()
fileName = filedialog.askopenfilename()
print(fileName)
root.destroy()
if not os.path.isfile(fileName):
raise ValueError('Not a real file.')
except ValueError:
print('Invalid file path. Please try again.')
print('')
continue
break
print('')
while True:
try:
accountCol = int(input('Account name col: '))
if accountCol < 0:
raise ValueError('Value must be positive.')
except ValueError:
print('Invalid number. Please try again.')
print('')
continue
break
print('')
while True:
try:
pwCol = int(input('Password col: '))
if accountCol < 0:
raise ValueError('Value must be positive.')
except ValueError:
print('Invalid number. Please try again.')
print('')
continue
break
print('')
while True:
try:
headerRow = input('Header row (y/n): ')
if headerRow == 'y':
headerRow = True
elif headerRow == 'n':
headerRow = False
else:
raise ValueError('Invalid input entered.')
except ValueError:
print('Value must be "y" or "n". Please try again.')
print('')
continue
break
print('')
print(checkForPwnedShared.checkCSV(
fileName, accountCol, pwCol, headerRow))
print('')
input('Press ENTER to exit...')
except ValueError as e:
print(str(e) + ' Please try again.')
print('')
continue
break