コード例 #1
0
ファイル: registry.py プロジェクト: Globalync/platformio-core
 def publish_package(self,
                     archive_path,
                     owner=None,
                     released_at=None,
                     private=False,
                     notify=True):
     account = AccountClient()
     if not owner:
         owner = (account.get_account_info(
             offline=True).get("profile").get("username"))
     with open(archive_path, "rb") as fp:
         return self.send_auth_request(
             "post",
             "/v3/packages/%s/%s" %
             (owner, PackageType.from_archive(archive_path)),
             params={
                 "private": 1 if private else 0,
                 "notify": 1 if notify else 0,
                 "released_at": released_at,
             },
             headers={
                 "Content-Type":
                 "application/octet-stream",
                 "X-PIO-Content-SHA256":
                 fs.calculate_file_hashsum("sha256", archive_path),
             },
             data=fp,
         )
コード例 #2
0
def account_show(offline, json_output):
    client = AccountClient()
    info = client.get_account_info(offline)
    if json_output:
        return click.echo(json.dumps(info))
    click.echo()
    if info.get("profile"):
        print_profile(info["profile"])
    if info.get("packages"):
        print_packages(info["packages"])
    if info.get("subscriptions"):
        print_subscriptions(info["subscriptions"])
    return click.echo()
コード例 #3
0
 def unpublish_package(  # pylint: disable=redefined-builtin
     self, type, name, owner=None, version=None, undo=False
 ):
     account = AccountClient()
     if not owner:
         owner = (
             account.get_account_info(offline=True).get("profile").get("username")
         )
     path = "/v3/packages/%s/%s/%s" % (owner, type, name)
     if version:
         path += "/" + version
     return self.send_auth_request(
         "delete", path, params={"undo": 1 if undo else 0},
     )
コード例 #4
0
def account_destroy():
    client = AccountClient()
    click.confirm(
        "Are you sure you want to delete the %s user account?\n"
        "Warning! All linked data will be permanently removed and can not be restored."
        % client.get_account_info().get("profile").get("username"),
        abort=True,
    )
    client.destroy_account()
    try:
        client.logout()
    except AccountNotAuthorized:
        pass
    return click.secho(
        "User account has been destroyed.",
        fg="green",
    )