forked from platformio/platformio-core
@@ -44,7 +44,7 @@ def device_list( # pylint: disable=too-many-branches
|
||||
if mdns:
|
||||
data['mdns'] = util.get_mdns_services()
|
||||
|
||||
single_key = data.keys()[0] if len(data.keys()) == 1 else None
|
||||
single_key = list(data)[0] if len(list(data)) == 1 else None
|
||||
|
||||
if json_output:
|
||||
return click.echo(json.dumps(data[single_key] if single_key else data))
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
import json
|
||||
import time
|
||||
from os.path import isdir, join
|
||||
from urllib import quote
|
||||
|
||||
import click
|
||||
|
||||
@@ -25,6 +24,11 @@ from platformio import exception, util
|
||||
from platformio.managers.lib import LibraryManager, get_builtin_libs
|
||||
from platformio.util import get_api_result
|
||||
|
||||
try:
|
||||
from urllib.parse import quote
|
||||
except ImportError:
|
||||
from urllib import quote
|
||||
|
||||
|
||||
@click.group(short_help="Library Manager")
|
||||
@click.option(
|
||||
@@ -142,9 +146,9 @@ def lib_update(lm, libraries, only_check, json_output):
|
||||
manifest['versionLatest'] = latest
|
||||
result.append(manifest)
|
||||
return click.echo(json.dumps(result))
|
||||
else:
|
||||
for library in libraries:
|
||||
lm.update(library, only_check=only_check)
|
||||
|
||||
for library in libraries:
|
||||
lm.update(library, only_check=only_check)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ def _original_version(version):
|
||||
return None
|
||||
if len(y) % 2 != 0:
|
||||
y = "0" + y
|
||||
parts = [str(int(y[i * 2:i * 2 + 2])) for i in range(len(y) / 2)]
|
||||
parts = [str(int(y[i * 2:i * 2 + 2])) for i in range(int(len(y) / 2))]
|
||||
return ".".join(parts)
|
||||
|
||||
|
||||
@@ -88,8 +88,8 @@ def _get_installed_platform_data(platform,
|
||||
docs=p.docs_url,
|
||||
license=p.license,
|
||||
forDesktop=not p.is_embedded(),
|
||||
frameworks=sorted(p.frameworks.keys() if p.frameworks else []),
|
||||
packages=p.packages.keys() if p.packages else [])
|
||||
frameworks=sorted(list(p.frameworks) if p.frameworks else []),
|
||||
packages=list(p.packages) if p.packages else [])
|
||||
|
||||
# if dump to API
|
||||
# del data['version']
|
||||
@@ -374,15 +374,14 @@ def platform_update(platforms, only_packages, only_check, json_output):
|
||||
data['versionLatest'] = latest
|
||||
result.append(data)
|
||||
return click.echo(json.dumps(result))
|
||||
else:
|
||||
# cleanup cached board and platform lists
|
||||
app.clean_cache()
|
||||
for platform in platforms:
|
||||
click.echo("Platform %s" % click.style(
|
||||
pkg_dir_to_name.get(platform, platform), fg="cyan"))
|
||||
click.echo("--------")
|
||||
pm.update(
|
||||
platform, only_packages=only_packages, only_check=only_check)
|
||||
click.echo()
|
||||
|
||||
# cleanup cached board and platform lists
|
||||
app.clean_cache()
|
||||
for platform in platforms:
|
||||
click.echo("Platform %s" % click.style(
|
||||
pkg_dir_to_name.get(platform, platform), fg="cyan"))
|
||||
click.echo("--------")
|
||||
pm.update(platform, only_packages=only_packages, only_check=only_check)
|
||||
click.echo()
|
||||
|
||||
return True
|
||||
|
||||
@@ -357,7 +357,7 @@ def _clean_build_dir(build_dir):
|
||||
def print_header(label, is_error=False):
|
||||
terminal_width, _ = click.get_terminal_size()
|
||||
width = len(click.unstyle(label))
|
||||
half_line = "=" * ((terminal_width - width - 2) / 2)
|
||||
half_line = "=" * int((terminal_width - width - 2) / 2)
|
||||
click.echo("%s %s %s" % (half_line, label, half_line), err=is_error)
|
||||
|
||||
|
||||
@@ -394,7 +394,7 @@ def print_summary(results, start_time):
|
||||
def check_project_defopts(config):
|
||||
if not config.has_section("platformio"):
|
||||
return True
|
||||
unknown = set([k for k, _ in config.items("platformio")]) - set(
|
||||
unknown = set(k for k, _ in config.items("platformio")) - set(
|
||||
EnvironmentProcessor.KNOWN_PLATFORMIO_OPTIONS)
|
||||
if not unknown:
|
||||
return True
|
||||
@@ -409,7 +409,7 @@ def check_project_envs(config, environments=None):
|
||||
if not config.sections():
|
||||
raise exception.ProjectEnvsNotAvailable()
|
||||
|
||||
known = set([s[4:] for s in config.sections() if s.startswith("env:")])
|
||||
known = set(s[4:] for s in config.sections() if s.startswith("env:"))
|
||||
unknown = set(environments or []) - known
|
||||
if unknown:
|
||||
raise exception.UnknownEnvNames(", ".join(unknown), ", ".join(known))
|
||||
@@ -432,4 +432,5 @@ def calculate_project_hash():
|
||||
# Fix issue with useless project rebuilding for case insensitive FS.
|
||||
# A case of disk drive can differ...
|
||||
chunks_to_str = chunks_to_str.lower()
|
||||
return sha1(chunks_to_str).hexdigest()
|
||||
return sha1(chunks_to_str if util.PY2 else chunks_to_str.
|
||||
encode()).hexdigest()
|
||||
|
||||
Reference in New Issue
Block a user