fixed publish command
This commit is contained in:
@@ -41,32 +41,33 @@ def publish(args):
|
|||||||
|
|
||||||
with console.status("Compressing...", spinner="bouncingBall", spinner_style="blue") as status:
|
with console.status("Compressing...", spinner="bouncingBall", spinner_style="blue") as status:
|
||||||
# compress to a tar file
|
# compress to a tar file
|
||||||
with tempfile.TemporaryFile(mode="wb+") as f:
|
f = tempfile.TemporaryFile(mode="wb+")
|
||||||
tar_file = tarfile.open(fileobj=f, mode="w:gz")
|
with tarfile.open(fileobj=f, mode="w:gz") as tar_file:
|
||||||
tar_file.add(args.folder_path, arcname=os.path.basename(args.folder_path))
|
tar_file.add(args.folder_path, arcname=os.path.basename(args.folder_path))
|
||||||
|
f.flush()
|
||||||
|
f.seek(0)
|
||||||
|
|
||||||
console.print("[d][:white_check_mark:] Compressed![/]")
|
console.print("[d][:white_check_mark:] Compressed![/]")
|
||||||
|
|
||||||
# send the request
|
# send the request
|
||||||
status.update("Uploading...")
|
status.update("Uploading...")
|
||||||
response = requests.put(
|
response = requests.put(
|
||||||
url=f"https://chookspace.com/api/packages/{username}/generic/{mineral_name}/{version}/mineral.tar",
|
url=f"https://chookspace.com/api/packages/{username}/generic/{mineral_name}/{version}/mineral.tar",
|
||||||
data=f,
|
data=f,
|
||||||
auth=HTTPBasicAuth(username, password)
|
auth=HTTPBasicAuth(username, password)
|
||||||
)
|
)
|
||||||
|
|
||||||
tar_file.close()
|
f.close()
|
||||||
|
|
||||||
if response.status_code == 401:
|
if response.status_code == 401:
|
||||||
console.print("[b red]digpkg: failed to publish mineral: authentication failed[/]")
|
console.print("[b red]digpkg: failed to publish mineral: authentication failed[/]")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
elif response.status_code == 400:
|
elif response.status_code == 400:
|
||||||
console.print("[b red]digpkg: failed to publish mineral: the package name or version number are invalid[/]")
|
console.print("[b red]digpkg: failed to publish mineral: the package name or version number are invalid[/]")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
elif response.status_code == 409:
|
elif response.status_code == 409:
|
||||||
console.print("[b red]digpkg: failed to publish mineral: that version number is already in use[/]")
|
console.print("[b red]digpkg: failed to publish mineral: that version number is already in use[/]")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
response.raise_for_status()
|
|
||||||
console.print("[d][:white_check_mark:] Uploaded![/]")
|
|
||||||
|
|
||||||
|
response.raise_for_status()
|
||||||
|
console.print("[d][:white_check_mark:] Uploaded![/]")
|
||||||
Reference in New Issue
Block a user