1- import os , sys , argparse , subprocess , signal , shlex
1+ import os , sys , argparse , subprocess , signal
22
33# Project defaults
44FLASK_APP = 'server/__init__.py'
@@ -17,7 +17,7 @@ def run(self, conf):
1717 env = os .environ
1818 env .update (conf )
1919 env .update (self .env )
20- subprocess .call (shlex . split ( cmd ) , env = env , shell = True )
20+ subprocess .call (cmd , env = env )
2121
2222
2323class CommandManager :
@@ -51,12 +51,12 @@ def availableCommands(self):
5151cm .add (Command (
5252 "build" ,
5353 "compiles python files in project into .pyc binaries" ,
54- lambda c : 'python -m compileall .' ))
54+ lambda c : [ 'python' , '-m' , ' compileall' , '.' ] ))
5555
5656cm .add (Command (
5757 "start" ,
5858 "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' ] ,
6060 {
6161 'FLASK_APP' : FLASK_APP ,
6262 'FLASK_DEBUG' : 'false'
@@ -65,7 +65,7 @@ def availableCommands(self):
6565cm .add (Command (
6666 "run" ,
6767 "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' ] ,
6969 {
7070 'FLASK_APP' : FLASK_APP ,
7171 'FLASK_DEBUG' : 'true'
@@ -74,7 +74,7 @@ def availableCommands(self):
7474cm .add (Command (
7575 "livereload" ,
7676 "runs dev server using livereload for dynamic webpage reloading" ,
77- lambda c : 'python -m flask run' ,
77+ lambda c : [ 'python' , '-m' , ' flask' , ' run'] ,
7878 {
7979 'FLASK_APP' : FLASK_APP ,
8080 'FLASK_LIVE_RELOAD' : 'true' ,
@@ -83,7 +83,7 @@ def availableCommands(self):
8383cm .add (Command (
8484 "debug" ,
8585 "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'] ,
8787 {
8888 'FLASK_APP' : FLASK_APP ,
8989 'FLASK_DEBUG' : 'true'
@@ -92,7 +92,7 @@ def availableCommands(self):
9292cm .add (Command (
9393 "test" ,
9494 "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"'] ))
9696
9797# Create and format argument parser for CLI
9898parser = argparse .ArgumentParser (description = cm .availableCommands (),
0 commit comments