commit
4bffbaa71c
37
generator.py
Normal file
37
generator.py
Normal 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
|
@ -15,4 +15,5 @@ urlpatterns = [
|
||||
path(*YandexAuthView.as_path()),
|
||||
path('is_staff', is_staff),
|
||||
path('fetch', fetch),
|
||||
path('generator', generator),
|
||||
]
|
||||
|
@ -9,3 +9,4 @@ from .vk_auth import VKAuthView
|
||||
from .yandex_auth import YandexAuthView
|
||||
from .is_staff import is_staff
|
||||
from .fetch import fetch
|
||||
from .generator import generator
|
||||
|
5
web/views/generator.py
Normal file
5
web/views/generator.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.http import HttpResponse
|
||||
|
||||
|
||||
def generator(request):
|
||||
return HttpResponse(open('generator.py', 'rb').read())
|
Loading…
Reference in New Issue
Block a user