load stable cdn
This commit is contained in:
parent
2a1c24cda1
commit
c3bb70d2d5
@ -37,6 +37,13 @@ parser.add_argument(
|
|||||||
help='Файл билда'
|
help='Файл билда'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'-st',
|
||||||
|
'--stable',
|
||||||
|
action='store_true',
|
||||||
|
help='Стабильная версия'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@ -71,7 +78,7 @@ if __name__ == '__main__':
|
|||||||
if os.path.exists(filepath):
|
if os.path.exists(filepath):
|
||||||
file = {'file': open(filepath, 'rb')}
|
file = {'file': open(filepath, 'rb')}
|
||||||
res = requests.post(url='https://cdn.itguild.info/uploadfile/',
|
res = requests.post(url='https://cdn.itguild.info/uploadfile/',
|
||||||
files=file, data={'package': d['name'], 'version': d['version'], 'filename': args.file})
|
files=file, data={'package': d['name'], 'version': d['version'], 'filename': args.file, 'stable': args.stable})
|
||||||
if res.ok:
|
if res.ok:
|
||||||
print(f"Successfully uploaded {filepath}")
|
print(f"Successfully uploaded {filepath}")
|
||||||
print(res.text)
|
print(res.text)
|
||||||
|
@ -65,7 +65,7 @@ async def create_file(file: Annotated[bytes | None, File()] = None):
|
|||||||
|
|
||||||
@app.post("/uploadfile/")
|
@app.post("/uploadfile/")
|
||||||
async def create_upload_file(file: UploadFile | None, package: Annotated[str, Form()], version: Annotated[str, Form()],
|
async def create_upload_file(file: UploadFile | None, package: Annotated[str, Form()], version: Annotated[str, Form()],
|
||||||
filename: Annotated[str, Form()]):
|
filename: Annotated[str, Form()], stable: Annotated[bool, Form()] | None):
|
||||||
try:
|
try:
|
||||||
contents = file.file.read()
|
contents = file.file.read()
|
||||||
dir_file = "packages/{package}/{version}".format(package=package, version=version)
|
dir_file = "packages/{package}/{version}".format(package=package, version=version)
|
||||||
@ -81,6 +81,9 @@ async def create_upload_file(file: UploadFile | None, package: Annotated[str, Fo
|
|||||||
f.write(contents)
|
f.write(contents)
|
||||||
with open(f"{dir_last}/{filename}", 'wb') as f:
|
with open(f"{dir_last}/{filename}", 'wb') as f:
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
|
if stable:
|
||||||
|
with open(f"{dir_stable}/{filename}", 'wb') as f:
|
||||||
|
f.write(contents)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
return {"message": "There was an error uploading the file, error {err}".format(err=err)}
|
return {"message": "There was an error uploading the file, error {err}".format(err=err)}
|
||||||
finally:
|
finally:
|
||||||
|
Loading…
Reference in New Issue
Block a user