-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
72 lines (57 loc) · 1.56 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
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
"""
Complexity: fabfile.py
~~~~~~~~~~~~~~~~~~~~~~
Fabric file for managing Complexity.
:copyright: (c) 2015 Luke Southam <[email protected]>.
:license: New BSD, see LICENSE for more details.
"""
import os
import base64
import uuid
from fabric.api import task, local
from fabric.colors import *
from fab import pip
from complexity import create_app
from complexity import command_line
from complexity._secrets import __doc__ as secrets_doc
@task
def run():
command_line.run()
@task
def debug():
command_line.debug()
@task
def pyclean():
print magenta("Cleaning python cache...")
local('find . -type f -name "*.py[co]" -delete')
local('find . -type d -name "__pycache__" -delete')
print green("Done cleaning python cache files!")
@task
def clean():
clean_storage()
print magenta("Cleaning all temporary files...")
pyclean()
local('find . -type d -name ".*.swp" -delete')
print green("Done cleaning temporary files!")
@task
def create_secrets():
cookie_secret = base64.b64encode(
uuid.uuid4().bytes + uuid.uuid4().bytes
)
with open('complexity/secrets.py', 'w') as f:
f.write("""#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
\"\"\"
{}
\"\"\"
# NOTE: This file was automatically generated.
COOKIE_SECRET='{}'
""".format(secrets_doc, cookie_secret))
@task
def clean_storage():
print magenta("Cleaning storage...")
local('rm -f complexity.bin')
local('rm -f complexity.bin.lock')
print green("Done cleaning storage.")