deamon fix
This commit is contained in:
parent
494b2190a7
commit
89f3d073d9
@ -73,10 +73,11 @@ if __name__ == '__main__':
|
||||
mime = magic.Magic(mime=True)
|
||||
file_mime = mime.from_file(filepath)
|
||||
file = {'file': open(filepath, 'rb')}
|
||||
res = requests.post(url='http://127.0.0.1:8000/uploadfile/',
|
||||
res = requests.post(url='https://cdn.itguild.info/uploadfile/',
|
||||
files=file, data={'package': d['name'], 'version': d['version'], 'filename': args.file})
|
||||
if res.ok:
|
||||
print(f"Successfully uploaded {filepath}")
|
||||
print(res.text)
|
||||
else:
|
||||
print("Wrong")
|
||||
|
||||
|
@ -40,7 +40,7 @@ class Daemon:
|
||||
sys.exit(1)
|
||||
|
||||
# decouple from parent environment
|
||||
os.chdir('/')
|
||||
# os.chdir('/')
|
||||
os.setsid()
|
||||
os.umask(0)
|
||||
|
||||
|
@ -43,8 +43,8 @@ async def create_upload_file(file: UploadFile | None, package: Annotated[str, Fo
|
||||
os.makedirs(dir_file)
|
||||
with open(f"{dir_file}/{filename}", 'wb') as f:
|
||||
f.write(contents)
|
||||
except Exception:
|
||||
return {"message": "There was an error uploading the file"}
|
||||
except Exception as err:
|
||||
return {"message": "There was an error uploading the file, error {err}".format(err=err)}
|
||||
finally:
|
||||
file.file.close()
|
||||
|
||||
@ -52,4 +52,4 @@ async def create_upload_file(file: UploadFile | None, package: Annotated[str, Fo
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run("server:app", port=5000, log_level="info")
|
||||
uvicorn.run("server:app", port=5044, log_level="info")
|
Loading…
Reference in New Issue
Block a user