-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
126 lines (105 loc) · 3.64 KB
/
fabfile.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
from fabric.api import lcd, task, settings, hide
from fabpolish import polish, sniff, local, info
from fabpolish.contrib import find_merge_conflict_leftovers
import os
from subprocess import call
ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
# @sniff(severity='major', timing='fast')
# def run_eslint():
# info('Running ESLint...')
# return local(
# "git ls-files | "
# "grep '\.js$' | "
# "xargs ./node_modules/eslint/bin/eslint.js --config=.eslintrc"
# )
@sniff(severity='major', timing='fast')
def remove_compiled_classes():
info('Removing compiled python classes...')
local('pyclean .')
return local(
'find ./federation_api ./config -name "*.py[co]" -print0 | xargs -0 rm -f'
)
@sniff(severity='major', timing='fast')
def fix_directory_permission():
info('Fixing directory permissions...')
return local(
'! find ./federation_api ./config '
'-path .git -prune -o '
'-name .webassets-cache -prune -o '
'-name gen -prune -o '
'-type d -not -perm 0775 -print0 | '
'tee /dev/stderr | '
'xargs -0 chmod 0775 >/dev/null 2>&1'
)
@sniff(severity='major', timing='fast')
def fix_file_permission():
"""Fixing permissions for files"""
info('Fixing permissions for files...')
return local(
"git ls-files -z | "
"grep -PvZz '\.sh$' | "
"grep -PvZz 'tests/' | "
"xargs -0 chmod -c 0664 > /dev/null 2>&1"
)
@sniff(severity='major', timing='fast')
def check_code_standard():
"""Running coding standards check"""
info('Running coding standards check...')
return local(
'pep8 ./federation_api ./config'
)
@sniff(severity='major', timing='fast')
def static_code_analyzer():
"""Running static code analyzer"""
info('Running static code analyzer...')
return local(
'pyflakes ./federation_api ./config'
)
@sniff(severity='major', timing='fast')
def check_print_statement():
"""Checking for debug print statements"""
info('Checking for debug print statements...')
return local(
'! find ./federation_api ./config -type f -name "*.py" -print0 | '
'xargs -0 grep -Pn \'(?<![Bb]lue|>>> )print\' | '
'grep -v NOCHECK'
)
@sniff(severity='major', timing='fast')
def servername_compatibility():
"""Checking for no-servername compatibility"""
info('Checking for no-servername compatibility...')
return local(
'! find ./federation_api ./config -name "default_settings.py" -o '
' -type f -name "*.py" -print0 | '
'xargs -0 grep -Pn \'SERVER_NAME|ENABLE_HTTPS|SSO_DOMAIN|'
'(SOFTWARE(_WEBSITE)?|EPICENTER|FABRIC|PVR|PRACTONAV)_HOST\''
)
# @sniff(severity='major', timing='fast')
# def check_migrations():
# """Checking migration branches"""
# info('Checking migration branches...')
# return local(
# '! alembic branches | grep branchpoint'
# )
@sniff(severity='major', timing='fast')
def run_tests():
"""Running tests"""
info('Running tests...')
value = 'PYTHONPATH=%s FLASK_ENV=TEST py.test --cov=. ./tests' % ROOT_DIR
return local(
value
)
@task
def grep(term, flags=''):
with lcd(ROOT_DIR), settings(hide('running')):
local('find federation_api ./config tests '
'-name "*~" -o '
'-name "*.py[co]" -o '
'-name "*.dot" -o '
'-name "*.min.*" -o '
'-name "gen" -prune -o '
'-name ".webassets-cache" -prune -o '
'-type d -o '
'-print0 | '
'xargs -0 grep -n --color=force ' + flags + ' "' + term + '"; '
' echo -n')