mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Format code with pep8 style
This commit is contained in:
2
.style.yapf
Normal file
2
.style.yapf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[style]
|
||||||
|
blank_line_before_nested_class_or_def = true
|
7
Makefile
7
Makefile
@ -4,6 +4,13 @@ lint:
|
|||||||
|
|
||||||
isort:
|
isort:
|
||||||
isort -rc ./platformio
|
isort -rc ./platformio
|
||||||
|
isort -rc ./tests
|
||||||
|
isort -rc ./scripts
|
||||||
|
|
||||||
|
yapf:
|
||||||
|
yapf --recursive --in-place platformio/
|
||||||
|
|
||||||
|
before-commit: isort yapf pylint
|
||||||
|
|
||||||
clean-docs:
|
clean-docs:
|
||||||
rm -rf docs/_build
|
rm -rf docs/_build
|
||||||
|
@ -18,12 +18,10 @@ VERSION = (3, 0, "0.dev18")
|
|||||||
__version__ = ".".join([str(s) for s in VERSION])
|
__version__ = ".".join([str(s) for s in VERSION])
|
||||||
|
|
||||||
__title__ = "platformio"
|
__title__ = "platformio"
|
||||||
__description__ = (
|
__description__ = ("An open source ecosystem for IoT development. "
|
||||||
"An open source ecosystem for IoT development. "
|
"Cross-platform build system and library manager. "
|
||||||
"Cross-platform build system and library manager. "
|
"Continuous and IDE integration. "
|
||||||
"Continuous and IDE integration. "
|
"Arduino and MBED compatible. Ready for Cloud compiling.")
|
||||||
"Arduino and MBED compatible. Ready for Cloud compiling."
|
|
||||||
)
|
|
||||||
__url__ = "http://platformio.org"
|
__url__ = "http://platformio.org"
|
||||||
|
|
||||||
__author__ = "Ivan Kravets"
|
__author__ = "Ivan Kravets"
|
||||||
@ -35,7 +33,6 @@ __copyright__ = "Copyright 2014-2016 Ivan Kravets"
|
|||||||
__apiurl__ = "http://api.platformio.org"
|
__apiurl__ = "http://api.platformio.org"
|
||||||
__apiip__ = "198.7.57.247"
|
__apiip__ = "198.7.57.247"
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info < (2, 7, 0) or sys.version_info >= (3, 0, 0):
|
if sys.version_info < (2, 7, 0) or sys.version_info >= (3, 0, 0):
|
||||||
msg = ("PlatformIO version %s does not run under Python version %s.\n"
|
msg = ("PlatformIO version %s does not run under Python version %s.\n"
|
||||||
"Python 3 is not yet supported.\n")
|
"Python 3 is not yet supported.\n")
|
||||||
|
@ -40,8 +40,8 @@ class PlatformioCLI(click.MultiCommand): # pylint: disable=R0904
|
|||||||
def get_command(self, ctx, name):
|
def get_command(self, ctx, name):
|
||||||
mod = None
|
mod = None
|
||||||
try:
|
try:
|
||||||
mod = __import__("platformio.commands." + name,
|
mod = __import__("platformio.commands." + name, None, None,
|
||||||
None, None, ["cli"])
|
["cli"])
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
return self._handle_obsolate_command(name)
|
return self._handle_obsolate_command(name)
|
||||||
@ -57,11 +57,15 @@ class PlatformioCLI(click.MultiCommand): # pylint: disable=R0904
|
|||||||
raise AttributeError()
|
raise AttributeError()
|
||||||
|
|
||||||
|
|
||||||
@click.command(cls=PlatformioCLI,
|
@click.command(
|
||||||
context_settings=dict(help_option_names=["-h", "--help"]))
|
cls=PlatformioCLI,
|
||||||
|
context_settings=dict(help_option_names=["-h", "--help"]))
|
||||||
@click.version_option(__version__, prog_name="PlatformIO")
|
@click.version_option(__version__, prog_name="PlatformIO")
|
||||||
@click.option("--force", "-f", is_flag=True,
|
@click.option(
|
||||||
help="Force to accept any confirmation prompts.")
|
"--force",
|
||||||
|
"-f",
|
||||||
|
is_flag=True,
|
||||||
|
help="Force to accept any confirmation prompts.")
|
||||||
@click.option("--caller", "-c", help="Caller ID (service).")
|
@click.option("--caller", "-c", help="Caller ID (service).")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def cli(ctx, force, caller):
|
def cli(ctx, force, caller):
|
||||||
|
@ -49,28 +49,23 @@ DEFAULT_SETTINGS = {
|
|||||||
"value": False
|
"value": False
|
||||||
},
|
},
|
||||||
"enable_telemetry": {
|
"enable_telemetry": {
|
||||||
"description": (
|
"description":
|
||||||
"Telemetry service <http://docs.platformio.org/en/stable/"
|
("Telemetry service <http://docs.platformio.org/en/stable/"
|
||||||
"userguide/cmd_settings.html?#enable-telemetry> (Yes/No)"),
|
"userguide/cmd_settings.html?#enable-telemetry> (Yes/No)"),
|
||||||
"value": True
|
"value": True
|
||||||
},
|
},
|
||||||
"enable_prompts": {
|
"enable_prompts": {
|
||||||
"description": (
|
"description":
|
||||||
"Can PlatformIO communicate with you via prompts: "
|
("Can PlatformIO communicate with you via prompts: "
|
||||||
"propose to install platforms which aren't installed yet, "
|
"propose to install platforms which aren't installed yet, "
|
||||||
"paginate over library search results and etc.)? ATTENTION!!! "
|
"paginate over library search results and etc.)? ATTENTION!!! "
|
||||||
"If you call PlatformIO like subprocess, "
|
"If you call PlatformIO like subprocess, "
|
||||||
"please disable prompts to avoid blocking (Yes/No)"),
|
"please disable prompts to avoid blocking (Yes/No)"),
|
||||||
"value": True
|
"value": True
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SESSION_VARS = {"command_ctx": None, "force_option": False, "caller_id": None}
|
||||||
SESSION_VARS = {
|
|
||||||
"command_ctx": None,
|
|
||||||
"force_option": False,
|
|
||||||
"caller_id": None
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class State(object):
|
class State(object):
|
||||||
@ -108,8 +103,8 @@ class State(object):
|
|||||||
return
|
return
|
||||||
self._lockfile = LockFile(self.path)
|
self._lockfile = LockFile(self.path)
|
||||||
|
|
||||||
if (self._lockfile.is_locked() and
|
if self._lockfile.is_locked() and \
|
||||||
(time() - getmtime(self._lockfile.lock_file)) > 10):
|
(time() - getmtime(self._lockfile.lock_file)) > 10:
|
||||||
self._lockfile.break_lock()
|
self._lockfile.break_lock()
|
||||||
|
|
||||||
self._lockfile.acquire()
|
self._lockfile.acquire()
|
||||||
|
@ -43,7 +43,7 @@ def generate(env):
|
|||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
_huge_sources_hook=_huge_sources_hook,
|
_huge_sources_hook=_huge_sources_hook,
|
||||||
ARCOM=env.get("ARCOM", "").replace(
|
ARCOM=env.get("ARCOM", "").replace("$SOURCES",
|
||||||
"$SOURCES", "${_huge_sources_hook(SOURCES)}"))
|
"${_huge_sources_hook(SOURCES)}"))
|
||||||
|
|
||||||
return env
|
return env
|
||||||
|
@ -25,15 +25,12 @@ from platformio import util
|
|||||||
|
|
||||||
class InoToCPPConverter(object):
|
class InoToCPPConverter(object):
|
||||||
|
|
||||||
PROTOTYPE_RE = re.compile(
|
PROTOTYPE_RE = re.compile(r"""^(
|
||||||
r"""^(
|
|
||||||
(\s*[a-z_\d]+\*?){1,2} # return type
|
(\s*[a-z_\d]+\*?){1,2} # return type
|
||||||
(\s+[a-z_\d]+\s*) # name of prototype
|
(\s+[a-z_\d]+\s*) # name of prototype
|
||||||
\([a-z_,\.\*\&\[\]\s\d]*\) # arguments
|
\([a-z_,\.\*\&\[\]\s\d]*\) # arguments
|
||||||
)\s*\{ # must end with {
|
)\s*\{ # must end with {
|
||||||
""",
|
""", re.X | re.M | re.I)
|
||||||
re.X | re.M | re.I
|
|
||||||
)
|
|
||||||
DETECTMAIN_RE = re.compile(r"void\s+(setup|loop)\s*\(", re.M | re.I)
|
DETECTMAIN_RE = re.compile(r"void\s+(setup|loop)\s*\(", re.M | re.I)
|
||||||
PROTOPTRS_TPLRE = r"\([^&\(]*&(%s)[^\)]*\)"
|
PROTOPTRS_TPLRE = r"\([^&\(]*&(%s)[^\)]*\)"
|
||||||
|
|
||||||
@ -66,20 +63,18 @@ class InoToCPPConverter(object):
|
|||||||
split_pos = item['match'].start()
|
split_pos = item['match'].start()
|
||||||
break
|
break
|
||||||
|
|
||||||
match_ptrs = re.search(
|
match_ptrs = re.search(self.PROTOPTRS_TPLRE %
|
||||||
self.PROTOPTRS_TPLRE % ("|".join(prototype_names)),
|
("|".join(prototype_names)),
|
||||||
contents[:split_pos],
|
contents[:split_pos], re.M)
|
||||||
re.M
|
|
||||||
)
|
|
||||||
if match_ptrs:
|
if match_ptrs:
|
||||||
split_pos = contents.rfind("\n", 0, match_ptrs.start())
|
split_pos = contents.rfind("\n", 0, match_ptrs.start())
|
||||||
|
|
||||||
result.append(contents[:split_pos].strip())
|
result.append(contents[:split_pos].strip())
|
||||||
result.append("%s;" %
|
result.append("%s;" %
|
||||||
";\n".join([p['match'].group(1) for p in prototypes]))
|
";\n".join([p['match'].group(1) for p in prototypes]))
|
||||||
result.append('#line %d "%s"' % (
|
result.append('#line %d "%s"' %
|
||||||
contents.count("\n", 0, split_pos) + 2,
|
(contents.count("\n", 0, split_pos) + 2,
|
||||||
file_path.replace("\\", "/")))
|
file_path.replace("\\", "/")))
|
||||||
result.append(contents[split_pos:].strip())
|
result.append(contents[split_pos:].strip())
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@ -106,8 +101,8 @@ class InoToCPPConverter(object):
|
|||||||
result.append('#line 1 "%s"' % file_path.replace("\\", "/"))
|
result.append('#line 1 "%s"' % file_path.replace("\\", "/"))
|
||||||
|
|
||||||
if is_first and prototypes:
|
if is_first and prototypes:
|
||||||
result += self.append_prototypes(
|
result += self.append_prototypes(file_path, contents,
|
||||||
file_path, contents, prototypes)
|
prototypes)
|
||||||
else:
|
else:
|
||||||
result.append(contents)
|
result.append(contents)
|
||||||
is_first = False
|
is_first = False
|
||||||
@ -187,9 +182,7 @@ def DumpIDEData(env):
|
|||||||
if env['PIOPLATFORM'] == "atmelavr":
|
if env['PIOPLATFORM'] == "atmelavr":
|
||||||
defines.append(
|
defines.append(
|
||||||
"__AVR_%s__" % env.BoardConfig().get("build.mcu").upper()
|
"__AVR_%s__" % env.BoardConfig().get("build.mcu").upper()
|
||||||
.replace("ATMEGA", "ATmega")
|
.replace("ATMEGA", "ATmega").replace("ATTINY", "ATtiny"))
|
||||||
.replace("ATTINY", "ATtiny")
|
|
||||||
)
|
|
||||||
return defines
|
return defines
|
||||||
|
|
||||||
LINTCCOM = "$CFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS"
|
LINTCCOM = "$CFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS"
|
||||||
@ -257,8 +250,8 @@ def GetActualLDScript(env):
|
|||||||
return path
|
return path
|
||||||
|
|
||||||
if script:
|
if script:
|
||||||
env.Exit("Error: Could not find '%s' LD script in LDPATH '%s'" % (
|
env.Exit("Error: Could not find '%s' LD script in LDPATH '%s'" %
|
||||||
script, env.subst("$LIBPATH")))
|
(script, env.subst("$LIBPATH")))
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -89,9 +89,7 @@ def LoadPioPlatform(env, variables):
|
|||||||
env.Replace(**{k: board_config.get("%s.%s" % (_opt, _val))})
|
env.Replace(**{k: board_config.get("%s.%s" % (_opt, _val))})
|
||||||
|
|
||||||
if "build.ldscript" in board_config:
|
if "build.ldscript" in board_config:
|
||||||
env.Replace(
|
env.Replace(LDSCRIPT_PATH=board_config.get("build.ldscript"))
|
||||||
LDSCRIPT_PATH=board_config.get("build.ldscript")
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def exists(_):
|
def exists(_):
|
||||||
|
@ -28,7 +28,6 @@ FRAMEWORK_PARAMETERS = {
|
|||||||
"serial_begin": "Serial.begin(9600)",
|
"serial_begin": "Serial.begin(9600)",
|
||||||
"serial_end": "Serial.end()"
|
"serial_end": "Serial.end()"
|
||||||
},
|
},
|
||||||
|
|
||||||
"mbed": {
|
"mbed": {
|
||||||
"framework": "mbed.h",
|
"framework": "mbed.h",
|
||||||
"serial_obj": "Serial pc(USBTX, USBRX);",
|
"serial_obj": "Serial pc(USBTX, USBRX);",
|
||||||
@ -37,7 +36,6 @@ FRAMEWORK_PARAMETERS = {
|
|||||||
"serial_begin": "pc.baud(9600)",
|
"serial_begin": "pc.baud(9600)",
|
||||||
"serial_end": ""
|
"serial_end": ""
|
||||||
},
|
},
|
||||||
|
|
||||||
"energia": {
|
"energia": {
|
||||||
"framework": "Energia.h",
|
"framework": "Energia.h",
|
||||||
"serial_obj": "",
|
"serial_obj": "",
|
||||||
@ -52,19 +50,14 @@ FRAMEWORK_PARAMETERS = {
|
|||||||
def ProcessTest(env):
|
def ProcessTest(env):
|
||||||
env.Append(
|
env.Append(
|
||||||
CPPDEFINES=[
|
CPPDEFINES=[
|
||||||
"UNIT_TEST",
|
"UNIT_TEST", "UNITY_INCLUDE_CONFIG_H"
|
||||||
"UNITY_INCLUDE_CONFIG_H"
|
|
||||||
],
|
],
|
||||||
|
|
||||||
CPPPATH=[
|
CPPPATH=[
|
||||||
join("$BUILD_DIR", "UnityTestLib")
|
join("$BUILD_DIR", "UnityTestLib")
|
||||||
]
|
])
|
||||||
)
|
|
||||||
unitylib = env.BuildLibrary(
|
unitylib = env.BuildLibrary(
|
||||||
join("$BUILD_DIR", "UnityTestLib"),
|
join("$BUILD_DIR", "UnityTestLib"),
|
||||||
env.PioPlatform().get_package_dir("tool-unity")
|
env.PioPlatform().get_package_dir("tool-unity"))
|
||||||
|
|
||||||
)
|
|
||||||
env.Prepend(LIBS=[unitylib])
|
env.Prepend(LIBS=[unitylib])
|
||||||
|
|
||||||
test_dir = env.subst("$PROJECTTEST_DIR")
|
test_dir = env.subst("$PROJECTTEST_DIR")
|
||||||
@ -75,8 +68,7 @@ def ProcessTest(env):
|
|||||||
src_filter += " +<%s%s>" % (env['PIOTEST'], sep)
|
src_filter += " +<%s%s>" % (env['PIOTEST'], sep)
|
||||||
|
|
||||||
return env.CollectBuildFiles(
|
return env.CollectBuildFiles(
|
||||||
"$BUILDTEST_DIR", test_dir, src_filter=src_filter, duplicate=False
|
"$BUILDTEST_DIR", test_dir, src_filter=src_filter, duplicate=False)
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def GenerateOutputReplacement(env, destination_dir):
|
def GenerateOutputReplacement(env, destination_dir):
|
||||||
@ -124,11 +116,11 @@ void output_complete(void)
|
|||||||
|
|
||||||
framework = env.subst("$PIOFRAMEWORK").lower()
|
framework = env.subst("$PIOFRAMEWORK").lower()
|
||||||
if framework not in FRAMEWORK_PARAMETERS:
|
if framework not in FRAMEWORK_PARAMETERS:
|
||||||
env.Exit(
|
env.Exit("Error: %s framework doesn't support testing feature!" %
|
||||||
"Error: %s framework doesn't support testing feature!" % framework)
|
framework)
|
||||||
else:
|
else:
|
||||||
data = Template(TEMPLATECPP).substitute(
|
data = Template(TEMPLATECPP).substitute(FRAMEWORK_PARAMETERS[
|
||||||
FRAMEWORK_PARAMETERS[framework])
|
framework])
|
||||||
|
|
||||||
tmp_file = join(destination_dir, "output_export.cpp")
|
tmp_file = join(destination_dir, "output_export.cpp")
|
||||||
with open(tmp_file, "w") as f:
|
with open(tmp_file, "w") as f:
|
||||||
|
@ -120,8 +120,7 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument
|
|||||||
"\nWarning! Please install `99-platformio-udev.rules` and "
|
"\nWarning! Please install `99-platformio-udev.rules` and "
|
||||||
"check that your board's PID and VID are listed in the rules."
|
"check that your board's PID and VID are listed in the rules."
|
||||||
"\n https://raw.githubusercontent.com/platformio/platformio"
|
"\n https://raw.githubusercontent.com/platformio/platformio"
|
||||||
"/develop/scripts/99-platformio-udev.rules\n"
|
"/develop/scripts/99-platformio-udev.rules\n")
|
||||||
)
|
|
||||||
env.Replace(UPLOAD_PORT=_look_for_serial_port())
|
env.Replace(UPLOAD_PORT=_look_for_serial_port())
|
||||||
|
|
||||||
if env.subst("$UPLOAD_PORT"):
|
if env.subst("$UPLOAD_PORT"):
|
||||||
|
@ -32,18 +32,14 @@ SRC_FILTER_DEFAULT = ["+<*>", "-<.git%s>" % sep, "-<svn%s>" % sep]
|
|||||||
def BuildProgram(env):
|
def BuildProgram(env):
|
||||||
|
|
||||||
def _append_pio_macros():
|
def _append_pio_macros():
|
||||||
env.AppendUnique(
|
env.AppendUnique(CPPDEFINES=["PLATFORMIO={0:02d}{1:02d}{2:02d}".format(
|
||||||
CPPDEFINES=["PLATFORMIO={0:02d}{1:02d}{2:02d}".format(
|
*pioversion_to_intstr())])
|
||||||
*pioversion_to_intstr())])
|
|
||||||
|
|
||||||
_append_pio_macros()
|
_append_pio_macros()
|
||||||
|
|
||||||
# fix ASM handling under non-casitive OS
|
# fix ASM handling under non-casitive OS
|
||||||
if not case_sensitive_suffixes(".s", ".S"):
|
if not case_sensitive_suffixes(".s", ".S"):
|
||||||
env.Replace(
|
env.Replace(AS="$CC", ASCOM="$ASPPCOM")
|
||||||
AS="$CC",
|
|
||||||
ASCOM="$ASPPCOM"
|
|
||||||
)
|
|
||||||
|
|
||||||
# process extra flags from board
|
# process extra flags from board
|
||||||
if "BOARD" in env and "build.extra_flags" in env.BoardConfig():
|
if "BOARD" in env and "build.extra_flags" in env.BoardConfig():
|
||||||
@ -55,7 +51,8 @@ def BuildProgram(env):
|
|||||||
|
|
||||||
if env.get("PIOFRAMEWORK"):
|
if env.get("PIOFRAMEWORK"):
|
||||||
env.BuildFrameworks([
|
env.BuildFrameworks([
|
||||||
f.lower().strip() for f in env['PIOFRAMEWORK'].split(",")])
|
f.lower().strip() for f in env['PIOFRAMEWORK'].split(",")
|
||||||
|
])
|
||||||
|
|
||||||
# restore PIO macros if it was deleted by framework
|
# restore PIO macros if it was deleted by framework
|
||||||
_append_pio_macros()
|
_append_pio_macros()
|
||||||
@ -66,18 +63,12 @@ def BuildProgram(env):
|
|||||||
# append specified LD_SCRIPT
|
# append specified LD_SCRIPT
|
||||||
if ("LDSCRIPT_PATH" in env and
|
if ("LDSCRIPT_PATH" in env and
|
||||||
not any(["-Wl,-T" in f for f in env['LINKFLAGS']])):
|
not any(["-Wl,-T" in f for f in env['LINKFLAGS']])):
|
||||||
env.Append(
|
env.Append(LINKFLAGS=['-Wl,-T"$LDSCRIPT_PATH"'])
|
||||||
LINKFLAGS=['-Wl,-T"$LDSCRIPT_PATH"']
|
|
||||||
)
|
|
||||||
|
|
||||||
# enable "cyclic reference" for linker
|
# enable "cyclic reference" for linker
|
||||||
if env.get("LIBS", deplibs) and env.GetCompilerType() == "gcc":
|
if env.get("LIBS", deplibs) and env.GetCompilerType() == "gcc":
|
||||||
env.Prepend(
|
env.Prepend(_LIBFLAGS="-Wl,--start-group ")
|
||||||
_LIBFLAGS="-Wl,--start-group "
|
env.Append(_LIBFLAGS=" -Wl,--end-group")
|
||||||
)
|
|
||||||
env.Append(
|
|
||||||
_LIBFLAGS=" -Wl,--end-group"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Handle SRC_BUILD_FLAGS
|
# Handle SRC_BUILD_FLAGS
|
||||||
env.ProcessFlags(env.get("SRC_BUILD_FLAGS"))
|
env.ProcessFlags(env.get("SRC_BUILD_FLAGS"))
|
||||||
@ -96,14 +87,11 @@ def BuildProgram(env):
|
|||||||
env.Append(PIOBUILDFILES=env.ProcessTest())
|
env.Append(PIOBUILDFILES=env.ProcessTest())
|
||||||
|
|
||||||
if not env['PIOBUILDFILES'] and not COMMAND_LINE_TARGETS:
|
if not env['PIOBUILDFILES'] and not COMMAND_LINE_TARGETS:
|
||||||
env.Exit(
|
env.Exit("Error: Nothing to build. Please put your source code files "
|
||||||
"Error: Nothing to build. Please put your source code files "
|
"to '%s' folder" % env.subst("$PROJECTSRC_DIR"))
|
||||||
"to '%s' folder" % env.subst("$PROJECTSRC_DIR"))
|
|
||||||
|
|
||||||
program = env.Program(
|
program = env.Program(
|
||||||
join("$BUILD_DIR", env.subst("$PROGNAME")),
|
join("$BUILD_DIR", env.subst("$PROGNAME")), env['PIOBUILDFILES'])
|
||||||
env['PIOBUILDFILES']
|
|
||||||
)
|
|
||||||
|
|
||||||
if set(["upload", "uploadlazy", "program"]) & set(COMMAND_LINE_TARGETS):
|
if set(["upload", "uploadlazy", "program"]) & set(COMMAND_LINE_TARGETS):
|
||||||
env.AddPostAction(program, env.CheckUploadSize)
|
env.AddPostAction(program, env.CheckUploadSize)
|
||||||
@ -210,8 +198,11 @@ def VariantDirWrap(env, variant_dir, src_dir, duplicate=False):
|
|||||||
env.VariantDir(variant_dir, src_dir, duplicate)
|
env.VariantDir(variant_dir, src_dir, duplicate)
|
||||||
|
|
||||||
|
|
||||||
def CollectBuildFiles(env, variant_dir, src_dir,
|
def CollectBuildFiles(env,
|
||||||
src_filter=None, duplicate=False):
|
variant_dir,
|
||||||
|
src_dir,
|
||||||
|
src_filter=None,
|
||||||
|
duplicate=False):
|
||||||
sources = []
|
sources = []
|
||||||
variants = []
|
variants = []
|
||||||
|
|
||||||
@ -239,9 +230,8 @@ def BuildFrameworks(env, frameworks):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if "BOARD" not in env:
|
if "BOARD" not in env:
|
||||||
env.Exit(
|
env.Exit("Please specify `board` in `platformio.ini` to use "
|
||||||
"Please specify `board` in `platformio.ini` to use "
|
"with '%s' framework" % ", ".join(frameworks))
|
||||||
"with '%s' framework" % ", ".join(frameworks))
|
|
||||||
|
|
||||||
board_frameworks = env.BoardConfig().get("frameworks", [])
|
board_frameworks = env.BoardConfig().get("frameworks", [])
|
||||||
if frameworks == ["platformio"]:
|
if frameworks == ["platformio"]:
|
||||||
|
@ -48,15 +48,21 @@ def cli(query, installed, json_output): # pylint: disable=R0912
|
|||||||
click.echo("Platform: ", nl=False)
|
click.echo("Platform: ", nl=False)
|
||||||
click.secho(platform, bold=True)
|
click.secho(platform, bold=True)
|
||||||
click.echo("-" * terminal_width)
|
click.echo("-" * terminal_width)
|
||||||
click.echo(BOARDLIST_TPL.format(
|
click.echo(
|
||||||
type=click.style("ID", fg="cyan"), mcu="MCU",
|
BOARDLIST_TPL.format(
|
||||||
frequency="Frequency", flash="Flash", ram="RAM", name="Name"))
|
type=click.style(
|
||||||
|
"ID", fg="cyan"),
|
||||||
|
mcu="MCU",
|
||||||
|
frequency="Frequency",
|
||||||
|
flash="Flash",
|
||||||
|
ram="RAM",
|
||||||
|
name="Name"))
|
||||||
click.echo("-" * terminal_width)
|
click.echo("-" * terminal_width)
|
||||||
|
|
||||||
for board in sorted(pboards, key=lambda b: b['id']):
|
for board in sorted(pboards, key=lambda b: b['id']):
|
||||||
if query:
|
if query:
|
||||||
search_data = "%s %s" % (
|
search_data = "%s %s" % (board['id'],
|
||||||
board['id'], json.dumps(board).lower())
|
json.dumps(board).lower())
|
||||||
if query.lower() not in search_data.lower():
|
if query.lower() not in search_data.lower():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -71,11 +77,15 @@ def cli(query, installed, json_output): # pylint: disable=R0912
|
|||||||
else:
|
else:
|
||||||
ram_size = "%dB" % ram_size
|
ram_size = "%dB" % ram_size
|
||||||
|
|
||||||
click.echo(BOARDLIST_TPL.format(
|
click.echo(
|
||||||
type=click.style(board['id'], fg="cyan"),
|
BOARDLIST_TPL.format(
|
||||||
mcu=board['mcu'],
|
type=click.style(
|
||||||
frequency="%dMhz" % (board['fcpu'] / 1000000),
|
board['id'], fg="cyan"),
|
||||||
flash=flash_size, ram=ram_size, name=board['name']))
|
mcu=board['mcu'],
|
||||||
|
frequency="%dMhz" % (board['fcpu'] / 1000000),
|
||||||
|
flash=flash_size,
|
||||||
|
ram=ram_size,
|
||||||
|
name=board['name']))
|
||||||
|
|
||||||
|
|
||||||
def _get_boards(installed=False):
|
def _get_boards(installed=False):
|
||||||
|
@ -55,19 +55,37 @@ def validate_path(ctx, param, value): # pylint: disable=W0613
|
|||||||
@click.argument("src", nargs=-1, callback=validate_path)
|
@click.argument("src", nargs=-1, callback=validate_path)
|
||||||
@click.option("-l", "--lib", multiple=True, callback=validate_path)
|
@click.option("-l", "--lib", multiple=True, callback=validate_path)
|
||||||
@click.option("--exclude", multiple=True)
|
@click.option("--exclude", multiple=True)
|
||||||
@click.option("-b", "--board", multiple=True, metavar="ID",
|
@click.option(
|
||||||
callback=validate_boards)
|
"-b", "--board", multiple=True, metavar="ID", callback=validate_boards)
|
||||||
@click.option("--build-dir", default=mkdtemp,
|
@click.option(
|
||||||
type=click.Path(exists=True, file_okay=False, dir_okay=True,
|
"--build-dir",
|
||||||
writable=True, resolve_path=True))
|
default=mkdtemp,
|
||||||
|
type=click.Path(
|
||||||
|
exists=True,
|
||||||
|
file_okay=False,
|
||||||
|
dir_okay=True,
|
||||||
|
writable=True,
|
||||||
|
resolve_path=True))
|
||||||
@click.option("--keep-build-dir", is_flag=True)
|
@click.option("--keep-build-dir", is_flag=True)
|
||||||
@click.option("--project-conf",
|
@click.option(
|
||||||
type=click.Path(exists=True, file_okay=True, dir_okay=False,
|
"--project-conf",
|
||||||
readable=True, resolve_path=True))
|
type=click.Path(
|
||||||
|
exists=True,
|
||||||
|
file_okay=True,
|
||||||
|
dir_okay=False,
|
||||||
|
readable=True,
|
||||||
|
resolve_path=True))
|
||||||
@click.option("-v", "--verbose", is_flag=True)
|
@click.option("-v", "--verbose", is_flag=True)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def cli(ctx, src, lib, exclude, board, # pylint: disable=R0913
|
def cli(ctx, # pylint: disable=R0913
|
||||||
build_dir, keep_build_dir, project_conf, verbose):
|
src,
|
||||||
|
lib,
|
||||||
|
exclude,
|
||||||
|
board,
|
||||||
|
build_dir,
|
||||||
|
keep_build_dir,
|
||||||
|
project_conf,
|
||||||
|
verbose):
|
||||||
|
|
||||||
if not src:
|
if not src:
|
||||||
src = getenv("PLATFORMIO_CI_SRC", "").split(":")
|
src = getenv("PLATFORMIO_CI_SRC", "").split(":")
|
||||||
@ -102,9 +120,8 @@ def cli(ctx, src, lib, exclude, board, # pylint: disable=R0913
|
|||||||
finally:
|
finally:
|
||||||
if not keep_build_dir:
|
if not keep_build_dir:
|
||||||
rmtree(
|
rmtree(
|
||||||
build_dir, onerror=lambda action, name, exc:
|
build_dir,
|
||||||
(chmod(name, stat.S_IWRITE), remove(name))
|
onerror=lambda action, name, exc: (chmod(name, stat.S_IWRITE), remove(name)))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _clean_dir(dirpath):
|
def _clean_dir(dirpath):
|
||||||
@ -113,10 +130,7 @@ def _clean_dir(dirpath):
|
|||||||
|
|
||||||
|
|
||||||
def _copy_contents(dst_dir, contents):
|
def _copy_contents(dst_dir, contents):
|
||||||
items = {
|
items = {"dirs": set(), "files": set()}
|
||||||
"dirs": set(),
|
|
||||||
"files": set()
|
|
||||||
}
|
|
||||||
|
|
||||||
for path in contents:
|
for path in contents:
|
||||||
if isdir(path):
|
if isdir(path):
|
||||||
|
@ -37,24 +37,35 @@ def validate_boards(ctx, param, value): # pylint: disable=W0613
|
|||||||
assert not unknown_boards
|
assert not unknown_boards
|
||||||
return value
|
return value
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
raise click.BadParameter(
|
raise click.BadParameter("%s. Please search for the board ID using "
|
||||||
"%s. Please search for the board ID using "
|
"`platformio boards` command" %
|
||||||
"`platformio boards` command" % ", ".join(unknown_boards))
|
", ".join(unknown_boards))
|
||||||
|
|
||||||
|
|
||||||
@click.command("init", short_help="Initialize new PlatformIO based project")
|
@click.command("init", short_help="Initialize new PlatformIO based project")
|
||||||
@click.option("--project-dir", "-d", default=getcwd,
|
@click.option(
|
||||||
type=click.Path(exists=True, file_okay=False, dir_okay=True,
|
"--project-dir",
|
||||||
writable=True, resolve_path=True))
|
"-d",
|
||||||
@click.option("-b", "--board", multiple=True, metavar="ID",
|
default=getcwd,
|
||||||
callback=validate_boards)
|
type=click.Path(
|
||||||
@click.option("--ide",
|
exists=True,
|
||||||
type=click.Choice(ProjectGenerator.get_supported_ides()))
|
file_okay=False,
|
||||||
|
dir_okay=True,
|
||||||
|
writable=True,
|
||||||
|
resolve_path=True))
|
||||||
|
@click.option(
|
||||||
|
"-b", "--board", multiple=True, metavar="ID", callback=validate_boards)
|
||||||
|
@click.option(
|
||||||
|
"--ide", type=click.Choice(ProjectGenerator.get_supported_ides()))
|
||||||
@click.option("--enable-auto-uploading", is_flag=True)
|
@click.option("--enable-auto-uploading", is_flag=True)
|
||||||
@click.option("--env-prefix", default="")
|
@click.option("--env-prefix", default="")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def cli(ctx, project_dir, board, ide, # pylint: disable=R0913
|
def cli(ctx, # pylint: disable=R0913
|
||||||
enable_auto_uploading, env_prefix):
|
project_dir,
|
||||||
|
board,
|
||||||
|
ide,
|
||||||
|
enable_auto_uploading,
|
||||||
|
env_prefix):
|
||||||
|
|
||||||
if project_dir == getcwd():
|
if project_dir == getcwd():
|
||||||
click.secho("\nThe current working directory", fg="yellow", nl=False)
|
click.secho("\nThe current working directory", fg="yellow", nl=False)
|
||||||
@ -63,18 +74,20 @@ def cli(ctx, project_dir, board, ide, # pylint: disable=R0913
|
|||||||
"will be used for project.\n"
|
"will be used for project.\n"
|
||||||
"You can specify another project directory via\n"
|
"You can specify another project directory via\n"
|
||||||
"`platformio init -d %PATH_TO_THE_PROJECT_DIR%` command.",
|
"`platformio init -d %PATH_TO_THE_PROJECT_DIR%` command.",
|
||||||
fg="yellow"
|
fg="yellow")
|
||||||
)
|
|
||||||
click.echo("")
|
click.echo("")
|
||||||
|
|
||||||
click.echo("The next files/directories will be created in %s" %
|
click.echo("The next files/directories will be created in %s" %
|
||||||
click.style(project_dir, fg="cyan"))
|
click.style(
|
||||||
|
project_dir, fg="cyan"))
|
||||||
click.echo("%s - Project Configuration File. |-> PLEASE EDIT ME <-|" %
|
click.echo("%s - Project Configuration File. |-> PLEASE EDIT ME <-|" %
|
||||||
click.style("platformio.ini", fg="cyan"))
|
click.style(
|
||||||
click.echo("%s - Put your source files here" %
|
"platformio.ini", fg="cyan"))
|
||||||
click.style("src", fg="cyan"))
|
click.echo("%s - Put your source files here" % click.style(
|
||||||
|
"src", fg="cyan"))
|
||||||
click.echo("%s - Put here project specific (private) libraries" %
|
click.echo("%s - Put here project specific (private) libraries" %
|
||||||
click.style("lib", fg="cyan"))
|
click.style(
|
||||||
|
"lib", fg="cyan"))
|
||||||
|
|
||||||
if (app.get_setting("enable_prompts") and
|
if (app.get_setting("enable_prompts") and
|
||||||
not click.confirm("Do you want to continue?")):
|
not click.confirm("Do you want to continue?")):
|
||||||
@ -83,10 +96,8 @@ def cli(ctx, project_dir, board, ide, # pylint: disable=R0913
|
|||||||
init_base_project(project_dir)
|
init_base_project(project_dir)
|
||||||
|
|
||||||
if board:
|
if board:
|
||||||
fill_project_envs(
|
fill_project_envs(ctx, project_dir, board, enable_auto_uploading,
|
||||||
ctx, project_dir, board,
|
env_prefix, ide is not None)
|
||||||
enable_auto_uploading, env_prefix, ide is not None
|
|
||||||
)
|
|
||||||
|
|
||||||
if ide:
|
if ide:
|
||||||
if not board:
|
if not board:
|
||||||
@ -102,8 +113,7 @@ def cli(ctx, project_dir, board, ide, # pylint: disable=R0913
|
|||||||
"However, the IDE features (code autocompletion, syntax "
|
"However, the IDE features (code autocompletion, syntax "
|
||||||
"linter) have been configured for the first board '%s' from "
|
"linter) have been configured for the first board '%s' from "
|
||||||
"your list '%s'." % (board[0], ", ".join(board)),
|
"your list '%s'." % (board[0], ", ".join(board)),
|
||||||
fg="yellow"
|
fg="yellow")
|
||||||
)
|
|
||||||
pg = ProjectGenerator(project_dir, ide, board[0])
|
pg = ProjectGenerator(project_dir, ide, board[0])
|
||||||
pg.generate()
|
pg.generate()
|
||||||
|
|
||||||
@ -116,8 +126,7 @@ def cli(ctx, project_dir, board, ide, # pylint: disable=R0913
|
|||||||
"`platformio run --target clean` - clean project (remove compiled "
|
"`platformio run --target clean` - clean project (remove compiled "
|
||||||
"files)\n"
|
"files)\n"
|
||||||
"`platformio run --help` - additional information",
|
"`platformio run --help` - additional information",
|
||||||
fg="green"
|
fg="green")
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def get_first_board(project_dir):
|
def get_first_board(project_dir):
|
||||||
@ -132,8 +141,9 @@ def get_first_board(project_dir):
|
|||||||
|
|
||||||
def init_base_project(project_dir):
|
def init_base_project(project_dir):
|
||||||
if not util.is_platformio_project(project_dir):
|
if not util.is_platformio_project(project_dir):
|
||||||
copyfile(join(util.get_source_dir(), "projectconftpl.ini"),
|
copyfile(
|
||||||
join(project_dir, "platformio.ini"))
|
join(util.get_source_dir(), "projectconftpl.ini"),
|
||||||
|
join(project_dir, "platformio.ini"))
|
||||||
|
|
||||||
lib_dir = join(project_dir, "lib")
|
lib_dir = join(project_dir, "lib")
|
||||||
src_dir = join(project_dir, "src")
|
src_dir = join(project_dir, "src")
|
||||||
@ -275,8 +285,8 @@ def init_cvs_ignore(project_dir):
|
|||||||
|
|
||||||
|
|
||||||
def fill_project_envs( # pylint: disable=too-many-arguments,too-many-locals
|
def fill_project_envs( # pylint: disable=too-many-arguments,too-many-locals
|
||||||
ctx, project_dir, board_ids, enable_auto_uploading,
|
ctx, project_dir, board_ids, enable_auto_uploading, env_prefix,
|
||||||
env_prefix, force_download):
|
force_download):
|
||||||
installed_boards = PlatformManager().get_installed_boards()
|
installed_boards = PlatformManager().get_installed_boards()
|
||||||
content = []
|
content = []
|
||||||
used_boards = []
|
used_boards = []
|
||||||
@ -291,8 +301,8 @@ def fill_project_envs( # pylint: disable=too-many-arguments,too-many-locals
|
|||||||
|
|
||||||
for id_ in board_ids:
|
for id_ in board_ids:
|
||||||
manifest = None
|
manifest = None
|
||||||
for boards in (
|
for boards in (installed_boards,
|
||||||
installed_boards, PlatformManager.get_registered_boards()):
|
PlatformManager.get_registered_boards()):
|
||||||
for b in boards:
|
for b in boards:
|
||||||
if b['id'] == id_:
|
if b['id'] == id_:
|
||||||
manifest = b
|
manifest = b
|
||||||
@ -329,10 +339,10 @@ def fill_project_envs( # pylint: disable=too-many-arguments,too-many-locals
|
|||||||
|
|
||||||
def _install_dependent_platforms(ctx, platforms):
|
def _install_dependent_platforms(ctx, platforms):
|
||||||
installed_platforms = [
|
installed_platforms = [
|
||||||
p['name'] for p in PlatformManager().get_installed()]
|
p['name'] for p in PlatformManager().get_installed()
|
||||||
|
]
|
||||||
if set(platforms) <= set(installed_platforms):
|
if set(platforms) <= set(installed_platforms):
|
||||||
return
|
return
|
||||||
ctx.invoke(
|
ctx.invoke(
|
||||||
cli_platform_install,
|
cli_platform_install,
|
||||||
platforms=list(set(platforms) - set(installed_platforms))
|
platforms=list(set(platforms) - set(installed_platforms)))
|
||||||
)
|
|
||||||
|
@ -33,14 +33,26 @@ from platformio.managers.platform import PlatformFactory
|
|||||||
@click.option("-e", "--environment", multiple=True)
|
@click.option("-e", "--environment", multiple=True)
|
||||||
@click.option("-t", "--target", multiple=True)
|
@click.option("-t", "--target", multiple=True)
|
||||||
@click.option("--upload-port")
|
@click.option("--upload-port")
|
||||||
@click.option("-d", "--project-dir", default=getcwd,
|
@click.option(
|
||||||
type=click.Path(exists=True, file_okay=False, dir_okay=True,
|
"-d",
|
||||||
writable=True, resolve_path=True))
|
"--project-dir",
|
||||||
|
default=getcwd,
|
||||||
|
type=click.Path(
|
||||||
|
exists=True,
|
||||||
|
file_okay=False,
|
||||||
|
dir_okay=True,
|
||||||
|
writable=True,
|
||||||
|
resolve_path=True))
|
||||||
@click.option("-v", "--verbose", is_flag=True)
|
@click.option("-v", "--verbose", is_flag=True)
|
||||||
@click.option("--disable-auto-clean", is_flag=True)
|
@click.option("--disable-auto-clean", is_flag=True)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914
|
def cli(ctx, # pylint: disable=R0913,R0914
|
||||||
project_dir, verbose, disable_auto_clean):
|
environment,
|
||||||
|
target,
|
||||||
|
upload_port,
|
||||||
|
project_dir,
|
||||||
|
verbose,
|
||||||
|
disable_auto_clean):
|
||||||
assert check_project_envs(project_dir, environment)
|
assert check_project_envs(project_dir, environment)
|
||||||
with util.cd(project_dir):
|
with util.cd(project_dir):
|
||||||
# clean obsolete .pioenvs dir
|
# clean obsolete .pioenvs dir
|
||||||
@ -59,7 +71,8 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914
|
|||||||
if config.has_option("platformio", "env_default"):
|
if config.has_option("platformio", "env_default"):
|
||||||
env_default = [
|
env_default = [
|
||||||
e.strip()
|
e.strip()
|
||||||
for e in config.get("platformio", "env_default").split(",")]
|
for e in config.get("platformio", "env_default").split(",")
|
||||||
|
]
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
for section in config.sections():
|
for section in config.sections():
|
||||||
@ -71,9 +84,10 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914
|
|||||||
raise exception.InvalidEnvName(section)
|
raise exception.InvalidEnvName(section)
|
||||||
|
|
||||||
envname = section[4:]
|
envname = section[4:]
|
||||||
if ((environment and envname not in environment) or
|
skipenv = any([environment and envname not in environment,
|
||||||
(not environment and env_default and
|
not environment and env_default and
|
||||||
envname not in env_default)):
|
envname not in env_default])
|
||||||
|
if skipenv:
|
||||||
# echo("Skipped %s environment" % style(envname, fg="yellow"))
|
# echo("Skipped %s environment" % style(envname, fg="yellow"))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -86,8 +100,8 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914
|
|||||||
if "piotest" not in options and "piotest" in ctx.meta:
|
if "piotest" not in options and "piotest" in ctx.meta:
|
||||||
options['piotest'] = ctx.meta['piotest']
|
options['piotest'] = ctx.meta['piotest']
|
||||||
|
|
||||||
ep = EnvironmentProcessor(
|
ep = EnvironmentProcessor(ctx, envname, options, target,
|
||||||
ctx, envname, options, target, upload_port, verbose)
|
upload_port, verbose)
|
||||||
results.append(ep.process())
|
results.append(ep.process())
|
||||||
|
|
||||||
if not all(results):
|
if not all(results):
|
||||||
@ -96,10 +110,7 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914
|
|||||||
|
|
||||||
class EnvironmentProcessor(object):
|
class EnvironmentProcessor(object):
|
||||||
|
|
||||||
REMAPED_OPTIONS = {
|
REMAPED_OPTIONS = {"FRAMEWORK": "PIOFRAMEWORK", "PLATFORM": "PIOPLATFORM"}
|
||||||
"FRAMEWORK": "PIOFRAMEWORK",
|
|
||||||
"PLATFORM": "PIOPLATFORM"
|
|
||||||
}
|
|
||||||
|
|
||||||
RENAMED_OPTIONS = {
|
RENAMED_OPTIONS = {
|
||||||
"INSTALL_LIBS": "LIB_INSTALL",
|
"INSTALL_LIBS": "LIB_INSTALL",
|
||||||
@ -107,8 +118,13 @@ class EnvironmentProcessor(object):
|
|||||||
"LIB_USE": "LIB_FORCE"
|
"LIB_USE": "LIB_FORCE"
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, cmd_ctx, name, options, # pylint: disable=R0913
|
def __init__(self, # pylint: disable=R0913
|
||||||
targets, upload_port, verbose):
|
cmd_ctx,
|
||||||
|
name,
|
||||||
|
options,
|
||||||
|
targets,
|
||||||
|
upload_port,
|
||||||
|
verbose):
|
||||||
self.cmd_ctx = cmd_ctx
|
self.cmd_ctx = cmd_ctx
|
||||||
self.name = name
|
self.name = name
|
||||||
self.options = self._validate_options(options)
|
self.options = self._validate_options(options)
|
||||||
@ -121,21 +137,21 @@ class EnvironmentProcessor(object):
|
|||||||
start_time = time()
|
start_time = time()
|
||||||
|
|
||||||
click.echo("[%s] Processing %s (%s)" % (
|
click.echo("[%s] Processing %s (%s)" % (
|
||||||
datetime.now().strftime("%c"),
|
datetime.now().strftime("%c"), click.style(
|
||||||
click.style(self.name, fg="cyan", bold=True),
|
self.name, fg="cyan", bold=True), ", ".join(
|
||||||
", ".join(["%s: %s" % (k, v) for k, v in self.options.iteritems()])
|
["%s: %s" % (k, v) for k, v in self.options.iteritems()])))
|
||||||
))
|
|
||||||
click.secho("-" * terminal_width, bold=True)
|
click.secho("-" * terminal_width, bold=True)
|
||||||
|
|
||||||
result = self._run()
|
result = self._run()
|
||||||
|
|
||||||
is_error = result['returncode'] != 0
|
is_error = result['returncode'] != 0
|
||||||
if is_error or "piotest_processor" not in self.cmd_ctx.meta:
|
if is_error or "piotest_processor" not in self.cmd_ctx.meta:
|
||||||
print_header("[%s] Took %.2f seconds" % (
|
print_header(
|
||||||
(click.style("ERROR", fg="red", bold=True) if is_error
|
"[%s] Took %.2f seconds" % ((click.style(
|
||||||
else click.style("SUCCESS", fg="green", bold=True)),
|
"ERROR", fg="red", bold=True) if is_error else click.style(
|
||||||
time() - start_time
|
"SUCCESS", fg="green", bold=True)),
|
||||||
), is_error=is_error)
|
time() - start_time),
|
||||||
|
is_error=is_error)
|
||||||
|
|
||||||
return not is_error
|
return not is_error
|
||||||
|
|
||||||
@ -148,10 +164,8 @@ class EnvironmentProcessor(object):
|
|||||||
click.secho(
|
click.secho(
|
||||||
"Warning! `%s` option is deprecated and will be "
|
"Warning! `%s` option is deprecated and will be "
|
||||||
"removed in the next release! Please use "
|
"removed in the next release! Please use "
|
||||||
"`%s` instead." % (
|
"`%s` instead." % (k, self.RENAMED_OPTIONS[_k].lower()),
|
||||||
k, self.RENAMED_OPTIONS[_k].lower()),
|
fg="yellow")
|
||||||
fg="yellow"
|
|
||||||
)
|
|
||||||
k = self.RENAMED_OPTIONS[_k].lower()
|
k = self.RENAMED_OPTIONS[_k].lower()
|
||||||
result[k] = v
|
result[k] = v
|
||||||
return result
|
return result
|
||||||
@ -249,12 +263,10 @@ def check_project_envs(project_dir, environments):
|
|||||||
if not config.sections():
|
if not config.sections():
|
||||||
raise exception.ProjectEnvsNotAvailable()
|
raise exception.ProjectEnvsNotAvailable()
|
||||||
|
|
||||||
known = set([s[4:] for s in config.sections()
|
known = set([s[4:] for s in config.sections() if s.startswith("env:")])
|
||||||
if s.startswith("env:")])
|
|
||||||
unknown = set(environments) - known
|
unknown = set(environments) - known
|
||||||
if unknown:
|
if unknown:
|
||||||
raise exception.UnknownEnvNames(
|
raise exception.UnknownEnvNames(", ".join(unknown), ", ".join(known))
|
||||||
", ".join(unknown), ", ".join(known))
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,41 +46,72 @@ def serialports_list(json_output):
|
|||||||
|
|
||||||
|
|
||||||
if int(PYSERIAL_VERSION[0]) == 3:
|
if int(PYSERIAL_VERSION[0]) == 3:
|
||||||
|
|
||||||
@cli.command("monitor", short_help="Monitor Serial port")
|
@cli.command("monitor", short_help="Monitor Serial port")
|
||||||
@click.option("--port", "-p", help="Port, a number or a device name")
|
@click.option("--port", "-p", help="Port, a number or a device name")
|
||||||
@click.option("--baud", "-b", type=int, default=9600,
|
@click.option(
|
||||||
help="Set baud rate, default=9600")
|
"--baud",
|
||||||
@click.option("--parity", default="N",
|
"-b",
|
||||||
type=click.Choice(["N", "E", "O", "S", "M"]),
|
type=int,
|
||||||
help="Set parity, default=N")
|
default=9600,
|
||||||
@click.option("--rtscts", is_flag=True,
|
help="Set baud rate, default=9600")
|
||||||
help="Enable RTS/CTS flow control, default=Off")
|
@click.option(
|
||||||
@click.option("--xonxoff", is_flag=True,
|
"--parity",
|
||||||
help="Enable software flow control, default=Off")
|
default="N",
|
||||||
@click.option("--rts", default=None, type=click.Choice(["0", "1"]),
|
type=click.Choice(["N", "E", "O", "S", "M"]),
|
||||||
help="Set initial RTS line state")
|
help="Set parity, default=N")
|
||||||
@click.option("--dtr", default=None, type=click.Choice(["0", "1"]),
|
@click.option(
|
||||||
help="Set initial DTR line state")
|
"--rtscts",
|
||||||
@click.option("--echo", is_flag=True,
|
is_flag=True,
|
||||||
help="Enable local echo, default=Off")
|
help="Enable RTS/CTS flow control, default=Off")
|
||||||
@click.option("--encoding", default="UTF-8",
|
@click.option(
|
||||||
help="Set the encoding for the serial port (e.g. hexlify, "
|
"--xonxoff",
|
||||||
"Latin1, UTF-8), default: UTF-8")
|
is_flag=True,
|
||||||
@click.option("--filter", "-f", multiple=True,
|
help="Enable software flow control, default=Off")
|
||||||
help="Add text transformation")
|
@click.option(
|
||||||
@click.option("--eol", default="CRLF",
|
"--rts",
|
||||||
type=click.Choice(["CR", "LF", "CRLF"]),
|
default=None,
|
||||||
help="End of line mode, default=CRLF")
|
type=click.Choice(["0", "1"]),
|
||||||
@click.option("--raw", is_flag=True,
|
help="Set initial RTS line state")
|
||||||
help="Do not apply any encodings/transformations")
|
@click.option(
|
||||||
@click.option("--exit-char", type=int, default=29,
|
"--dtr",
|
||||||
help="ASCII code of special character that is used to exit "
|
default=None,
|
||||||
"the application, default=29 (DEC)")
|
type=click.Choice(["0", "1"]),
|
||||||
@click.option("--menu-char", type=int, default=20,
|
help="Set initial DTR line state")
|
||||||
help="ASCII code of special character that is used to "
|
@click.option(
|
||||||
"control miniterm (menu), default=20 (DEC)")
|
"--echo", is_flag=True, help="Enable local echo, default=Off")
|
||||||
@click.option("--quiet", is_flag=True,
|
@click.option(
|
||||||
help="Diagnostics: suppress non-error messages, default=Off")
|
"--encoding",
|
||||||
|
default="UTF-8",
|
||||||
|
help="Set the encoding for the serial port (e.g. hexlify, "
|
||||||
|
"Latin1, UTF-8), default: UTF-8")
|
||||||
|
@click.option(
|
||||||
|
"--filter", "-f", multiple=True, help="Add text transformation")
|
||||||
|
@click.option(
|
||||||
|
"--eol",
|
||||||
|
default="CRLF",
|
||||||
|
type=click.Choice(["CR", "LF", "CRLF"]),
|
||||||
|
help="End of line mode, default=CRLF")
|
||||||
|
@click.option(
|
||||||
|
"--raw",
|
||||||
|
is_flag=True,
|
||||||
|
help="Do not apply any encodings/transformations")
|
||||||
|
@click.option(
|
||||||
|
"--exit-char",
|
||||||
|
type=int,
|
||||||
|
default=29,
|
||||||
|
help="ASCII code of special character that is used to exit "
|
||||||
|
"the application, default=29 (DEC)")
|
||||||
|
@click.option(
|
||||||
|
"--menu-char",
|
||||||
|
type=int,
|
||||||
|
default=20,
|
||||||
|
help="ASCII code of special character that is used to "
|
||||||
|
"control miniterm (menu), default=20 (DEC)")
|
||||||
|
@click.option(
|
||||||
|
"--quiet",
|
||||||
|
is_flag=True,
|
||||||
|
help="Diagnostics: suppress non-error messages, default=Off")
|
||||||
def serialports_monitor(**kwargs):
|
def serialports_monitor(**kwargs):
|
||||||
if not kwargs['port']:
|
if not kwargs['port']:
|
||||||
for item in get_serialports():
|
for item in get_serialports():
|
||||||
@ -107,47 +138,78 @@ if int(PYSERIAL_VERSION[0]) == 3:
|
|||||||
default_port=kwargs['port'],
|
default_port=kwargs['port'],
|
||||||
default_baudrate=kwargs['baud'],
|
default_baudrate=kwargs['baud'],
|
||||||
default_rts=kwargs['rts'],
|
default_rts=kwargs['rts'],
|
||||||
default_dtr=kwargs['dtr']
|
default_dtr=kwargs['dtr'])
|
||||||
)
|
|
||||||
except Exception as e: # pylint: disable=W0702
|
except Exception as e: # pylint: disable=W0702
|
||||||
raise MinitermException(e)
|
raise MinitermException(e)
|
||||||
else:
|
else:
|
||||||
|
|
||||||
@cli.command("monitor", short_help="Monitor Serial port")
|
@cli.command("monitor", short_help="Monitor Serial port")
|
||||||
@click.option("--port", "-p", help="Port, a number or a device name")
|
@click.option("--port", "-p", help="Port, a number or a device name")
|
||||||
@click.option("--baud", "-b", type=int, default=9600,
|
@click.option(
|
||||||
help="Set baud rate, default=9600")
|
"--baud",
|
||||||
@click.option("--parity", default="N",
|
"-b",
|
||||||
type=click.Choice(["N", "E", "O", "S", "M"]),
|
type=int,
|
||||||
help="Set parity, default=N")
|
default=9600,
|
||||||
@click.option("--rtscts", is_flag=True,
|
help="Set baud rate, default=9600")
|
||||||
help="Enable RTS/CTS flow control, default=Off")
|
@click.option(
|
||||||
@click.option("--xonxoff", is_flag=True,
|
"--parity",
|
||||||
help="Enable software flow control, default=Off")
|
default="N",
|
||||||
@click.option("--rts", default=None, type=click.Choice(["0", "1"]),
|
type=click.Choice(["N", "E", "O", "S", "M"]),
|
||||||
help="Set initial RTS line state, default=0")
|
help="Set parity, default=N")
|
||||||
@click.option("--dtr", default=None, type=click.Choice(["0", "1"]),
|
@click.option(
|
||||||
help="Set initial DTR line state, default=0")
|
"--rtscts",
|
||||||
@click.option("--echo", is_flag=True,
|
is_flag=True,
|
||||||
help="Enable local echo, default=Off")
|
help="Enable RTS/CTS flow control, default=Off")
|
||||||
@click.option("--cr", is_flag=True,
|
@click.option(
|
||||||
help="Do not send CR+LF, send CR only, default=Off")
|
"--xonxoff",
|
||||||
@click.option("--lf", is_flag=True,
|
is_flag=True,
|
||||||
help="Do not send CR+LF, send LF only, default=Off")
|
help="Enable software flow control, default=Off")
|
||||||
@click.option("--debug", "-d", count=True,
|
@click.option(
|
||||||
help="""Debug received data (escape non-printable chars)
|
"--rts",
|
||||||
|
default=None,
|
||||||
|
type=click.Choice(["0", "1"]),
|
||||||
|
help="Set initial RTS line state, default=0")
|
||||||
|
@click.option(
|
||||||
|
"--dtr",
|
||||||
|
default=None,
|
||||||
|
type=click.Choice(["0", "1"]),
|
||||||
|
help="Set initial DTR line state, default=0")
|
||||||
|
@click.option(
|
||||||
|
"--echo", is_flag=True, help="Enable local echo, default=Off")
|
||||||
|
@click.option(
|
||||||
|
"--cr",
|
||||||
|
is_flag=True,
|
||||||
|
help="Do not send CR+LF, send CR only, default=Off")
|
||||||
|
@click.option(
|
||||||
|
"--lf",
|
||||||
|
is_flag=True,
|
||||||
|
help="Do not send CR+LF, send LF only, default=Off")
|
||||||
|
@click.option(
|
||||||
|
"--debug",
|
||||||
|
"-d",
|
||||||
|
count=True,
|
||||||
|
help="""Debug received data (escape non-printable chars)
|
||||||
# --debug can be given multiple times:
|
# --debug can be given multiple times:
|
||||||
# 0: just print what is received
|
# 0: just print what is received
|
||||||
# 1: escape non-printable characters, do newlines as unusual
|
# 1: escape non-printable characters, do newlines as unusual
|
||||||
# 2: escape non-printable characters, newlines too
|
# 2: escape non-printable characters, newlines too
|
||||||
# 3: hex dump everything""")
|
# 3: hex dump everything""")
|
||||||
@click.option("--exit-char", type=int, default=29,
|
@click.option(
|
||||||
help="ASCII code of special character that is used to exit "
|
"--exit-char",
|
||||||
"the application, default=29 (DEC)")
|
type=int,
|
||||||
@click.option("--menu-char", type=int, default=20,
|
default=29,
|
||||||
help="ASCII code of special character that is used to "
|
help="ASCII code of special character that is used to exit "
|
||||||
"control miniterm (menu), default=20 (DEC)")
|
"the application, default=29 (DEC)")
|
||||||
@click.option("--quiet", is_flag=True,
|
@click.option(
|
||||||
help="Diagnostics: suppress non-error messages, default=Off")
|
"--menu-char",
|
||||||
|
type=int,
|
||||||
|
default=20,
|
||||||
|
help="ASCII code of special character that is used to "
|
||||||
|
"control miniterm (menu), default=20 (DEC)")
|
||||||
|
@click.option(
|
||||||
|
"--quiet",
|
||||||
|
is_flag=True,
|
||||||
|
help="Diagnostics: suppress non-error messages, default=Off")
|
||||||
def serialports_monitor(**kwargs):
|
def serialports_monitor(**kwargs):
|
||||||
sys.argv = app.get_session_var("command_ctx").args[1:]
|
sys.argv = app.get_session_var("command_ctx").args[1:]
|
||||||
|
|
||||||
|
@ -29,12 +29,14 @@ def settings_get(name):
|
|||||||
list_tpl = "{name:<40} {value:<35} {description}"
|
list_tpl = "{name:<40} {value:<35} {description}"
|
||||||
terminal_width, _ = click.get_terminal_size()
|
terminal_width, _ = click.get_terminal_size()
|
||||||
|
|
||||||
click.echo(list_tpl.format(
|
click.echo(
|
||||||
name=click.style("Name", fg="cyan"),
|
list_tpl.format(
|
||||||
value=(click.style("Value", fg="green") +
|
name=click.style(
|
||||||
click.style(" [Default]", fg="yellow")),
|
"Name", fg="cyan"),
|
||||||
description="Description"
|
value=(click.style(
|
||||||
))
|
"Value", fg="green") + click.style(
|
||||||
|
" [Default]", fg="yellow")),
|
||||||
|
description="Description"))
|
||||||
click.echo("-" * terminal_width)
|
click.echo("-" * terminal_width)
|
||||||
|
|
||||||
for _name, _data in sorted(app.DEFAULT_SETTINGS.items()):
|
for _name, _data in sorted(app.DEFAULT_SETTINGS.items()):
|
||||||
@ -55,11 +57,12 @@ def settings_get(name):
|
|||||||
else:
|
else:
|
||||||
_value_str += click.style(" ", fg="yellow")
|
_value_str += click.style(" ", fg="yellow")
|
||||||
|
|
||||||
click.echo(list_tpl.format(
|
click.echo(
|
||||||
name=click.style(_name, fg="cyan"),
|
list_tpl.format(
|
||||||
value=_value_str,
|
name=click.style(
|
||||||
description=_data['description']
|
_name, fg="cyan"),
|
||||||
))
|
value=_value_str,
|
||||||
|
description=_data['description']))
|
||||||
|
|
||||||
|
|
||||||
@cli.command("set", short_help="Set new value for the setting")
|
@cli.command("set", short_help="Set new value for the setting")
|
||||||
|
@ -32,9 +32,16 @@ from platformio.managers.platform import PlatformFactory
|
|||||||
@click.option("--environment", "-e", multiple=True, metavar="<environment>")
|
@click.option("--environment", "-e", multiple=True, metavar="<environment>")
|
||||||
@click.option("--skip", multiple=True, metavar="<pattern>")
|
@click.option("--skip", multiple=True, metavar="<pattern>")
|
||||||
@click.option("--upload-port", metavar="<upload port>")
|
@click.option("--upload-port", metavar="<upload port>")
|
||||||
@click.option("-d", "--project-dir", default=getcwd,
|
@click.option(
|
||||||
type=click.Path(exists=True, file_okay=False, dir_okay=True,
|
"-d",
|
||||||
writable=True, resolve_path=True))
|
"--project-dir",
|
||||||
|
default=getcwd,
|
||||||
|
type=click.Path(
|
||||||
|
exists=True,
|
||||||
|
file_okay=False,
|
||||||
|
dir_okay=True,
|
||||||
|
writable=True,
|
||||||
|
resolve_path=True))
|
||||||
@click.option("--verbose", "-v", is_flag=True)
|
@click.option("--verbose", "-v", is_flag=True)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def cli(ctx, environment, skip, upload_port, project_dir, verbose):
|
def cli(ctx, environment, skip, upload_port, project_dir, verbose):
|
||||||
@ -85,16 +92,17 @@ def cli(ctx, environment, skip, upload_port, project_dir, verbose):
|
|||||||
elif status is None:
|
elif status is None:
|
||||||
status_str = click.style("IGNORED", fg="yellow")
|
status_str = click.style("IGNORED", fg="yellow")
|
||||||
|
|
||||||
click.echo("test:%s/env:%s\t%s" % (
|
click.echo(
|
||||||
click.style(testname, fg="yellow"),
|
"test:%s/env:%s\t%s" % (click.style(
|
||||||
click.style(envname, fg="cyan"),
|
testname, fg="yellow"), click.style(
|
||||||
status_str), err=status is False)
|
envname, fg="cyan"), status_str),
|
||||||
|
err=status is False)
|
||||||
|
|
||||||
print_header("[%s] Took %.2f seconds" % (
|
print_header(
|
||||||
(click.style("PASSED", fg="green", bold=True) if passed
|
"[%s] Took %.2f seconds" % ((click.style(
|
||||||
else click.style("FAILED", fg="red", bold=True)),
|
"PASSED", fg="green", bold=True) if passed else click.style(
|
||||||
time() - start_time
|
"FAILED", fg="red", bold=True)), time() - start_time),
|
||||||
), is_error=not passed)
|
is_error=not passed)
|
||||||
|
|
||||||
if not passed:
|
if not passed:
|
||||||
raise exception.ReturnErrorCode()
|
raise exception.ReturnErrorCode()
|
||||||
@ -122,41 +130,42 @@ class TestProcessor(object):
|
|||||||
return self._run_hardware_test()
|
return self._run_hardware_test()
|
||||||
|
|
||||||
def _progress(self, text, is_error=False):
|
def _progress(self, text, is_error=False):
|
||||||
print_header("[test::%s] %s" % (
|
print_header(
|
||||||
click.style(self.test_name, fg="yellow", bold=True),
|
"[test::%s] %s" % (click.style(
|
||||||
text
|
self.test_name, fg="yellow", bold=True), text),
|
||||||
), is_error=is_error)
|
is_error=is_error)
|
||||||
click.echo()
|
click.echo()
|
||||||
|
|
||||||
def _build_or_upload(self, target):
|
def _build_or_upload(self, target):
|
||||||
if self.test_name != "*":
|
if self.test_name != "*":
|
||||||
self.cmd_ctx.meta['piotest'] = self.test_name
|
self.cmd_ctx.meta['piotest'] = self.test_name
|
||||||
return self.cmd_ctx.invoke(
|
return self.cmd_ctx.invoke(
|
||||||
cmd_run, project_dir=self.options['project_dir'],
|
cmd_run,
|
||||||
|
project_dir=self.options['project_dir'],
|
||||||
upload_port=self.options['upload_port'],
|
upload_port=self.options['upload_port'],
|
||||||
verbose=self.options['verbose'],
|
verbose=self.options['verbose'],
|
||||||
environment=[self.env_name],
|
environment=[self.env_name],
|
||||||
target=target
|
target=target)
|
||||||
)
|
|
||||||
|
|
||||||
def _run_hardware_test(self):
|
def _run_hardware_test(self):
|
||||||
click.echo("If you don't see any output for the first 10 secs, "
|
click.echo("If you don't see any output for the first 10 secs, "
|
||||||
"please reset board (press reset button)")
|
"please reset board (press reset button)")
|
||||||
click.echo()
|
click.echo()
|
||||||
ser = serial.Serial(self.get_serial_port(), self.SERIAL_BAUDRATE,
|
ser = serial.Serial(
|
||||||
timeout=self.SERIAL_TIMEOUT)
|
self.get_serial_port(),
|
||||||
|
self.SERIAL_BAUDRATE,
|
||||||
|
timeout=self.SERIAL_TIMEOUT)
|
||||||
passed = True
|
passed = True
|
||||||
while True:
|
while True:
|
||||||
line = ser.readline().strip()
|
line = ser.readline().strip()
|
||||||
if not line:
|
if not line:
|
||||||
continue
|
continue
|
||||||
if line.endswith(":PASS"):
|
if line.endswith(":PASS"):
|
||||||
click.echo("%s\t%s" % (
|
click.echo("%s\t%s" % (line[:-5], click.style(
|
||||||
line[:-5], click.style("PASSED", fg="green")))
|
"PASSED", fg="green")))
|
||||||
elif ":FAIL:" in line:
|
elif ":FAIL:" in line:
|
||||||
passed = False
|
passed = False
|
||||||
click.echo("%s\t%s" % (
|
click.echo("%s\t%s" % (line, click.style("FAILED", fg="red")))
|
||||||
line, click.style("FAILED", fg="red")))
|
|
||||||
else:
|
else:
|
||||||
click.echo(line)
|
click.echo(line)
|
||||||
if all([l in line for l in ("Tests", "Failures", "Ignored")]):
|
if all([l in line for l in ("Tests", "Failures", "Ignored")]):
|
||||||
|
@ -19,8 +19,8 @@ from platformio.commands.platform import platform_update as cmd_platform_update
|
|||||||
from platformio.managers.lib import LibraryManager
|
from platformio.managers.lib import LibraryManager
|
||||||
|
|
||||||
|
|
||||||
@click.command("update",
|
@click.command(
|
||||||
short_help="Update installed Platforms, Packages and Libraries")
|
"update", short_help="Update installed Platforms, Packages and Libraries")
|
||||||
@click.option(
|
@click.option(
|
||||||
"-c",
|
"-c",
|
||||||
"--only-check",
|
"--only-check",
|
||||||
|
@ -22,26 +22,22 @@ import requests
|
|||||||
from platformio import VERSION, __version__, exception, util
|
from platformio import VERSION, __version__, exception, util
|
||||||
|
|
||||||
|
|
||||||
@click.command("upgrade",
|
@click.command(
|
||||||
short_help="Upgrade PlatformIO to the latest version")
|
"upgrade", short_help="Upgrade PlatformIO to the latest version")
|
||||||
def cli():
|
def cli():
|
||||||
latest = get_latest_version()
|
latest = get_latest_version()
|
||||||
if __version__ == latest:
|
if __version__ == latest:
|
||||||
return click.secho(
|
return click.secho(
|
||||||
"You're up-to-date!\nPlatformIO %s is currently the "
|
"You're up-to-date!\nPlatformIO %s is currently the "
|
||||||
"newest version available." % __version__, fg="green"
|
"newest version available." % __version__,
|
||||||
)
|
fg="green")
|
||||||
else:
|
else:
|
||||||
click.secho("Please wait while upgrading PlatformIO ...",
|
click.secho("Please wait while upgrading PlatformIO ...", fg="yellow")
|
||||||
fg="yellow")
|
|
||||||
|
|
||||||
to_develop = not all([c.isdigit() for c in latest if c != "."])
|
to_develop = not all([c.isdigit() for c in latest if c != "."])
|
||||||
cmds = (
|
cmds = (["pip", "install", "--upgrade",
|
||||||
["pip", "install", "--upgrade",
|
"https://github.com/platformio/platformio/archive/develop.zip"
|
||||||
"https://github.com/platformio/platformio/archive/develop.zip"
|
if to_develop else "platformio"], ["platformio", "--version"])
|
||||||
if to_develop else "platformio"],
|
|
||||||
["platformio", "--version"]
|
|
||||||
)
|
|
||||||
|
|
||||||
cmd = None
|
cmd = None
|
||||||
r = None
|
r = None
|
||||||
@ -63,21 +59,19 @@ def cli():
|
|||||||
actual_version = r['out'].strip().split("version", 1)[1].strip()
|
actual_version = r['out'].strip().split("version", 1)[1].strip()
|
||||||
click.secho(
|
click.secho(
|
||||||
"PlatformIO has been successfully upgraded to %s" %
|
"PlatformIO has been successfully upgraded to %s" %
|
||||||
actual_version, fg="green")
|
actual_version,
|
||||||
|
fg="green")
|
||||||
click.echo("Release notes: ", nl=False)
|
click.echo("Release notes: ", nl=False)
|
||||||
click.secho("http://docs.platformio.org/en/stable/history.html",
|
click.secho(
|
||||||
fg="cyan")
|
"http://docs.platformio.org/en/stable/history.html", fg="cyan")
|
||||||
except Exception as e: # pylint: disable=W0703
|
except Exception as e: # pylint: disable=W0703
|
||||||
if not r:
|
if not r:
|
||||||
raise exception.UpgradeError(
|
raise exception.UpgradeError("\n".join([str(cmd), str(e)]))
|
||||||
"\n".join([str(cmd), str(e)]))
|
permission_errors = ("permission denied", "not permitted")
|
||||||
permission_errors = (
|
|
||||||
"permission denied",
|
|
||||||
"not permitted"
|
|
||||||
)
|
|
||||||
if (any([m in r['err'].lower() for m in permission_errors]) and
|
if (any([m in r['err'].lower() for m in permission_errors]) and
|
||||||
"windows" not in util.get_systype()):
|
"windows" not in util.get_systype()):
|
||||||
click.secho("""
|
click.secho(
|
||||||
|
"""
|
||||||
-----------------
|
-----------------
|
||||||
Permission denied
|
Permission denied
|
||||||
-----------------
|
-----------------
|
||||||
@ -86,11 +80,13 @@ You need the `sudo` permission to install Python packages. Try
|
|||||||
> sudo pip install -U platformio
|
> sudo pip install -U platformio
|
||||||
|
|
||||||
WARNING! Don't use `sudo` for the rest PlatformIO commands.
|
WARNING! Don't use `sudo` for the rest PlatformIO commands.
|
||||||
""", fg="yellow", err=True)
|
""",
|
||||||
|
fg="yellow",
|
||||||
|
err=True)
|
||||||
raise exception.ReturnErrorCode()
|
raise exception.ReturnErrorCode()
|
||||||
else:
|
else:
|
||||||
raise exception.UpgradeError(
|
raise exception.UpgradeError("\n".join([str(cmd), r['out'], r[
|
||||||
"\n".join([str(cmd), r['out'], r['err']]))
|
'err']]))
|
||||||
|
|
||||||
|
|
||||||
def get_latest_version():
|
def get_latest_version():
|
||||||
@ -107,11 +103,9 @@ def get_latest_version():
|
|||||||
|
|
||||||
def get_develop_latest_version():
|
def get_develop_latest_version():
|
||||||
version = None
|
version = None
|
||||||
r = requests.get(
|
r = requests.get("https://raw.githubusercontent.com/platformio/platformio"
|
||||||
"https://raw.githubusercontent.com/platformio/platformio"
|
"/develop/platformio/__init__.py",
|
||||||
"/develop/platformio/__init__.py",
|
headers=util.get_request_defheaders())
|
||||||
headers=util.get_request_defheaders()
|
|
||||||
)
|
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
for line in r.text.split("\n"):
|
for line in r.text.split("\n"):
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
@ -129,9 +123,7 @@ def get_develop_latest_version():
|
|||||||
|
|
||||||
|
|
||||||
def get_pypi_latest_version():
|
def get_pypi_latest_version():
|
||||||
r = requests.get(
|
r = requests.get("https://pypi.python.org/pypi/platformio/json",
|
||||||
"https://pypi.python.org/pypi/platformio/json",
|
headers=util.get_request_defheaders())
|
||||||
headers=util.get_request_defheaders()
|
|
||||||
)
|
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
return r.json()['info']['version']
|
return r.json()['info']['version']
|
||||||
|
@ -41,7 +41,8 @@ class FileDownloader(object):
|
|||||||
self._request = None
|
self._request = None
|
||||||
|
|
||||||
# make connection
|
# make connection
|
||||||
self._request = requests.get(url, stream=True,
|
self._request = requests.get(url,
|
||||||
|
stream=True,
|
||||||
headers=util.get_request_defheaders())
|
headers=util.get_request_defheaders())
|
||||||
if self._request.status_code != 200:
|
if self._request.status_code != 200:
|
||||||
raise FDUnrecognizedStatusCode(self._request.status_code, url)
|
raise FDUnrecognizedStatusCode(self._request.status_code, url)
|
||||||
|
@ -59,19 +59,14 @@ class ProjectGenerator(object):
|
|||||||
|
|
||||||
@util.memoized
|
@util.memoized
|
||||||
def get_project_build_data(self):
|
def get_project_build_data(self):
|
||||||
data = {
|
data = {"defines": [], "includes": [], "cxx_path": None}
|
||||||
"defines": [],
|
|
||||||
"includes": [],
|
|
||||||
"cxx_path": None
|
|
||||||
}
|
|
||||||
envdata = self.get_project_env()
|
envdata = self.get_project_env()
|
||||||
if "env_name" not in envdata:
|
if "env_name" not in envdata:
|
||||||
return data
|
return data
|
||||||
cmd = [
|
cmd = [
|
||||||
normpath(sys.executable), "-m",
|
normpath(sys.executable), "-m",
|
||||||
"platformio" + (
|
"platformio" + (".__main__"
|
||||||
".__main__" if sys.version_info < (2, 7, 0) else ""),
|
if sys.version_info < (2, 7, 0) else ""), "-f"
|
||||||
"-f"
|
|
||||||
]
|
]
|
||||||
if app.get_session_var("caller_id"):
|
if app.get_session_var("caller_id"):
|
||||||
cmd.extend(["-c", app.get_session_var("caller_id")])
|
cmd.extend(["-c", app.get_session_var("caller_id")])
|
||||||
@ -80,8 +75,8 @@ class ProjectGenerator(object):
|
|||||||
result = util.exec_command(cmd)
|
result = util.exec_command(cmd)
|
||||||
|
|
||||||
if result['returncode'] != 0 or '"includes":' not in result['out']:
|
if result['returncode'] != 0 or '"includes":' not in result['out']:
|
||||||
raise exception.PlatformioException(
|
raise exception.PlatformioException("\n".join([result['out'],
|
||||||
"\n".join([result['out'], result['err']]))
|
result['err']]))
|
||||||
|
|
||||||
output = result['out']
|
output = result['out']
|
||||||
start_index = output.index('{"')
|
start_index = output.index('{"')
|
||||||
@ -125,8 +120,7 @@ class ProjectGenerator(object):
|
|||||||
file_name = basename(tpl_path)[:-4]
|
file_name = basename(tpl_path)[:-4]
|
||||||
self._merge_contents(
|
self._merge_contents(
|
||||||
join(dst_dir, file_name),
|
join(dst_dir, file_name),
|
||||||
self._render_tpl(tpl_path).encode("utf8")
|
self._render_tpl(tpl_path).encode("utf8"))
|
||||||
)
|
|
||||||
|
|
||||||
def _render_tpl(self, tpl_path):
|
def _render_tpl(self, tpl_path):
|
||||||
content = ""
|
content = ""
|
||||||
@ -161,13 +155,13 @@ class ProjectGenerator(object):
|
|||||||
"project_dir": self.project_dir,
|
"project_dir": self.project_dir,
|
||||||
"project_src_dir": self.project_src_dir,
|
"project_src_dir": self.project_src_dir,
|
||||||
"systype": util.get_systype(),
|
"systype": util.get_systype(),
|
||||||
"platformio_path": self._fix_os_path(
|
"platformio_path":
|
||||||
util.where_is_program("platformio")),
|
self._fix_os_path(util.where_is_program("platformio")),
|
||||||
"env_pathsep": os.pathsep,
|
"env_pathsep": os.pathsep,
|
||||||
"env_path": self._fix_os_path(os.getenv("PATH"))
|
"env_path": self._fix_os_path(os.getenv("PATH"))
|
||||||
})
|
})
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _fix_os_path(path):
|
def _fix_os_path(path):
|
||||||
return (re.sub(r"[\\]+", '\\' * 4, path) if "windows" in
|
return (re.sub(r"[\\]+", '\\' * 4, path)
|
||||||
util.get_systype() else path)
|
if "windows" in util.get_systype() else path)
|
||||||
|
@ -56,8 +56,10 @@ def on_platformio_end(ctx, result): # pylint: disable=W0613
|
|||||||
check_internal_updates(ctx, "platforms")
|
check_internal_updates(ctx, "platforms")
|
||||||
check_internal_updates(ctx, "libraries")
|
check_internal_updates(ctx, "libraries")
|
||||||
except (exception.GetLatestVersionError, exception.APIRequestError):
|
except (exception.GetLatestVersionError, exception.APIRequestError):
|
||||||
click.secho("Failed to check for PlatformIO upgrades. "
|
click.secho(
|
||||||
"Please check your Internet connection.", fg="red")
|
"Failed to check for PlatformIO upgrades. "
|
||||||
|
"Please check your Internet connection.",
|
||||||
|
fg="red")
|
||||||
|
|
||||||
|
|
||||||
def on_platformio_exception(e):
|
def on_platformio_exception(e):
|
||||||
@ -100,8 +102,7 @@ class Upgrader(object):
|
|||||||
continue
|
continue
|
||||||
os.remove(join(boards_dir, item))
|
os.remove(join(boards_dir, item))
|
||||||
for key, value in data.items():
|
for key, value in data.items():
|
||||||
with open(join(boards_dir, "%s.json" % key),
|
with open(join(boards_dir, "%s.json" % key), "w") as f:
|
||||||
"w") as f:
|
|
||||||
json.dump(value, f, sort_keys=True, indent=2)
|
json.dump(value, f, sort_keys=True, indent=2)
|
||||||
|
|
||||||
# re-install PlatformIO 2.0 development platforms
|
# re-install PlatformIO 2.0 development platforms
|
||||||
@ -120,8 +121,7 @@ def after_upgrade(ctx):
|
|||||||
if last_version == "0.0.0":
|
if last_version == "0.0.0":
|
||||||
app.set_state_item("last_version", __version__)
|
app.set_state_item("last_version", __version__)
|
||||||
else:
|
else:
|
||||||
click.secho("Please wait while upgrading PlatformIO ...",
|
click.secho("Please wait while upgrading PlatformIO ...", fg="yellow")
|
||||||
fg="yellow")
|
|
||||||
|
|
||||||
u = Upgrader(last_version, __version__)
|
u = Upgrader(last_version, __version__)
|
||||||
if u.run(ctx):
|
if u.run(ctx):
|
||||||
@ -132,11 +132,15 @@ def after_upgrade(ctx):
|
|||||||
for manifest in pm.get_installed():
|
for manifest in pm.get_installed():
|
||||||
pm.update(manifest['name'], "^" + manifest['version'])
|
pm.update(manifest['name'], "^" + manifest['version'])
|
||||||
|
|
||||||
click.secho("PlatformIO has been successfully upgraded to %s!\n" %
|
click.secho(
|
||||||
__version__, fg="green")
|
"PlatformIO has been successfully upgraded to %s!\n" %
|
||||||
|
__version__,
|
||||||
|
fg="green")
|
||||||
|
|
||||||
telemetry.on_event(category="Auto", action="Upgrade",
|
telemetry.on_event(
|
||||||
label="%s > %s" % (last_version, __version__))
|
category="Auto",
|
||||||
|
action="Upgrade",
|
||||||
|
label="%s > %s" % (last_version, __version__))
|
||||||
else:
|
else:
|
||||||
raise exception.UpgradeError("Auto upgrading...")
|
raise exception.UpgradeError("Auto upgrading...")
|
||||||
click.echo("")
|
click.echo("")
|
||||||
@ -144,29 +148,24 @@ def after_upgrade(ctx):
|
|||||||
# PlatformIO banner
|
# PlatformIO banner
|
||||||
terminal_width, _ = click.get_terminal_size()
|
terminal_width, _ = click.get_terminal_size()
|
||||||
click.echo("*" * terminal_width)
|
click.echo("*" * terminal_width)
|
||||||
click.echo("If you like %s, please:" % (
|
click.echo("If you like %s, please:" % (click.style(
|
||||||
click.style("PlatformIO", fg="cyan")
|
"PlatformIO", fg="cyan")))
|
||||||
))
|
click.echo("- %s us on Twitter to stay up-to-date "
|
||||||
click.echo(
|
"on the latest project news > %s" % (click.style(
|
||||||
"- %s us on Twitter to stay up-to-date "
|
"follow", fg="cyan"), click.style(
|
||||||
"on the latest project news > %s" %
|
"https://twitter.com/PlatformIO_Org", fg="cyan")))
|
||||||
(click.style("follow", fg="cyan"),
|
click.echo("- %s it on GitHub > %s" % (click.style(
|
||||||
click.style("https://twitter.com/PlatformIO_Org", fg="cyan"))
|
"star", fg="cyan"), click.style(
|
||||||
)
|
"https://github.com/platformio/platformio", fg="cyan")))
|
||||||
click.echo("- %s it on GitHub > %s" % (
|
|
||||||
click.style("star", fg="cyan"),
|
|
||||||
click.style("https://github.com/platformio/platformio", fg="cyan")
|
|
||||||
))
|
|
||||||
if not getenv("PLATFORMIO_IDE"):
|
if not getenv("PLATFORMIO_IDE"):
|
||||||
click.echo("- %s PlatformIO IDE for IoT development > %s" % (
|
click.echo("- %s PlatformIO IDE for IoT development > %s" %
|
||||||
click.style("try", fg="cyan"),
|
(click.style(
|
||||||
click.style("http://platformio.org/platformio-ide", fg="cyan")
|
"try", fg="cyan"), click.style(
|
||||||
))
|
"http://platformio.org/platformio-ide", fg="cyan")))
|
||||||
if not util.is_ci():
|
if not util.is_ci():
|
||||||
click.echo("- %s to keep PlatformIO alive! > %s" % (
|
click.echo("- %s to keep PlatformIO alive! > %s" % (click.style(
|
||||||
click.style("donate", fg="cyan"),
|
"donate", fg="cyan"), click.style(
|
||||||
click.style("http://platformio.org/donate", fg="cyan")
|
"http://platformio.org/donate", fg="cyan")))
|
||||||
))
|
|
||||||
|
|
||||||
click.echo("*" * terminal_width)
|
click.echo("*" * terminal_width)
|
||||||
click.echo("")
|
click.echo("")
|
||||||
@ -191,12 +190,14 @@ def check_platformio_upgrade():
|
|||||||
|
|
||||||
click.echo("")
|
click.echo("")
|
||||||
click.echo("*" * terminal_width)
|
click.echo("*" * terminal_width)
|
||||||
click.secho("There is a new version %s of PlatformIO available.\n"
|
click.secho(
|
||||||
"Please upgrade it via `" % latest_version,
|
"There is a new version %s of PlatformIO available.\n"
|
||||||
fg="yellow", nl=False)
|
"Please upgrade it via `" % latest_version,
|
||||||
|
fg="yellow",
|
||||||
|
nl=False)
|
||||||
if getenv("PLATFORMIO_IDE"):
|
if getenv("PLATFORMIO_IDE"):
|
||||||
click.secho("PlatformIO IDE Menu: Upgrade PlatformIO",
|
click.secho(
|
||||||
fg="cyan", nl=False)
|
"PlatformIO IDE Menu: Upgrade PlatformIO", fg="cyan", nl=False)
|
||||||
click.secho("`.", fg="yellow")
|
click.secho("`.", fg="yellow")
|
||||||
elif join("Cellar", "platformio") in util.get_source_dir():
|
elif join("Cellar", "platformio") in util.get_source_dir():
|
||||||
click.secho("brew update && brew upgrade", fg="cyan", nl=False)
|
click.secho("brew update && brew upgrade", fg="cyan", nl=False)
|
||||||
@ -235,20 +236,29 @@ def check_internal_updates(ctx, what):
|
|||||||
|
|
||||||
click.echo("")
|
click.echo("")
|
||||||
click.echo("*" * terminal_width)
|
click.echo("*" * terminal_width)
|
||||||
click.secho("There are the new updates for %s (%s)" %
|
click.secho(
|
||||||
(what, ", ".join(outdated_items)), fg="yellow")
|
"There are the new updates for %s (%s)" %
|
||||||
|
(what, ", ".join(outdated_items)),
|
||||||
|
fg="yellow")
|
||||||
|
|
||||||
if not app.get_setting("auto_update_" + what):
|
if not app.get_setting("auto_update_" + what):
|
||||||
click.secho("Please update them via ", fg="yellow", nl=False)
|
click.secho("Please update them via ", fg="yellow", nl=False)
|
||||||
click.secho("`platformio %s update`" %
|
click.secho(
|
||||||
("lib --global" if what == "libraries" else "platform"),
|
"`platformio %s update`" %
|
||||||
fg="cyan", nl=False)
|
("lib --global" if what == "libraries" else "platform"),
|
||||||
|
fg="cyan",
|
||||||
|
nl=False)
|
||||||
click.secho(" command.\n", fg="yellow")
|
click.secho(" command.\n", fg="yellow")
|
||||||
click.secho("If you want to manually check for the new versions "
|
click.secho(
|
||||||
"without updating, please use ", fg="yellow", nl=False)
|
"If you want to manually check for the new versions "
|
||||||
click.secho("`platformio %s update --only-check`" %
|
"without updating, please use ",
|
||||||
("lib --global" if what == "libraries" else "platform"),
|
fg="yellow",
|
||||||
fg="cyan", nl=False)
|
nl=False)
|
||||||
|
click.secho(
|
||||||
|
"`platformio %s update --only-check`" %
|
||||||
|
("lib --global" if what == "libraries" else "platform"),
|
||||||
|
fg="cyan",
|
||||||
|
nl=False)
|
||||||
click.secho(" command.", fg="yellow")
|
click.secho(" command.", fg="yellow")
|
||||||
else:
|
else:
|
||||||
click.secho("Please wait while updating %s ..." % what, fg="yellow")
|
click.secho("Please wait while updating %s ..." % what, fg="yellow")
|
||||||
|
@ -210,8 +210,7 @@ class MPDataPusher(object):
|
|||||||
"https://ssl.google-analytics.com/collect",
|
"https://ssl.google-analytics.com/collect",
|
||||||
data=data,
|
data=data,
|
||||||
headers=util.get_request_defheaders(),
|
headers=util.get_request_defheaders(),
|
||||||
timeout=1
|
timeout=1)
|
||||||
)
|
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
return True
|
return True
|
||||||
except: # pylint: disable=W0702
|
except: # pylint: disable=W0702
|
||||||
@ -233,11 +232,7 @@ def on_command():
|
|||||||
|
|
||||||
|
|
||||||
def measure_ci():
|
def measure_ci():
|
||||||
event = {
|
event = {"category": "CI", "action": "NoName", "label": None}
|
||||||
"category": "CI",
|
|
||||||
"action": "NoName",
|
|
||||||
"label": None
|
|
||||||
}
|
|
||||||
|
|
||||||
envmap = {
|
envmap = {
|
||||||
"APPVEYOR": {"label": getenv("APPVEYOR_REPO_NAME")},
|
"APPVEYOR": {"label": getenv("APPVEYOR_REPO_NAME")},
|
||||||
@ -258,11 +253,7 @@ def measure_ci():
|
|||||||
|
|
||||||
def measure_caller(calller_id):
|
def measure_caller(calller_id):
|
||||||
calller_id = str(calller_id)[:20].lower()
|
calller_id = str(calller_id)[:20].lower()
|
||||||
event = {
|
event = {"category": "Caller", "action": "Misc", "label": calller_id}
|
||||||
"category": "Caller",
|
|
||||||
"action": "Misc",
|
|
||||||
"label": calller_id
|
|
||||||
}
|
|
||||||
if calller_id in (["atom", "vim"] + ProjectGenerator.get_supported_ides()):
|
if calller_id in (["atom", "vim"] + ProjectGenerator.get_supported_ides()):
|
||||||
event['action'] = "IDE"
|
event['action'] = "IDE"
|
||||||
on_event(**event)
|
on_event(**event)
|
||||||
|
@ -64,8 +64,7 @@ class ZIPArchive(ArchiveBase):
|
|||||||
def preserve_mtime(item, dest_dir):
|
def preserve_mtime(item, dest_dir):
|
||||||
util.change_filemtime(
|
util.change_filemtime(
|
||||||
join(dest_dir, item.filename),
|
join(dest_dir, item.filename),
|
||||||
mktime(list(item.date_time) + [0] * 3)
|
mktime(list(item.date_time) + [0] * 3))
|
||||||
)
|
|
||||||
|
|
||||||
def get_items(self):
|
def get_items(self):
|
||||||
return self._afo.infolist()
|
return self._afo.infolist()
|
||||||
@ -97,8 +96,8 @@ class FileUnpacker(object):
|
|||||||
for item in self._unpacker.get_items():
|
for item in self._unpacker.get_items():
|
||||||
self._unpacker.extract_item(item, self._dest_dir)
|
self._unpacker.extract_item(item, self._dest_dir)
|
||||||
else:
|
else:
|
||||||
with click.progressbar(self._unpacker.get_items(),
|
items = self._unpacker.get_items()
|
||||||
label="Unpacking") as pb:
|
with click.progressbar(items, label="Unpacking") as pb:
|
||||||
for item in pb:
|
for item in pb:
|
||||||
self._unpacker.extract_item(item, self._dest_dir)
|
self._unpacker.extract_item(item, self._dest_dir)
|
||||||
return True
|
return True
|
||||||
|
@ -81,7 +81,6 @@ class cd(object):
|
|||||||
|
|
||||||
|
|
||||||
class memoized(object):
|
class memoized(object):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Decorator. Caches a function's return value each time it is called.
|
Decorator. Caches a function's return value each time it is called.
|
||||||
If called later with the same arguments, the cached value is returned
|
If called later with the same arguments, the cached value is returned
|
||||||
@ -122,6 +121,7 @@ def singleton(cls):
|
|||||||
if cls not in _instances:
|
if cls not in _instances:
|
||||||
_instances[cls] = cls(*args, **kwargs)
|
_instances[cls] = cls(*args, **kwargs)
|
||||||
return _instances[cls]
|
return _instances[cls]
|
||||||
|
|
||||||
return get_instance
|
return get_instance
|
||||||
|
|
||||||
|
|
||||||
@ -162,10 +162,8 @@ def _get_projconf_option_dir(name, default=None):
|
|||||||
|
|
||||||
|
|
||||||
def get_home_dir():
|
def get_home_dir():
|
||||||
home_dir = _get_projconf_option_dir(
|
home_dir = _get_projconf_option_dir("home_dir",
|
||||||
"home_dir",
|
join(expanduser("~"), ".platformio"))
|
||||||
join(expanduser("~"), ".platformio")
|
|
||||||
)
|
|
||||||
|
|
||||||
if "windows" in get_systype():
|
if "windows" in get_systype():
|
||||||
try:
|
try:
|
||||||
@ -234,10 +232,8 @@ URL=http://docs.platformio.org/en/stable/projectconf.html#envs-dir
|
|||||||
|
|
||||||
|
|
||||||
def get_projectdata_dir():
|
def get_projectdata_dir():
|
||||||
return _get_projconf_option_dir(
|
return _get_projconf_option_dir("data_dir",
|
||||||
"data_dir",
|
join(get_project_dir(), "data"))
|
||||||
join(get_project_dir(), "data")
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def load_project_config(project_dir=None):
|
def load_project_config(project_dir=None):
|
||||||
@ -259,17 +255,12 @@ def is_ci():
|
|||||||
|
|
||||||
|
|
||||||
def exec_command(*args, **kwargs):
|
def exec_command(*args, **kwargs):
|
||||||
result = {
|
result = {"out": None, "err": None, "returncode": None}
|
||||||
"out": None,
|
|
||||||
"err": None,
|
|
||||||
"returncode": None
|
|
||||||
}
|
|
||||||
|
|
||||||
default = dict(
|
default = dict(
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
shell=system() == "Windows"
|
shell=system() == "Windows")
|
||||||
)
|
|
||||||
default.update(kwargs)
|
default.update(kwargs)
|
||||||
kwargs = default
|
kwargs = default
|
||||||
|
|
||||||
@ -344,9 +335,8 @@ def get_logicaldisks():
|
|||||||
|
|
||||||
def get_request_defheaders():
|
def get_request_defheaders():
|
||||||
import requests
|
import requests
|
||||||
return {"User-Agent": "PlatformIO/%s CI/%d %s" % (
|
data = (__version__, int(is_ci()), requests.utils.default_user_agent())
|
||||||
__version__, int(is_ci()), requests.utils.default_user_agent()
|
return {"User-Agent": "PlatformIO/%s CI/%d %s" % data}
|
||||||
)}
|
|
||||||
|
|
||||||
|
|
||||||
@memoized
|
@memoized
|
||||||
@ -364,7 +354,7 @@ def get_api_result(path, params=None, data=None, skipdns=False):
|
|||||||
url = __apiurl__
|
url = __apiurl__
|
||||||
if skipdns:
|
if skipdns:
|
||||||
url = "http://%s" % __apiip__
|
url = "http://%s" % __apiip__
|
||||||
headers['host'] = __apiurl__[__apiurl__.index("://")+3:]
|
headers['host'] = __apiurl__[__apiurl__.index("://") + 3:]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if data:
|
if data:
|
||||||
@ -390,8 +380,8 @@ def get_api_result(path, params=None, data=None, skipdns=False):
|
|||||||
"Could not connect to PlatformIO Registry Service. "
|
"Could not connect to PlatformIO Registry Service. "
|
||||||
"Please try later.")
|
"Please try later.")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise exception.APIRequestError(
|
raise exception.APIRequestError("Invalid response: %s" %
|
||||||
"Invalid response: %s" % r.text.encode("utf-8"))
|
r.text.encode("utf-8"))
|
||||||
finally:
|
finally:
|
||||||
if r:
|
if r:
|
||||||
r.close()
|
r.close()
|
||||||
@ -401,8 +391,8 @@ def get_api_result(path, params=None, data=None, skipdns=False):
|
|||||||
@memoized
|
@memoized
|
||||||
def _lookup_frameworks():
|
def _lookup_frameworks():
|
||||||
frameworks = {}
|
frameworks = {}
|
||||||
frameworks_path = join(
|
frameworks_path = join(get_source_dir(), "builder", "scripts",
|
||||||
get_source_dir(), "builder", "scripts", "frameworks")
|
"frameworks")
|
||||||
|
|
||||||
frameworks_list = [f[:-3] for f in os.listdir(frameworks_path)
|
frameworks_list = [f[:-3] for f in os.listdir(frameworks_path)
|
||||||
if not f.startswith("__") and f.endswith(".py")]
|
if not f.startswith("__") and f.endswith(".py")]
|
||||||
@ -412,8 +402,8 @@ def _lookup_frameworks():
|
|||||||
fcontent = f.read()
|
fcontent = f.read()
|
||||||
assert '"""' in fcontent
|
assert '"""' in fcontent
|
||||||
_doc_start = fcontent.index('"""') + 3
|
_doc_start = fcontent.index('"""') + 3
|
||||||
fdoc = fcontent[
|
fdoc = fcontent[_doc_start:fcontent.index('"""',
|
||||||
_doc_start:fcontent.index('"""', _doc_start)].strip()
|
_doc_start)].strip()
|
||||||
doclines = [l.strip() for l in fdoc.splitlines() if l.strip()]
|
doclines = [l.strip() for l in fdoc.splitlines() if l.strip()]
|
||||||
frameworks[_type] = {
|
frameworks[_type] = {
|
||||||
"name": doclines[0],
|
"name": doclines[0],
|
||||||
@ -446,8 +436,7 @@ def where_is_program(program, envpath=None):
|
|||||||
try:
|
try:
|
||||||
result = exec_command(
|
result = exec_command(
|
||||||
["where" if "windows" in get_systype() else "which", program],
|
["where" if "windows" in get_systype() else "which", program],
|
||||||
env=env
|
env=env)
|
||||||
)
|
|
||||||
if result['returncode'] == 0 and isfile(result['out'].strip()):
|
if result['returncode'] == 0 and isfile(result['out'].strip()):
|
||||||
return result['out'].strip()
|
return result['out'].strip()
|
||||||
except OSError:
|
except OSError:
|
||||||
|
5
setup.py
5
setup.py
@ -12,8 +12,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
from platformio import (__author__, __description__, __email__, __license__,
|
from platformio import (__author__, __description__, __email__, __license__,
|
||||||
@ -29,9 +27,6 @@ install_requires = [
|
|||||||
"pyserial<4"
|
"pyserial<4"
|
||||||
]
|
]
|
||||||
|
|
||||||
if sys.version_info < (2, 7, 0):
|
|
||||||
install_requires[-1] = "pyserial<3"
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name=__title__,
|
name=__title__,
|
||||||
version=__version__,
|
version=__version__,
|
||||||
|
Reference in New Issue
Block a user