-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommands.py
More file actions
55 lines (42 loc) · 1.58 KB
/
commands.py
File metadata and controls
55 lines (42 loc) · 1.58 KB
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
import secrets
from pprint import pprint
import cv2
from redis.commands.json.path import Path
from tqdm import tqdm
import helper
from constants import *
def test():
visual = True
with_markers = True
image_name = SHEET_TEST
image = cv2.imread(image_name)
sheet = helper.SheetNormalizer(image, visual=visual)
frame, frame_tresh = sheet.get_adaptive_thresh()
detctor = helper.BubbleReader(frame, frame_tresh, with_markers=with_markers, visual=visual)
keypoints, keypoints_filled, keypoints_empty = detctor.detect_answers()
choices = detctor.extract_choices(keypoints, keypoints_filled, keypoints_empty)
sheet_with_choices = detctor.get_sheet_with_choices()
print(choices)
print()
print(f'{len(choices)} questions')
print()
print(f'{len(sheet_with_choices)} px')
def token():
print(secrets.token_urlsafe(32))
def set():
data = {
"endpoint": input('please enter an endpoint like "nodes.alaatv.com":'),
"bucket": input('please enter your desired bucket like "pictures":'),
"accessKey": input('please enter accessKey:'),
"secretKey": input('please enter secretKey:'),
}
token = secrets.token_urlsafe(32)
client = helper.establish_redis()
client.json().set(f'bubblesheet:token:{token}', Path.rootPath(), data)
print(f'your token is "{token}" keep this it safe.')
def dump():
client = helper.establish_redis()
for key in client.scan_iter("bubblesheet:token:*"):
user = client.json().get(key, Path.rootPath())
user['token'] = str(key.decode('utf8'))
pprint(user)