Initial support for non-ascii locales

This commit is contained in:
Ivan Kravets
2017-11-02 23:14:32 +02:00
parent f85202d64c
commit b670ab4888
9 changed files with 31 additions and 31 deletions

2
docs

Submodule docs updated: 1ceb1ce707...06258ad914

View File

@@ -170,7 +170,8 @@ if "envdump" in COMMAND_LINE_TARGETS:
if "idedata" in COMMAND_LINE_TARGETS:
try:
print "\n%s\n" % json.dumps(env.DumpIDEData())
print "\n%s\n" % util.path_to_unicode(
json.dumps(env.DumpIDEData(), ensure_ascii=False))
env.Exit(0)
except UnicodeDecodeError:
sys.stderr.write(

View File

@@ -64,8 +64,8 @@ def dump_defines(env):
# special symbol for Atmel AVR MCU
if env['PIOPLATFORM'] == "atmelavr":
defines.append(
"__AVR_%s__" % env.BoardConfig().get("build.mcu").upper()
.replace("ATMEGA", "ATmega").replace("ATTINY", "ATtiny"))
str("__AVR_%s__" % env.BoardConfig().get("build.mcu").upper()
.replace("ATMEGA", "ATmega").replace("ATTINY", "ATtiny")))
return defines

View File

@@ -20,8 +20,12 @@ from platformio.managers.core import pioplus_call
@click.command("home", short_help="PIO Home")
@click.option("--port", type=int, default=8008, help="HTTP port, default=8008")
@click.option(
"--port", "-p", type=int, default=8008, help="HTTP port, default=8008")
"--host",
default="127.0.0.1",
help="HTTP host, default=127.0.0.1. "
"You can open PIO Home for inbound connections with --host=0.0.0.0")
@click.option("--no-open", is_flag=True)
def cli(*args, **kwargs): # pylint: disable=unused-argument
pioplus_call(sys.argv[1:])

View File

@@ -15,7 +15,7 @@
from email.utils import parsedate_tz
from math import ceil
from os.path import getsize, join
from sys import version_info
from sys import getfilesystemencoding, version_info
from time import mktime
import click
@@ -53,7 +53,8 @@ class FileDownloader(object):
self._progressbar = None
self._destination = self._fname
if dest_dir:
self.set_destination(join(dest_dir, self._fname))
self.set_destination(
join(dest_dir.decode(getfilesystemencoding()), self._fname))
def set_destination(self, destination):
self._destination = destination

View File

@@ -15,11 +15,10 @@
import json
import os
import re
from cStringIO import StringIO
from os.path import abspath, basename, expanduser, isdir, isfile, join, relpath
import bottle
import click
from click.testing import CliRunner
from platformio import exception, util
from platformio.commands.run import cli as cmd_run
@@ -65,19 +64,18 @@ class ProjectGenerator(object):
if not envdata:
return data
out = StringIO()
with util.capture_stdout(out):
click.get_current_context().invoke(
cmd_run,
project_dir=self.project_dir,
environment=[envdata['env_name']],
target=["idedata"])
result = out.getvalue()
result = CliRunner().invoke(cmd_run, [
"--project-dir", self.project_dir, "--environment",
envdata['env_name'], "--target", "idedata"
])
if '"includes":' not in result:
raise exception.PlatformioException(result)
if result.exit_code != 0 and not isinstance(result.exception,
exception.ReturnErrorCode):
raise result.exception
if '"includes":' not in result.output:
raise exception.PlatformioException(result.output)
for line in result.split("\n"):
for line in result.output.split("\n"):
line = line.strip()
if line.startswith('{"') and line.endswith("}"):
data = json.loads(line)

View File

@@ -21,9 +21,9 @@ from platformio import __version__, exception, util
from platformio.managers.package import PackageManager
CORE_PACKAGES = {
"contrib-piohome": ">=0.3.0,<2",
"contrib-piohome": ">=0.3.2,<2",
"pysite-pioplus": ">=0.4.2,<2",
"tool-pioplus": ">=0.10.10,<2",
"tool-pioplus": ">=0.10.13,<2",
"tool-unity": "~1.20302.1",
"tool-scons": "~3.20501.2"
}

View File

@@ -18,6 +18,7 @@ import json
import os
import re
import shutil
import sys
from os.path import basename, getsize, isdir, isfile, islink, join
from tempfile import mkdtemp
@@ -195,7 +196,7 @@ class PkgInstallerMixin(object):
name = re.sub(r"[^\da-z\_\-\. ]", "_", manifest['name'], flags=re.I)
if "id" in manifest:
name += "_ID%d" % manifest['id']
return name
return str(name)
def get_src_manifest_path(self, pkg_dir):
if not isdir(pkg_dir):
@@ -258,7 +259,7 @@ class PkgInstallerMixin(object):
if "version" not in manifest:
manifest['version'] = "0.0.0"
manifest['__pkg_dir'] = pkg_dir
manifest['__pkg_dir'] = util.path_to_unicode(pkg_dir)
self.cache_set(cache_key, manifest)
return manifest

View File

@@ -21,7 +21,6 @@ import re
import stat
import subprocess
import sys
from contextlib import contextmanager
from functools import wraps
from glob import glob
from os.path import (abspath, basename, dirname, expanduser, isdir, isfile,
@@ -180,12 +179,8 @@ def singleton(cls):
return get_instance
@contextmanager
def capture_stdout(output):
stdout = sys.stdout
sys.stdout = output
yield
sys.stdout = stdout
def path_to_unicode(path):
return path.decode(sys.getfilesystemencoding()).encode("utf-8")
def load_json(file_path):