Skip to content

Commit

Permalink
Merge branch 'release/v5.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Sep 10, 2020
2 parents ada3f8b + b515a00 commit 65297c2
Show file tree
Hide file tree
Showing 38 changed files with 432 additions and 148 deletions.
14 changes: 13 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,23 @@ PlatformIO Core 5

**A professional collaborative platform for embedded development**

- `Migration guide from 4.x to 5.0 <https://docs.platformio.org/page/core/migration.html>`__
5.0.1 (2020-09-10)
~~~~~~~~~~~~~~~~~~

- Added support for "owner" requirement when declaring ``dependencies`` using `library.json <https://docs.platformio.org/page/librarymanager/config.html#dependencies>`__
- Fixed an issue when using a custom git/ssh package with `platform_packages <https://docs.platformio.org/page/projectconf/section_env_platform.html#platform-packages>`__ option (`issue #3624 <https://github.com/platformio/platformio-core/issues/3624>`_)
- Fixed an issue with "ImportError: cannot import name '_get_backend' from 'cryptography.hazmat.backends'" when using `Remote Development <https://docs.platformio.org/page/plus/pio-remote.html>`__ on RaspberryPi device (`issue #3652 <https://github.com/platformio/platformio-core/issues/3652>`_)
- Fixed an issue when `pio package unpublish <https://docs.platformio.org/page/core/userguide/package/cmd_unpublish.html>`__ command crashes (`issue #3660 <https://github.com/platformio/platformio-core/issues/3660>`_)
- Fixed an issue when the package manager tries to install a built-in library from the registry (`issue #3662 <https://github.com/platformio/platformio-core/issues/3662>`_)
- Fixed an issue with incorrect value for C++ language standard in IDE projects when an in-progress language standard is used (`issue #3653 <https://github.com/platformio/platformio-core/issues/3653>`_)
- Fixed an issue with "Invalid simple block (semantic_version)" from library dependency that refs to an external source (repository, ZIP/Tar archives) (`issue #3658 <https://github.com/platformio/platformio-core/issues/3658>`_)
- Fixed an issue when can not remove update or remove external dev-platform using PlatformIO Home (`issue #3663 <https://github.com/platformio/platformio-core/issues/3663>`_)

5.0.0 (2020-09-03)
~~~~~~~~~~~~~~~~~~

Please check `Migration guide from 4.x to 5.0 <https://docs.platformio.org/page/core/migration.html>`__.

* Integration with the new **PlatformIO Trusted Registry**

- Enterprise-grade package storage with high availability (multi replicas)
Expand Down
2 changes: 1 addition & 1 deletion platformio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import sys

VERSION = (5, 0, 0)
VERSION = (5, 0, 1)
__version__ = ".".join([str(s) for s in VERSION])

__title__ = "platformio"
Expand Down
64 changes: 50 additions & 14 deletions platformio/clients/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def login(self, username, password):
)

data = self.fetch_json_data(
"post", "/v1/login", data={"username": username, "password": password},
"post",
"/v1/login",
data={"username": username, "password": password},
)
app.set_state_item("account", data)
return data
Expand Down Expand Up @@ -108,7 +110,9 @@ def logout(self):
self.delete_local_session()
try:
self.fetch_json_data(
"post", "/v1/logout", data={"refresh_token": refresh_token},
"post",
"/v1/logout",
data={"refresh_token": refresh_token},
)
except AccountError:
pass
Expand Down Expand Up @@ -153,15 +157,26 @@ def auth_token(self, password, regenerate):
).get("auth_token")

def forgot_password(self, username):
return self.fetch_json_data("post", "/v1/forgot", data={"username": username},)
return self.fetch_json_data(
"post",
"/v1/forgot",
data={"username": username},
)

def get_profile(self):
return self.send_auth_request("get", "/v1/profile",)
return self.send_auth_request(
"get",
"/v1/profile",
)

def update_profile(self, profile, current_password):
profile["current_password"] = current_password
self.delete_local_state("summary")
response = self.send_auth_request("put", "/v1/profile", data=profile,)
response = self.send_auth_request(
"put",
"/v1/profile",
data=profile,
)
return response

