-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtasks.py
69 lines (53 loc) · 1.44 KB
/
tasks.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
import os
import re
import shutil
import stat
from invoke import task
@task
def restapi(c):
c.run('python -m pytest -n 4 ./tests/restapi')
@task
def unit(c):
c.run('python -m pytest ./tests/unit --cov=sintel')
@task
def install_minimum(c):
with open('setup.py', 'r') as setup_py:
lines = setup_py.read().splitlines()
versions = []
started = False
for line in lines:
if started:
if line == ']':
started = False
continue
line = line.strip()
if (len(line) > 0) and (line[0] == '#'):
continue
line = re.sub(r',?<=?[\d.]*,?', '', line)
line = re.sub(r'>=?', '==', line)
line = re.sub(r"""['",]""", '', line)
versions.append(line)
elif line.startswith('install_requires = ['):
started = True
c.run(f'python -m pip install {" ".join(versions)}')
@task
def minimum(c):
install_minimum(c)
c.run('python -m pip check')
unit(c)
restapi(c)
@task
def lint(c):
c.run('flake8 sintel tests --ignore W503')
c.run('isort -c --recursive sintel tests')
# c.run('pydocstyle sintel')
def remove_readonly(func, path, _):
"Clear the readonly bit and reattempt the removal"
os.chmod(path, stat.S_IWRITE)
func(path)
@task
def rmdir(c, path):
try:
shutil.rmtree(path, onerror=remove_readonly)
except PermissionError:
pass