1
- import os , sys , argparse , subprocess , signal , shlex
1
+ import os , sys , argparse , subprocess , signal
2
2
3
3
# Project defaults
4
4
FLASK_APP = 'server/__init__.py'
@@ -17,7 +17,7 @@ def run(self, conf):
17
17
env = os .environ
18
18
env .update (conf )
19
19
env .update (self .env )
20
- subprocess .call (shlex . split ( cmd ) , env = env , shell = True )
20
+ subprocess .call (cmd , env = env )
21
21
22
22
23
23
class CommandManager :
@@ -51,12 +51,12 @@ def availableCommands(self):
51
51
cm .add (Command (
52
52
"build" ,
53
53
"compiles python files in project into .pyc binaries" ,
54
- lambda c : 'python -m compileall .' ))
54
+ lambda c : [ 'python' , '-m' , ' compileall' , '.' ] ))
55
55
56
56
cm .add (Command (
57
57
"start" ,
58
58
"runs server with gunicorn in a production setting" ,
59
- lambda c : 'gunicorn -b {0}:{1} server:app' . format ( c ['host' ], c ['port' ]) ,
59
+ lambda c : [ 'gunicorn' , '-b' , c ['host' ] + ':' + c ['port' ], 'server:app' ] ,
60
60
{
61
61
'FLASK_APP' : FLASK_APP ,
62
62
'FLASK_DEBUG' : 'false'
@@ -65,7 +65,7 @@ def availableCommands(self):
65
65
cm .add (Command (
66
66
"run" ,
67
67
"runs dev server using Flask's native debugger & backend reloader" ,
68
- lambda c : 'python -m flask run --host={0} --port={1} --debugger --reload' . format ( c ['host ' ], c [ 'port' ]) ,
68
+ lambda c : [ 'python' , '-m' , ' flask' , ' run' , ' --host=' + c [ 'host' ], ' --port=' + c ['port ' ], '--debugger' , '--reload' ] ,
69
69
{
70
70
'FLASK_APP' : FLASK_APP ,
71
71
'FLASK_DEBUG' : 'true'
@@ -74,7 +74,7 @@ def availableCommands(self):
74
74
cm .add (Command (
75
75
"livereload" ,
76
76
"runs dev server using livereload for dynamic webpage reloading" ,
77
- lambda c : 'python -m flask run' ,
77
+ lambda c : [ 'python' , '-m' , ' flask' , ' run'] ,
78
78
{
79
79
'FLASK_APP' : FLASK_APP ,
80
80
'FLASK_LIVE_RELOAD' : 'true' ,
@@ -83,7 +83,7 @@ def availableCommands(self):
83
83
cm .add (Command (
84
84
"debug" ,
85
85
"runs dev server in debug mode; use with an IDE's remote debugger" ,
86
- lambda c : 'python -m flask run --host={0} --port={1} --no-debugger --no-reload' . format ( c [ 'host' ], c [ 'port' ]) ,
86
+ lambda c : [ 'python' , '-m' , ' flask' , ' run' , ' --host=' + c [ 'host' ], ' --port=' + c [ 'port' ], ' --no-debugger' , ' --no-reload'] ,
87
87
{
88
88
'FLASK_APP' : FLASK_APP ,
89
89
'FLASK_DEBUG' : 'true'
@@ -92,7 +92,7 @@ def availableCommands(self):
92
92
cm .add (Command (
93
93
"test" ,
94
94
"runs all tests inside of `tests` directory" ,
95
- lambda c : 'python -m unittest discover -s tests -p "*.py"' ))
95
+ lambda c : [ 'python' , '-m' , ' unittest' , ' discover' , '-s' , ' tests' , '-p' , ' "*.py"'] ))
96
96
97
97
# Create and format argument parser for CLI
98
98
parser = argparse .ArgumentParser (description = cm .availableCommands (),
0 commit comments