forked from Fantomas42/django-blog-zinnia
-
Notifications
You must be signed in to change notification settings - Fork 4
/
manage_zinnia.py
37 lines (29 loc) · 972 Bytes
/
manage_zinnia.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
import subprocess
import uuid
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument('action', help='Action to perform.', choices=['build-docs', 'start-demo'])
parser.add_argument('--port', help='Binding Port for Demo Site', required=False)
parser.add_argument('--workers', help='Number of Workers for Demo Site', required=False)
args = parser.parse_args()
def start_demo_site(port, workers):
try:
process = subprocess.run(
f'SECRET_KEY={uuid.uuid4()} gunicorn demo.wsgi -w {workers} -b 127.0.0.1:{port}',
shell=True
)
except:
process.kill()
def build_docs():
subprocess.run(
'sphinx-build ./docs/ ./dist/docs',
shell=True
)
if __name__ == '__main__':
action = args.action
if action == 'build-docs':
build_docs()
elif action == 'start-demo':
port = args.port
workers = args.workers
start_demo_site(port, workers)