Implement "package pack" command

This commit is contained in:
Ivan Kravets
2020-05-26 22:17:55 +03:00
parent 19cdc7d34a
commit 8346b9822d
3 changed files with 13 additions and 14 deletions

View File

@@ -25,16 +25,18 @@ class RegistryClient(RESTClient):
def publish_package(
self, archive_path, owner=None, released_at=None, private=False
):
client = AccountClient()
account = AccountClient()
if not owner:
owner = client.get_account_info(offline=True).get("profile").get("username")
owner = (
account.get_account_info(offline=True).get("profile").get("username")
)
with open(archive_path, "rb") as fp:
response = self.send_request(
"post",
"/v3/package/%s/%s" % (owner, PackageType.from_archive(archive_path)),
params={"private": 1 if private else 0, "released_at": released_at},
headers={
"Authorization": "Bearer %s" % client.fetch_authentication_token()
"Authorization": "Bearer %s" % account.fetch_authentication_token()
},
data=fp,
)