def get_account_info(self, offline=False):
Expand All @@ -178,7 +193,10 @@ def get_account_info(self, offline=False):
"username": account.get("username"),
}
}
result = self.send_auth_request("get", "/v1/summary",)
result = self.send_auth_request(
"get",
"/v1/summary",
)
account["summary"] = dict(
profile=result.get("profile"),
packages=result.get("packages"),
Expand All @@ -203,27 +221,40 @@ def get_org(self, orgname):
return self.send_auth_request("get", "/v1/orgs/%s" % orgname)

def list_orgs(self):
return self.send_auth_request("get", "/v1/orgs",)
return self.send_auth_request(
"get",
"/v1/orgs",
)

def update_org(self, orgname, data):
return self.send_auth_request(
"put", "/v1/orgs/%s" % orgname, data={k: v for k, v in data.items() if v}
)

def destroy_org(self, orgname):
return self.send_auth_request("delete", "/v1/orgs/%s" % orgname,)
return self.send_auth_request(
"delete",
"/v1/orgs/%s" % orgname,
)

def add_org_owner(self, orgname, username):
return self.send_auth_request(
"post", "/v1/orgs/%s/owners" % orgname, data={"username": username},
"post",
"/v1/orgs/%s/owners" % orgname,
data={"username": username},
)

def list_org_owners(self, orgname):
return self.send_auth_request("get", "/v1/orgs/%s/owners" % orgname,)
return self.send_auth_request(
"get",
"/v1/orgs/%s/owners" % orgname,
)

def remove_org_owner(self, orgname, username):
return self.send_auth_request(
"delete", "/v1/orgs/%s/owners" % orgname, data={"username": username},
"delete",
"/v1/orgs/%s/owners" % orgname,
data={"username": username},
)

def create_team(self, orgname, teamname, description):
Expand All @@ -235,16 +266,21 @@ def create_team(self, orgname, teamname, description):

def destroy_team(self, orgname, teamname):
return self.send_auth_request(
"delete", "/v1/orgs/%s/teams/%s" % (orgname, teamname),
"delete",
"/v1/orgs/%s/teams/%s" % (orgname, teamname),
)

def get_team(self, orgname, teamname):
return self.send_auth_request(
"get", "/v1/orgs/%s/teams/%s" % (orgname, teamname),
"get",
"/v1/orgs/%s/teams/%s" % (orgname, teamname),
)

def list_teams(self, orgname):
return self.send_auth_request("get", "/v1/orgs/%s/teams" % orgname,)
return self.send_auth_request(
"get",
"/v1/orgs/%s/teams" % orgname,
)

def update_team(self, orgname, teamname, data):
return self.send_auth_request(
Expand Down
12 changes: 9 additions & 3 deletions platformio/clients/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,16 @@ def unpublish_package( # pylint: disable=redefined-builtin
if version:
path += "/" + version
return self.send_auth_request(
"delete", path, params={"undo": 1 if undo else 0},
"delete",
path,
params={"undo": 1 if undo else 0},
)

def update_resource(self, urn, private):
return self.send_auth_request(
"put", "/v3/resources/%s" % urn, data={"private": int(private)},
"put",
"/v3/resources/%s" % urn,
data={"private": int(private)},
)

def grant_access_for_resource(self, urn, client, level):
Expand All @@ -87,7 +91,9 @@ def grant_access_for_resource(self, urn, client, level):

def revoke_access_from_resource(self, urn, client):
return self.send_auth_request(
"delete", "/v3/resources/%s/access" % urn, data={"client": client},
"delete",
"/v3/resources/%s/access" % urn,
data={"client": client},
)

def list_resources(self, owner):
Expand Down
24 changes: 16 additions & 8 deletions platformio/commands/access.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,31 @@ def validate_urn(value):

@cli.command("public", short_help="Make resource public")
@click.argument(
"urn", callback=lambda _, __, value: validate_urn(value),
"urn",
callback=lambda _, __, value: validate_urn(value),
)
@click.option("--urn-type", type=click.Choice(["prn:reg:pkg"]), default="prn:reg:pkg")
def access_public(urn, urn_type):
client = RegistryClient()
client.update_resource(urn=urn, private=0)
return click.secho(
"The resource %s has been successfully updated." % urn, fg="green",
"The resource %s has been successfully updated." % urn,
fg="green",
)


@cli.command("private", short_help="Make resource private")
@click.argument(
"urn", callback=lambda _, __, value: validate_urn(value),
"urn",
callback=lambda _, __, value: validate_urn(value),
)
@click.option("--urn-type", type=click.Choice(["prn:reg:pkg"]), default="prn:reg:pkg")
def access_private(urn, urn_type):
client = RegistryClient()
client.update_resource(urn=urn, private=1)
return click.secho(
"The resource %s has been successfully updated." % urn, fg="green",
"The resource %s has been successfully updated." % urn,
fg="green",
)


Expand All @@ -79,14 +83,16 @@ def access_private(urn, urn_type):
callback=lambda _, __, value: validate_client(value),
)
@click.argument(
"urn", callback=lambda _, __, value: validate_urn(value),
"urn",
callback=lambda _, __, value: validate_urn(value),
)
@click.option("--urn-type", type=click.Choice(["prn:reg:pkg"]), default="prn:reg:pkg")
def access_grant(level, client, urn, urn_type):
reg_client = RegistryClient()
reg_client.grant_access_for_resource(urn=urn, client=client, level=level)
return click.secho(
"Access for resource %s has been granted for %s" % (urn, client), fg="green",
"Access for resource %s has been granted for %s" % (urn, client),
fg="green",
)


Expand All @@ -97,14 +103,16 @@ def access_grant(level, client, urn, urn_type):
callback=lambda _, __, value: validate_client(value),
)
@click.argument(
"urn", callback=lambda _, __, value: validate_urn(value),
"urn",
callback=lambda _, __, value: validate_urn(value),
)
@click.option("--urn-type", type=click.Choice(["prn:reg:pkg"]), default="prn:reg:pkg")
def access_revoke(client, urn, urn_type):
reg_client = RegistryClient()
reg_client.revoke_access_from_resource(urn=urn, client=client)
return click.secho(
"Access for resource %s has been revoked for %s" % (urn, client), fg="green",
"Access for resource %s has been revoked for %s" % (urn, client),
fg="green",
)


Expand Down
5 changes: 4 additions & 1 deletion platformio/commands/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ def account_destroy():
client.logout()
except AccountNotAuthorized:
pass
return click.secho("User account has been destroyed.", fg="green",)
return click.secho(
"User account has been destroyed.",
fg="green",
)


@cli.command("show", short_help="PlatformIO Account information")
Expand Down
4 changes: 3 additions & 1 deletion platformio/commands/device/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ def device_monitor(**kwargs): # pylint: disable=too-many-branches
kwargs["port"] = ports[0]["port"]
elif "platform" in project_options and "board" in project_options:
board_hwids = device_helpers.get_board_hwids(
kwargs["project_dir"], platform, project_options["board"],
kwargs["project_dir"],
platform,
project_options["board"],
)
for item in ports:
for hwid in board_hwids:
Expand Down
15 changes: 2 additions & 13 deletions platformio/commands/lib/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@

from platformio import exception, fs, util
from platformio.commands import PlatformioCLI
from platformio.commands.lib.helpers import (
get_builtin_libs,
is_builtin_lib,
save_project_libdeps,
)
from platformio.commands.lib.helpers import get_builtin_libs, save_project_libdeps
from platformio.compat import dump_json_to_unicode
from platformio.package.exception import NotGlobalLibDir, UnknownPackageError
from platformio.package.manager.library import LibraryPackageManager
Expand Down Expand Up @@ -164,15 +160,8 @@ def lib_install( # pylint: disable=too-many-arguments,unused-argument
}

elif storage_dir in storage_libdeps:
builtin_lib_storages = None
for library in storage_libdeps[storage_dir]:
try:
lm.install(library, silent=silent, force=force)
except UnknownPackageError as e:
if builtin_lib_storages is None:
builtin_lib_storages = get_builtin_libs()
if not silent or not is_builtin_lib(builtin_lib_storages, library):
click.secho("Warning! %s" % e, fg="yellow")
lm.install(library, silent=silent, force=force)

if save and installed_pkgs:
_save_deps(ctx, installed_pkgs)
Expand Down
9 changes: 5 additions & 4 deletions platformio/commands/lib/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ def get_builtin_libs(storage_names=None):
return items


def is_builtin_lib(storages, name):
for storage in storages or []:
if any(lib.get("name") == name for lib in storage["items"]):
return True
def is_builtin_lib(name, storages=None):
for storage in storages or get_builtin_libs():
for lib in storage["items"]:
if lib.get("name") == name:
return True
return False


Expand Down
Loading

0 comments on commit 65297c2

Please sign in to comment.