forked from wbond/asn1crypto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
58 lines (41 loc) · 1.12 KB
/
run.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
#!/usr/bin/env python
# coding: utf-8
from __future__ import unicode_literals, division, absolute_import, print_function
import sys
if sys.version_info < (3,):
byte_cls = str
else:
byte_cls = bytes
def show_usage():
print('Usage: run.py (lint | tests [regex] | coverage | ci | release)', file=sys.stderr)
sys.exit(1)
def get_arg(num):
if len(sys.argv) < num + 1:
return None
arg = sys.argv[num]
if isinstance(arg, byte_cls):
arg = arg.decode('utf-8')
return arg
if len(sys.argv) < 2 or len(sys.argv) > 3:
show_usage()
task = get_arg(1)
if task not in set(['lint', 'tests', 'coverage', 'ci', 'release']):
show_usage()
if task != 'tests' and len(sys.argv) == 3:
show_usage()
params = []
if task == 'lint':
from dev.lint import run
elif task == 'tests':
from dev.tests import run
matcher = get_arg(2)
if matcher:
params.append(matcher)
elif task == 'coverage':
from dev.coverage import run
elif task == 'ci':
from dev.ci import run
elif task == 'release':
from dev.release import run
result = run(*params)
sys.exit(int(not result))