mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Format code
This commit is contained in:
@ -132,7 +132,7 @@ if env.GetOption("clean"):
|
|||||||
env.PioClean(env.subst("$BUILD_DIR"))
|
env.PioClean(env.subst("$BUILD_DIR"))
|
||||||
env.Exit(0)
|
env.Exit(0)
|
||||||
elif not int(ARGUMENTS.get("PIOVERBOSE", 0)):
|
elif not int(ARGUMENTS.get("PIOVERBOSE", 0)):
|
||||||
print ("Verbose mode can be enabled via `-v, --verbose` option")
|
print("Verbose mode can be enabled via `-v, --verbose` option")
|
||||||
|
|
||||||
env.LoadProjectOptions()
|
env.LoadProjectOptions()
|
||||||
env.LoadPioPlatform()
|
env.LoadPioPlatform()
|
||||||
@ -181,12 +181,12 @@ AlwaysBuild(env.Alias("__test", DEFAULT_TARGETS))
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
if "envdump" in COMMAND_LINE_TARGETS:
|
if "envdump" in COMMAND_LINE_TARGETS:
|
||||||
print (env.Dump())
|
print(env.Dump())
|
||||||
env.Exit(0)
|
env.Exit(0)
|
||||||
|
|
||||||
if "idedata" in COMMAND_LINE_TARGETS:
|
if "idedata" in COMMAND_LINE_TARGETS:
|
||||||
Import("projenv")
|
Import("projenv")
|
||||||
print (
|
print(
|
||||||
"\n%s\n"
|
"\n%s\n"
|
||||||
% dump_json_to_unicode(
|
% dump_json_to_unicode(
|
||||||
projenv.DumpIDEData() # pylint: disable=undefined-variable
|
projenv.DumpIDEData() # pylint: disable=undefined-variable
|
||||||
|
@ -294,17 +294,17 @@ def VerboseAction(_, act, actstr):
|
|||||||
|
|
||||||
def PioClean(env, clean_dir):
|
def PioClean(env, clean_dir):
|
||||||
if not isdir(clean_dir):
|
if not isdir(clean_dir):
|
||||||
print ("Build environment is clean")
|
print("Build environment is clean")
|
||||||
env.Exit(0)
|
env.Exit(0)
|
||||||
clean_rel_path = relpath(clean_dir)
|
clean_rel_path = relpath(clean_dir)
|
||||||
for root, _, files in walk(clean_dir):
|
for root, _, files in walk(clean_dir):
|
||||||
for f in files:
|
for f in files:
|
||||||
dst = join(root, f)
|
dst = join(root, f)
|
||||||
remove(dst)
|
remove(dst)
|
||||||
print (
|
print(
|
||||||
"Removed %s" % (dst if clean_rel_path.startswith(".") else relpath(dst))
|
"Removed %s" % (dst if clean_rel_path.startswith(".") else relpath(dst))
|
||||||
)
|
)
|
||||||
print ("Done cleaning")
|
print("Done cleaning")
|
||||||
fs.rmtree(clean_dir)
|
fs.rmtree(clean_dir)
|
||||||
env.Exit(0)
|
env.Exit(0)
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ def PrintConfiguration(env): # pylint: disable=too-many-statements
|
|||||||
_get_packages_data(),
|
_get_packages_data(),
|
||||||
):
|
):
|
||||||
if data and len(data) > 1:
|
if data and len(data) > 1:
|
||||||
print (" ".join(data))
|
print(" ".join(data))
|
||||||
|
|
||||||
|
|
||||||
def exists(_):
|
def exists(_):
|
||||||
|
@ -45,7 +45,7 @@ def FlushSerialBuffer(env, port):
|
|||||||
|
|
||||||
def TouchSerialPort(env, port, baudrate):
|
def TouchSerialPort(env, port, baudrate):
|
||||||
port = env.subst(port)
|
port = env.subst(port)
|
||||||
print ("Forcing reset using %dbps open/close on port %s" % (baudrate, port))
|
print("Forcing reset using %dbps open/close on port %s" % (baudrate, port))
|
||||||
try:
|
try:
|
||||||
s = Serial(port=port, baudrate=baudrate)
|
s = Serial(port=port, baudrate=baudrate)
|
||||||
s.setDTR(False)
|
s.setDTR(False)
|
||||||
@ -56,7 +56,7 @@ def TouchSerialPort(env, port, baudrate):
|
|||||||
|
|
||||||
|
|
||||||
def WaitForNewSerialPort(env, before):
|
def WaitForNewSerialPort(env, before):
|
||||||
print ("Waiting for the new upload port...")
|
print("Waiting for the new upload port...")
|
||||||
prev_port = env.subst("$UPLOAD_PORT")
|
prev_port = env.subst("$UPLOAD_PORT")
|
||||||
new_port = None
|
new_port = None
|
||||||
elapsed = 0
|
elapsed = 0
|
||||||
@ -145,7 +145,7 @@ def AutodetectUploadPort(*args, **kwargs):
|
|||||||
return port
|
return port
|
||||||
|
|
||||||
if "UPLOAD_PORT" in env and not _get_pattern():
|
if "UPLOAD_PORT" in env and not _get_pattern():
|
||||||
print (env.subst("Use manually specified: $UPLOAD_PORT"))
|
print(env.subst("Use manually specified: $UPLOAD_PORT"))
|
||||||
return
|
return
|
||||||
|
|
||||||
if env.subst("$UPLOAD_PROTOCOL") == "mbed" or (
|
if env.subst("$UPLOAD_PROTOCOL") == "mbed" or (
|
||||||
@ -160,7 +160,7 @@ def AutodetectUploadPort(*args, **kwargs):
|
|||||||
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"):
|
||||||
print (env.subst("Auto-detected: $UPLOAD_PORT"))
|
print(env.subst("Auto-detected: $UPLOAD_PORT"))
|
||||||
else:
|
else:
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
"Error: Please specify `upload_port` for environment or use "
|
"Error: Please specify `upload_port` for environment or use "
|
||||||
@ -179,7 +179,7 @@ def UploadToDisk(_, target, source, env):
|
|||||||
if not isfile(fpath):
|
if not isfile(fpath):
|
||||||
continue
|
continue
|
||||||
copyfile(fpath, join(env.subst("$UPLOAD_PORT"), "%s.%s" % (progname, ext)))
|
copyfile(fpath, join(env.subst("$UPLOAD_PORT"), "%s.%s" % (progname, ext)))
|
||||||
print (
|
print(
|
||||||
"Firmware has been successfully uploaded.\n"
|
"Firmware has been successfully uploaded.\n"
|
||||||
"(Some boards may require manual hard reset)"
|
"(Some boards may require manual hard reset)"
|
||||||
)
|
)
|
||||||
@ -249,13 +249,13 @@ def CheckUploadSize(_, target, source, env):
|
|||||||
program_size = _calculate_size(output, env.get("SIZEPROGREGEXP"))
|
program_size = _calculate_size(output, env.get("SIZEPROGREGEXP"))
|
||||||
data_size = _calculate_size(output, env.get("SIZEDATAREGEXP"))
|
data_size = _calculate_size(output, env.get("SIZEDATAREGEXP"))
|
||||||
|
|
||||||
print ('Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"')
|
print('Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"')
|
||||||
if data_max_size and data_size > -1:
|
if data_max_size and data_size > -1:
|
||||||
print ("DATA: %s" % _format_availale_bytes(data_size, data_max_size))
|
print("DATA: %s" % _format_availale_bytes(data_size, data_max_size))
|
||||||
if program_size > -1:
|
if program_size > -1:
|
||||||
print ("PROGRAM: %s" % _format_availale_bytes(program_size, program_max_size))
|
print("PROGRAM: %s" % _format_availale_bytes(program_size, program_max_size))
|
||||||
if int(ARGUMENTS.get("PIOVERBOSE", 0)):
|
if int(ARGUMENTS.get("PIOVERBOSE", 0)):
|
||||||
print (output)
|
print(output)
|
||||||
|
|
||||||
# raise error
|
# raise error
|
||||||
# if data_max_size and data_size > data_max_size:
|
# if data_max_size and data_size > data_max_size:
|
||||||
@ -277,9 +277,9 @@ def PrintUploadInfo(env):
|
|||||||
if "BOARD" in env:
|
if "BOARD" in env:
|
||||||
available.extend(env.BoardConfig().get("upload", {}).get("protocols", []))
|
available.extend(env.BoardConfig().get("upload", {}).get("protocols", []))
|
||||||
if available:
|
if available:
|
||||||
print ("AVAILABLE: %s" % ", ".join(sorted(set(available))))
|
print("AVAILABLE: %s" % ", ".join(sorted(set(available))))
|
||||||
if configured:
|
if configured:
|
||||||
print ("CURRENT: upload_protocol = %s" % configured)
|
print("CURRENT: upload_protocol = %s" % configured)
|
||||||
|
|
||||||
|
|
||||||
def exists(_):
|
def exists(_):
|
||||||
|
@ -397,4 +397,4 @@ ProjectOptions = OrderedDict(
|
|||||||
|
|
||||||
|
|
||||||
def get_config_options_schema():
|
def get_config_options_schema():
|
||||||
return [option.as_dict() for option in ProjectOptions.values()]
|
return [opt.as_dict() for opt in ProjectOptions.values()]
|
||||||
|
Reference in New Issue
Block a user