-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
test_keyboard
executable file
·52 lines (45 loc) · 1.76 KB
/
test_keyboard
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
#!/usr/bin/env python3
"""Run a test compile for a keyboard.
"""
import random
import sys
from time import strftime, sleep
import qmk_redis
from qmk_compiler import compile_firmware
if len(sys.argv) != 2:
print('Usage: %s <keyboard_name>' % sys.argv[0])
exit(1)
keyboard_name = sys.argv[1]
metadata = qmk_redis.get('qmk_api_kb_%s' % (keyboard_name))
if not metadata:
print('No such keyboard!', keyboard_name)
exit(1)
if not metadata['layouts']:
print('No available layouts for %s!' % keyboard)
exit(1)
# Prepare our compile
layout_macro = random.choice(list(metadata['layouts']))
layout = list(map(lambda x: 'KC_NO', metadata['layouts'][layout_macro]['layout']))
layers = [layout, list(map(lambda x: 'KC_TRNS', layout))]
print('*** There are %s jobs on the queue.' % (len(qmk_redis.rq.jobs)))
print('***', strftime('%Y-%m-%d %H:%M:%S %z'))
print('Beginning test compile for %s, layout %s' % (keyboard_name, layout_macro))
job = compile_firmware.delay(keyboard_name, 'cli_test_compile', layout_macro, layers)
print('Successfully enqueued job_id %s, polling every 5 seconds.' % (job.id,))
started = False
print('Waiting to start compiling...', end="", flush=True)
while job.get_status() in ['queued', 'deferred', 'started'] and job.result is None:
if not started and job.get_status() == 'started':
started = True
print('\nWorker has picked up job and begun to compile.')
print('Waiting for compile...', end="", flush=True)
sleep(5)
print('.', end="", flush=True)
result = job.result
if result['returncode'] == 0:
print('\nCompile job completed successfully!')
exit(0)
else:
print('\nCould not compile %s, layout %s, return code %s' % (keyboard_name, layout_macro, result['returncode']))
print(result['output'])
exit(1)