redid command invocation to catch bad return codes

This commit is contained in:
andy 2021-02-07 23:32:46 +00:00
parent 1ca8e6b778
commit ab11346a2a
2 changed files with 27 additions and 17 deletions

View File

@ -45,26 +45,30 @@ class Admin(Cmd):
# )
# os.chdir(stage_dir)
# os.system('gcloud config set project sarsooxyz')
subprocess.check_call(['gcloud', 'config', 'set', 'project', 'sarsooxyz'], shell=True)
def prepare_frontend(self):
print('>> building css')
os.system(f'sass --style=compressed {scss_rel_path} {css_rel_path}')
print(f'sass --style=compressed {scss_rel_path} {css_rel_path}')
subprocess.check_call(['sass', '--style=compressed', str(scss_rel_path), str(css_rel_path)], shell=True)
print('>> building javascript')
os.system('npm run build')
subprocess.check_call(['npm', 'run', 'build'], shell=True)
def prepare_main(self, path):
print('>> preparing main.py')
shutil.copy(f'main.{path}.py', 'main.py')
def deploy_function(self, name, timeout: int = 60, region='europe-west2'):
os.system(f'gcloud functions deploy {name} '
f'--region {region} '
'--runtime=python38 '
f'--trigger-topic {name} '
'--set-env-vars DEPLOY_DESTINATION=PROD '
f'--timeout={timeout}s')
subprocess.check_call([
'gcloud', 'functions', 'deploy', name,
'--region', region,
'--runtime=python38',
'--trigger-topic', name,
'--set-env-vars', 'DEPLOY_DESTINATION=PROD',
f'--timeout={timeout}s'
], shell=True
)
def do_all(self, args):
self.prepare_frontend()
@ -72,7 +76,7 @@ class Admin(Cmd):
self.prepare_main('api')
print('>> deploying api')
os.system('gcloud app deploy')
subprocess.check_call(['gcloud', 'app', 'deploy'], shell=True)
self.prepare_main('update_tag')
print('>> deploying tag function')
@ -89,7 +93,7 @@ class Admin(Cmd):
self.prepare_main('api')
print('>> deploying')
os.system('gcloud app deploy')
subprocess.check_call(['gcloud', 'app', 'deploy'], shell=True)
def do_tag(self, args):
self.prepare_stage()
@ -145,10 +149,10 @@ class Admin(Cmd):
exit(0)
def do_sass(self, args):
os.system(f'sass --style=compressed {scss_rel_path} {css_rel_path}')
subprocess.check_call(['sass', '--style=compressed', str(scss_rel_path), str(css_rel_path)], shell=True)
def do_watchsass(self, args):
os.system(f'sass --style=compressed --watch {scss_rel_path} {css_rel_path}')
subprocess.check_call(['sass', '--style=compressed', '--watch', str(scss_rel_path), str(css_rel_path)], shell=True)
def do_rename(self, args):
from music.model.user import User
@ -171,13 +175,13 @@ class Admin(Cmd):
playlist.update()
def do_depend(self, args):
return os.popen('poetry export -f requirements.txt --output requirements.txt').read()
return subprocess.check_output(['poetry', 'export', '-f', 'requirements.txt', '--output', 'requirements.txt'], shell=True, text=True)
def do_filt_depend(self, args):
self.export_filtered_dependencies()
def export_filtered_dependencies(self):
string = os.popen('poetry export -f requirements.txt --without-hashes').read()
string = subprocess.check_output(['poetry', 'export', '-f', 'requirements.txt', '--without-hashes'], shell=True, text=True)
depend = string.split('\n')
@ -191,8 +195,8 @@ class Admin(Cmd):
def test():
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'service.json'
subprocess.run(
['python', '-u', '-m', 'unittest', 'discover', "-s", "tests"]
subprocess.check_call(
['python', '-u', '-m', 'unittest', 'discover', "-s", "tests"], shell=True
)
if __name__ == '__main__':

6
main.py Normal file
View File

@ -0,0 +1,6 @@
from music.music import create_app
app = create_app()
if __name__ == '__main__':
app.run(host='127.0.0.1', port=8080, debug=True)