redid command invocation to catch bad return codes
This commit is contained in:
parent
1ca8e6b778
commit
ab11346a2a
38
admin.py
38
admin.py
@ -45,26 +45,30 @@ class Admin(Cmd):
|
|||||||
# )
|
# )
|
||||||
|
|
||||||
# os.chdir(stage_dir)
|
# 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):
|
def prepare_frontend(self):
|
||||||
print('>> building css')
|
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')
|
print('>> building javascript')
|
||||||
os.system('npm run build')
|
subprocess.check_call(['npm', 'run', 'build'], shell=True)
|
||||||
|
|
||||||
def prepare_main(self, path):
|
def prepare_main(self, path):
|
||||||
print('>> preparing main.py')
|
print('>> preparing main.py')
|
||||||
shutil.copy(f'main.{path}.py', 'main.py')
|
shutil.copy(f'main.{path}.py', 'main.py')
|
||||||
|
|
||||||
def deploy_function(self, name, timeout: int = 60, region='europe-west2'):
|
def deploy_function(self, name, timeout: int = 60, region='europe-west2'):
|
||||||
os.system(f'gcloud functions deploy {name} '
|
subprocess.check_call([
|
||||||
f'--region {region} '
|
'gcloud', 'functions', 'deploy', name,
|
||||||
'--runtime=python38 '
|
'--region', region,
|
||||||
f'--trigger-topic {name} '
|
'--runtime=python38',
|
||||||
'--set-env-vars DEPLOY_DESTINATION=PROD '
|
'--trigger-topic', name,
|
||||||
f'--timeout={timeout}s')
|
'--set-env-vars', 'DEPLOY_DESTINATION=PROD',
|
||||||
|
f'--timeout={timeout}s'
|
||||||
|
], shell=True
|
||||||
|
)
|
||||||
|
|
||||||
def do_all(self, args):
|
def do_all(self, args):
|
||||||
self.prepare_frontend()
|
self.prepare_frontend()
|
||||||
@ -72,7 +76,7 @@ class Admin(Cmd):
|
|||||||
|
|
||||||
self.prepare_main('api')
|
self.prepare_main('api')
|
||||||
print('>> deploying api')
|
print('>> deploying api')
|
||||||
os.system('gcloud app deploy')
|
subprocess.check_call(['gcloud', 'app', 'deploy'], shell=True)
|
||||||
|
|
||||||
self.prepare_main('update_tag')
|
self.prepare_main('update_tag')
|
||||||
print('>> deploying tag function')
|
print('>> deploying tag function')
|
||||||
@ -89,7 +93,7 @@ class Admin(Cmd):
|
|||||||
self.prepare_main('api')
|
self.prepare_main('api')
|
||||||
|
|
||||||
print('>> deploying')
|
print('>> deploying')
|
||||||
os.system('gcloud app deploy')
|
subprocess.check_call(['gcloud', 'app', 'deploy'], shell=True)
|
||||||
|
|
||||||
def do_tag(self, args):
|
def do_tag(self, args):
|
||||||
self.prepare_stage()
|
self.prepare_stage()
|
||||||
@ -145,10 +149,10 @@ class Admin(Cmd):
|
|||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
def do_sass(self, args):
|
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):
|
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):
|
def do_rename(self, args):
|
||||||
from music.model.user import User
|
from music.model.user import User
|
||||||
@ -171,13 +175,13 @@ class Admin(Cmd):
|
|||||||
playlist.update()
|
playlist.update()
|
||||||
|
|
||||||
def do_depend(self, args):
|
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):
|
def do_filt_depend(self, args):
|
||||||
self.export_filtered_dependencies()
|
self.export_filtered_dependencies()
|
||||||
|
|
||||||
def export_filtered_dependencies(self):
|
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')
|
depend = string.split('\n')
|
||||||
|
|
||||||
@ -191,8 +195,8 @@ class Admin(Cmd):
|
|||||||
|
|
||||||
def test():
|
def test():
|
||||||
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'service.json'
|
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'service.json'
|
||||||
subprocess.run(
|
subprocess.check_call(
|
||||||
['python', '-u', '-m', 'unittest', 'discover', "-s", "tests"]
|
['python', '-u', '-m', 'unittest', 'discover', "-s", "tests"], shell=True
|
||||||
)
|
)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user