-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathtest.py
77 lines (61 loc) · 2.17 KB
/
test.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
import utils
import os
from PIL import Image
from multiprocessing import Process, Queue, Pool
import wda
import baiduocr
# 测试代码
def test_shot(is_ios):
size = utils.check_os(is_ios)
pixel_json = utils.get_pixel_config(size)
blank_area = pixel_json['blank_area']
question_area = pixel_json['question_area']
blank_area_point = blank_area['x1'], blank_area['y1'], blank_area['x2'], blank_area['y2']
question_area_point = question_area['x1'], question_area['y1'], question_area['x2'], question_area['y2']
backup_img = None
if os.path.exists('image/backup.png'):
backup_img = Image.open('image/backup.png')
else:
utils.pull_from_screen_ios()
backup_img = Image.open('image/backup.png')
utils.crop_image(backup_img, question_area_point, 'image/crop_test.png')
utils.crop_image(backup_img, blank_area_point, 'image/blank_test.png')
def run_proc(name):
print('这是子进程{}'.format(name))
def test_process():
print('process {} start'.format(os.getpid()))
pool = Pool(2)
for i in range(2):
pool.apply_async(run_proc(i))
pool.close()
pool.join()
print('all done')
def test_split():
text = '蝴蝶的翅膀'
arr = text.split('的')
a1, a2 = arr
print(a1)
if a1 in '蝴蝶哈哈哈哈':
print(a1)
print(arr)
def test_ios_crop():
c = wda.Client()
c.screenshot('image/screen.png')
if os.path.exists('image/screen.png'):
ios_img = Image.open('image/screen.png')
width, height = ios_img.size
print('width:{},height:{}'.format(width, height))
def test_get_pixel():
size = 1440, 2560
config = utils.get_pixel_config(size)
print(config)
def test_get_question():
obj = {'words_result': [{'words': '11.代表作之一是《蒙娜丽莎的眼'},
{'words': '泪》的歌手是?'}, {'words': '林志颖'},
{'words': '林志炫'}, {'words': '林志玲'}],
'log_id': 916087026228727188, 'words_result_num': 5}
question, option = baiduocr.get_question_and_options(obj)
print(question)
print(option)
if __name__ == '__main__':
test_get_question()