forked from platformio/platformio-core
Make "print" compatible between Py2 & Py3
This commit is contained in:
@ -20,4 +20,4 @@ confidence=
|
||||
# --disable=W"
|
||||
# disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating
|
||||
|
||||
disable=locally-disabled,missing-docstring,invalid-name,too-few-public-methods,redefined-variable-type,import-error,similarities,unsupported-membership-test,unsubscriptable-object,ungrouped-imports,cyclic-import
|
||||
disable=locally-disabled,missing-docstring,invalid-name,too-few-public-methods,redefined-variable-type,import-error,similarities,unsupported-membership-test,unsubscriptable-object,ungrouped-imports,cyclic-import,superfluous-parens
|
||||
|
@ -135,7 +135,7 @@ if env.GetOption('clean'):
|
||||
env.PioClean(env.subst("$BUILD_DIR"))
|
||||
env.Exit(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")
|
||||
|
||||
# Handle custom variables from system environment
|
||||
for var in ("BUILD_FLAGS", "SRC_BUILD_FLAGS", "SRC_FILTER", "EXTRA_SCRIPTS",
|
||||
@ -198,13 +198,13 @@ AlwaysBuild(env.Alias("__test", DEFAULT_TARGETS))
|
||||
##############################################################################
|
||||
|
||||
if "envdump" in COMMAND_LINE_TARGETS:
|
||||
print env.Dump()
|
||||
print(env.Dump())
|
||||
env.Exit(0)
|
||||
|
||||
if "idedata" in COMMAND_LINE_TARGETS:
|
||||
try:
|
||||
print "\n%s\n" % util.path_to_unicode(
|
||||
json.dumps(env.DumpIDEData(), ensure_ascii=False))
|
||||
print("\n%s\n" % util.path_to_unicode(
|
||||
json.dumps(env.DumpIDEData(), ensure_ascii=False)))
|
||||
env.Exit(0)
|
||||
except UnicodeDecodeError:
|
||||
sys.stderr.write(
|
||||
|
@ -373,7 +373,7 @@ class LibBuilderBase(object):
|
||||
if isfile("%s.%s" % (_f_part, ext)):
|
||||
incs.append(
|
||||
self.env.File("%s.%s" % (_f_part, ext)))
|
||||
# print path, map(lambda n: n.get_abspath(), incs)
|
||||
# print(path, map(lambda n: n.get_abspath(), incs))
|
||||
for inc in incs:
|
||||
if inc not in result:
|
||||
result.append(inc)
|
||||
@ -851,24 +851,24 @@ def ConfigureProjectLibBuilder(env):
|
||||
project = ProjectAsLibBuilder(env, "$PROJECT_DIR")
|
||||
ldf_mode = LibBuilderBase.lib_ldf_mode.fget(project)
|
||||
|
||||
print "Library Dependency Finder -> http://bit.ly/configure-pio-ldf"
|
||||
print "LDF MODES: FINDER(%s) COMPATIBILITY(%s)" % (ldf_mode,
|
||||
project.lib_compat_mode)
|
||||
print("Library Dependency Finder -> http://bit.ly/configure-pio-ldf")
|
||||
print("LDF MODES: FINDER(%s) COMPATIBILITY(%s)" %
|
||||
(ldf_mode, project.lib_compat_mode))
|
||||
|
||||
lib_builders = env.GetLibBuilders()
|
||||
print "Collected %d compatible libraries" % len(lib_builders)
|
||||
print("Collected %d compatible libraries" % len(lib_builders))
|
||||
|
||||
print "Scanning dependencies..."
|
||||
print("Scanning dependencies...")
|
||||
project.search_deps_recursive()
|
||||
|
||||
if ldf_mode.startswith("chain") and project.depbuilders:
|
||||
correct_found_libs(lib_builders)
|
||||
|
||||
if project.depbuilders:
|
||||
print "Dependency Graph"
|
||||
print("Dependency Graph")
|
||||
print_deps_tree(project)
|
||||
else:
|
||||
print "No dependencies"
|
||||
print("No dependencies")
|
||||
|
||||
return project
|
||||
|
||||
|
@ -274,13 +274,13 @@ def VerboseAction(_, act, actstr):
|
||||
|
||||
def PioClean(env, clean_dir):
|
||||
if not isdir(clean_dir):
|
||||
print "Build environment is clean"
|
||||
print("Build environment is clean")
|
||||
env.Exit(0)
|
||||
for root, _, files in walk(clean_dir):
|
||||
for file_ in files:
|
||||
remove(join(root, file_))
|
||||
print "Removed %s" % relpath(join(root, file_))
|
||||
print "Done cleaning"
|
||||
print("Removed %s" % relpath(join(root, file_)))
|
||||
print("Done cleaning")
|
||||
util.rmtree_(clean_dir)
|
||||
env.Exit(0)
|
||||
|
||||
|
@ -150,7 +150,7 @@ def PrintConfiguration(env):
|
||||
|
||||
for data in (configuration_data, platform_data, system_data):
|
||||
if len(data) > 1:
|
||||
print " ".join(data)
|
||||
print(" ".join(data))
|
||||
|
||||
# Debugging
|
||||
if not debug_tools:
|
||||
@ -172,7 +172,7 @@ def PrintConfiguration(env):
|
||||
if external:
|
||||
data.append("EXTERNAL(%s)" % ", ".join(sorted(external)))
|
||||
|
||||
print "DEBUG: %s" % " ".join(data)
|
||||
print("DEBUG: %s" % " ".join(data))
|
||||
|
||||
|
||||
def exists(_):
|
||||
|
@ -43,7 +43,7 @@ def FlushSerialBuffer(env, port):
|
||||
|
||||
def TouchSerialPort(env, port, baudrate):
|
||||
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:
|
||||
s = Serial(port=port, baudrate=baudrate)
|
||||
s.setDTR(False)
|
||||
@ -54,7 +54,7 @@ def TouchSerialPort(env, port, baudrate):
|
||||
|
||||
|
||||
def WaitForNewSerialPort(env, before):
|
||||
print "Waiting for the new upload port..."
|
||||
print("Waiting for the new upload port...")
|
||||
prev_port = env.subst("$UPLOAD_PORT")
|
||||
new_port = None
|
||||
elapsed = 0
|
||||
@ -146,7 +146,7 @@ def AutodetectUploadPort(*args, **kwargs):
|
||||
return port
|
||||
|
||||
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
|
||||
|
||||
if (env.subst("$UPLOAD_PROTOCOL") == "mbed"
|
||||
@ -161,7 +161,7 @@ def AutodetectUploadPort(*args, **kwargs):
|
||||
env.Replace(UPLOAD_PORT=_look_for_serial_port())
|
||||
|
||||
if env.subst("$UPLOAD_PORT"):
|
||||
print env.subst("Auto-detected: $UPLOAD_PORT")
|
||||
print(env.subst("Auto-detected: $UPLOAD_PORT"))
|
||||
else:
|
||||
sys.stderr.write(
|
||||
"Error: Please specify `upload_port` for environment or use "
|
||||
@ -180,8 +180,8 @@ def UploadToDisk(_, target, source, env):
|
||||
continue
|
||||
copyfile(fpath,
|
||||
join(env.subst("$UPLOAD_PORT"), "%s.%s" % (progname, ext)))
|
||||
print "Firmware has been successfully uploaded.\n"\
|
||||
"(Some boards may require manual hard reset)"
|
||||
print("Firmware has been successfully uploaded.\n"
|
||||
"(Some boards may require manual hard reset)")
|
||||
|
||||
|
||||
def CheckUploadSize(_, target, source, env):
|
||||
@ -246,14 +246,14 @@ def CheckUploadSize(_, target, source, env):
|
||||
program_size = _calculate_size(output, env.get("SIZEPROGREGEXP"))
|
||||
data_size = _calculate_size(output, env.get("SIZEDATAREGEXP"))
|
||||
|
||||
print "Memory Usage -> http://bit.ly/pio-memory-usage"
|
||||
print("Memory Usage -> http://bit.ly/pio-memory-usage")
|
||||
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:
|
||||
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)):
|
||||
print output
|
||||
print(output)
|
||||
|
||||
# raise error
|
||||
# if data_max_size and data_size > data_max_size:
|
||||
@ -275,9 +275,9 @@ def PrintUploadInfo(env):
|
||||
available.extend(env.BoardConfig().get("upload", {}).get(
|
||||
"protocols", []))
|
||||
if available:
|
||||
print "AVAILABLE: %s" % ", ".join(sorted(set(available)))
|
||||
print("AVAILABLE: %s" % ", ".join(sorted(set(available))))
|
||||
if configured:
|
||||
print "CURRENT: upload_protocol = %s" % configured
|
||||
print("CURRENT: upload_protocol = %s" % configured)
|
||||
|
||||
|
||||
def exists(_):
|
||||
|
@ -100,7 +100,7 @@ class AsyncPipe(Thread):
|
||||
if self.outcallback:
|
||||
self.outcallback(line)
|
||||
else:
|
||||
print line
|
||||
print(line)
|
||||
self._pipe_reader.close()
|
||||
|
||||
def close(self):
|
||||
|
Reference in New Issue
Block a user