-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbcc_main.py
100 lines (70 loc) · 2.65 KB
/
bcc_main.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
import os
import keychain
import dataparsing
import serialgao
import sha256frompubkey
from console import *
user = "henrytwo"
locked = True
primed = False
log_event = False
def authorized():
global primed, log_event
if primed:
Console.clear()
else:
primed = True
keychain.load_key()
state = keychain.check_key(log_event)
log_event = primed
if not state:
Console.print(
'\nAccess denied! This key has been revoked.\nContact the owner securely over keybase for further instructions. (@%s)' % user,
Colors.RED_BOLD)
return state
def main():
global locked
andrew = serialgao.Andrewino('/dev/ttyACM0')
#locked = andrew.status()
Console.clear()
MenuFormatter.splash()
key = authorized()
if key:
while True:
Console.print('\nSystem State: %s' % ('LOCKED' if locked else 'UNLOCKED'), Colors.WHITE)
choice = MenuFormatter.option_list(['Lock' if not locked else 'Unlock',
'View Log',
'Clear Log',
'Train',
'Exit'])
if choice == 1 and authorized():
state = Prompts.yn_prompt(
'Are you sure you want to %s the chain?' % ('LOCK' if not locked else 'UNLOCK'), 'n')
if state == 'y':
if andrew.status():
andrew.unlock(sha256frompubkey.sha256_fingerprint_from_pub_key(key[0][0]))
else:
andrew.lock(sha256frompubkey.sha256_fingerprint_from_pub_key(key[0][0]))
Console.print('Chain has been %s' % 'LOCKED' if not locked else 'UNLOCKED', Colors.PURPLE_BOLD_BRIGHT)
Prompts.cn_prompt()
locked = andrew.status()
elif choice == 2 and authorized():
dataparsing.print_log()
Prompts.cn_prompt()
elif choice == 3 and authorized():
state = Prompts.yn_prompt('Are you sure you want to clear system logs?', 'n')
if state == 'y':
dataparsing.clear_log()
Console.clear()
Console.print('Logs cleared!', Colors.GREEN_BOLD_BRIGHT)
Prompts.cn_prompt()
elif choice == 4:
os.system('sl')
elif choice == 5:
Console.print('Goodbye.', Colors.BLUE_BOLD)
break
else:
break
if __name__ == '__main__':
main()
# hello