fix
All checks were successful
Deploy Prod / Build (pull_request) Successful in 6s
Deploy Prod / Push (pull_request) Successful in 13s
Deploy Prod / Deploy prod (pull_request) Successful in 14s

This commit is contained in:
emmatveev 2024-12-08 15:50:16 +03:00
parent b9a2ab5509
commit f1b57abeca
4 changed files with 44 additions and 0 deletions

37
generator.py Normal file
View File

@ -0,0 +1,37 @@
import json
import urllib.request
import os
import shutil
projects = {
'queues': 'tasks.proto'
}
try:
shutil.rmtree('schemas')
except:
pass
try:
os.mkdir('schemas')
except:
pass
for project in projects:
response = urllib.request.urlopen(f'https://platform.sprinthub.ru/schemas/get?project={project}').read()
data = json.loads(response)
os.mkdir(f'schemas/{project}')
for key, value in data.items():
with open(f'schemas/{project}/{key}', 'w+') as fp:
fp.write(value)
for key, value in projects.items():
os.system(f'python -m grpc_tools.protoc --proto_path schemas --python_out=. --pyi_out=. --grpc_python_out=. ./schemas/{key}/{value}')
try:
shutil.rmtree('schemas')
except:
pass

View File

@ -15,4 +15,5 @@ urlpatterns = [
path(*YandexAuthView.as_path()), path(*YandexAuthView.as_path()),
path('is_staff', is_staff), path('is_staff', is_staff),
path('fetch', fetch), path('fetch', fetch),
path('generator', generator),
] ]

View File

@ -9,3 +9,4 @@ from .vk_auth import VKAuthView
from .yandex_auth import YandexAuthView from .yandex_auth import YandexAuthView
from .is_staff import is_staff from .is_staff import is_staff
from .fetch import fetch from .fetch import fetch
from .generator import generator

5
web/views/generator.py Normal file
View File

@ -0,0 +1,5 @@
from django.http import HttpResponse
def generator(request):
return HttpResponse(open('generator.py', 'rb').read())