diff --git a/platformio/app.py b/platformio/app.py index 5ac23d11..ef850a55 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -264,8 +264,10 @@ def set_session_var(name, value): def is_disabled_progressbar(): - return any([get_session_var("force_option"), util.is_ci(), - getenv("PLATFORMIO_DISABLE_PROGRESSBAR") == "true"]) + return any([ + get_session_var("force_option"), util.is_ci(), + getenv("PLATFORMIO_DISABLE_PROGRESSBAR") == "true" + ]) def get_cid(): @@ -282,7 +284,7 @@ def get_cid(): except: # pylint: disable=bare-except pass cid = str( - uuid.UUID(bytes=hashlib.md5(str(_uid if _uid else uuid.getnode())) - .digest())) + uuid.UUID(bytes=hashlib.md5( + str(_uid if _uid else uuid.getnode())).digest())) set_state_item("cid", cid) return cid diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 359199cc..a710aefc 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -67,9 +67,8 @@ commonvars.AddVariables( DEFAULT_ENV_OPTIONS = dict( tools=[ - "ar", "as", "gcc", "g++", "gnulink", - "platformio", "pioplatform", "piowinhooks", - "piolib", "piotest", "pioupload", "piomisc" + "ar", "as", "gcc", "g++", "gnulink", "platformio", "pioplatform", + "piowinhooks", "piolib", "piotest", "pioupload", "piomisc" ], # yapf: disable toolpath=[join(util.get_source_dir(), "builder", "tools")], variables=commonvars, diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 20c8b893..6b3100e7 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -51,8 +51,10 @@ class LibBuilderFactory(object): @staticmethod def get_used_frameworks(env, path): - if any([isfile(join(path, fname)) - for fname in ("library.properties", "keywords.txt")]): + if any([ + isfile(join(path, fname)) + for fname in ("library.properties", "keywords.txt") + ]): return ["arduino"] if isfile(join(path, "module.json")): @@ -71,6 +73,7 @@ class LibBuilderFactory(object): return ["mbed"] return [] + # pylint: disable=too-many-instance-attributes, too-many-public-methods @@ -200,10 +203,8 @@ class LibBuilderBase(object): if self.extra_script: self.env.SConscript( realpath(self.extra_script), - exports={ - "env": self.env, - "pio_lib_builder": self - }) + exports={"env": self.env, + "pio_lib_builder": self}) def _process_dependencies(self, lib_builders): if not self.dependencies: diff --git a/platformio/builder/tools/piotest.py b/platformio/builder/tools/piotest.py index e79584a3..573f562f 100644 --- a/platformio/builder/tools/piotest.py +++ b/platformio/builder/tools/piotest.py @@ -19,12 +19,8 @@ from os.path import join, sep def ProcessTest(env): env.Append( - CPPDEFINES=[ - "UNIT_TEST", "UNITY_INCLUDE_CONFIG_H" - ], - CPPPATH=[ - join("$BUILD_DIR", "UnityTestLib") - ]) + CPPDEFINES=["UNIT_TEST", "UNITY_INCLUDE_CONFIG_H"], + CPPPATH=[join("$BUILD_DIR", "UnityTestLib")]) unitylib = env.BuildLibrary( join("$BUILD_DIR", "UnityTestLib"), env.PioPlatform().get_package_dir("tool-unity")) diff --git a/platformio/builder/tools/pioupload.py b/platformio/builder/tools/pioupload.py index e78df88e..3ea7b9fe 100644 --- a/platformio/builder/tools/pioupload.py +++ b/platformio/builder/tools/pioupload.py @@ -146,8 +146,8 @@ def UploadToDisk(_, target, source, env): # pylint: disable=W0613,W0621 fpath = join(env.subst("$BUILD_DIR"), "%s.%s" % (progname, ext)) if not isfile(fpath): continue - copyfile(fpath, join( - env.subst("$UPLOAD_PORT"), "%s.%s" % (progname, ext))) + 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)" @@ -161,8 +161,10 @@ def CheckUploadSize(_, target, source, env): # pylint: disable=W0613,W0621 sysenv = environ.copy() sysenv['PATH'] = str(env['ENV']['PATH']) - cmd = [env.subst("$SIZETOOL"), "-B", - str(source[0] if isinstance(target[0], Alias) else target[0])] + cmd = [ + env.subst("$SIZETOOL"), "-B", + str(source[0] if isinstance(target[0], Alias) else target[0]) + ] result = util.exec_command(cmd, env=sysenv) if result['returncode'] != 0: return diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index f49b3b2d..6970d3a5 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -35,8 +35,9 @@ SRC_FILTER_DEFAULT = ["+<*>", "-<.git%s>" % sep, "-" % sep] def BuildProgram(env): def _append_pio_macros(): - env.AppendUnique(CPPDEFINES=["PLATFORMIO={0:02d}{1:02d}{2:02d}".format( - *pioversion_to_intstr())]) + env.AppendUnique(CPPDEFINES=[ + "PLATFORMIO={0:02d}{1:02d}{2:02d}".format(*pioversion_to_intstr()) + ]) _append_pio_macros() @@ -130,8 +131,10 @@ def ProcessFlags(env, flags): # Cancel any previous definition of name, either built in or # provided with a -D option // Issue #191 - undefines = [u for u in env.get("CCFLAGS", []) - if isinstance(u, basestring) and u.startswith("-U")] + undefines = [ + u for u in env.get("CCFLAGS", []) + if isinstance(u, basestring) and u.startswith("-U") + ] if undefines: for undef in undefines: env['CCFLAGS'].remove(undef) diff --git a/platformio/commands/ci.py b/platformio/commands/ci.py index 39e328db..e74abb18 100644 --- a/platformio/commands/ci.py +++ b/platformio/commands/ci.py @@ -73,16 +73,9 @@ def validate_path(ctx, param, value): # pylint: disable=unused-argument @click.option("-O", "--project-option", multiple=True) @click.option("-v", "--verbose", is_flag=True) @click.pass_context -def cli(ctx, # pylint: disable=R0913 - src, - lib, - exclude, - board, - build_dir, - keep_build_dir, - project_conf, - project_option, - verbose): +def cli( # pylint: disable=too-many-arguments + ctx, src, lib, exclude, board, build_dir, keep_build_dir, project_conf, + project_option, verbose): if not src and getenv("PLATFORMIO_CI_SRC"): src = validate_path(ctx, None, getenv("PLATFORMIO_CI_SRC").split(":")) diff --git a/platformio/commands/init.py b/platformio/commands/init.py index 11ae6932..fa6cdc19 100644 --- a/platformio/commands/init.py +++ b/platformio/commands/init.py @@ -58,7 +58,8 @@ def validate_boards(ctx, param, value): # pylint: disable=W0613 @click.option("-O", "--project-option", multiple=True) @click.option("--env-prefix", default="") @click.pass_context -def cli(ctx, # pylint: disable=R0913 +def cli( + ctx, # pylint: disable=R0913 project_dir, board, ide, @@ -292,10 +293,11 @@ def fill_project_envs(ctx, project_dir, board_ids, project_option, env_prefix, config = util.load_project_config(project_dir) for section in config.sections(): - if not all([section.startswith("env:"), - config.has_option(section, "board")]): - continue - used_boards.append(config.get(section, "board")) + cond = [ + section.startswith("env:"), config.has_option(section, "board") + ] + if all(cond): + used_boards.append(config.get(section, "board")) pm = PlatformManager() for id_ in board_ids: diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index f67af7ab..90e72b93 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -113,6 +113,7 @@ def lib_update(lm, libraries, only_check): for library in libraries: lm.update(library, only_check=only_check) + ####### LIBLIST_TPL = ("[{id:^14}] {name:<25} {compatibility:<30} " diff --git a/platformio/commands/run.py b/platformio/commands/run.py index bd06ae22..27fcc269 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -87,9 +87,10 @@ def cli(ctx, environment, target, upload_port, project_dir, silent, verbose, continue envname = section[4:] - skipenv = any([environment and envname not in environment, - not environment and env_default and - envname not in env_default]) + skipenv = any([ + environment and envname not in environment, not environment and + env_default and envname not in env_default + ]) if skipenv: results[envname] = None continue @@ -133,14 +134,15 @@ class EnvironmentProcessor(object): RENAMED_PLATFORMS = {"espressif": "espressif8266"} - def __init__(self, # pylint: disable=R0913 - cmd_ctx, - name, - options, - targets, - upload_port, - silent, - verbose): + def __init__( + self, # pylint: disable=R0913 + cmd_ctx, + name, + options, + targets, + upload_port, + silent, + verbose): self.cmd_ctx = cmd_ctx self.name = name self.options = options diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index ef613fc8..33a30bc0 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -33,9 +33,11 @@ def cli(): click.secho("Please wait while upgrading PlatformIO ...", fg="yellow") to_develop = not all([c.isdigit() for c in latest if c != "."]) - cmds = (["pip", "install", "--upgrade", - "https://github.com/platformio/platformio/archive/develop.zip" - if to_develop else "platformio"], ["platformio", "--version"]) + cmds = ([ + "pip", "install", "--upgrade", + "https://github.com/platformio/platformio/archive/develop.zip" + if to_develop else "platformio" + ], ["platformio", "--version"]) cmd = None r = None @@ -81,8 +83,8 @@ WARNING! Don't use `sudo` for the rest PlatformIO commands. err=True) raise exception.ReturnErrorCode() else: - raise exception.UpgradeError("\n".join([str(cmd), r['out'], r[ - 'err']])) + raise exception.UpgradeError("\n".join( + [str(cmd), r['out'], r['err']])) def get_latest_version(): diff --git a/platformio/ide/projectgenerator.py b/platformio/ide/projectgenerator.py index 03df1840..662636af 100644 --- a/platformio/ide/projectgenerator.py +++ b/platformio/ide/projectgenerator.py @@ -38,8 +38,8 @@ class ProjectGenerator(object): @staticmethod def get_supported_ides(): tpls_dir = join(util.get_source_dir(), "ide", "tpls") - return sorted([d for d in os.listdir(tpls_dir) - if isdir(join(tpls_dir, d))]) + return sorted( + [d for d in os.listdir(tpls_dir) if isdir(join(tpls_dir, d))]) @util.memoized def get_project_env(self): @@ -69,8 +69,8 @@ class ProjectGenerator(object): result = util.exec_command(cmd) if result['returncode'] != 0 or '"includes":' not in result['out']: - raise exception.PlatformioException("\n".join([result['out'], - result['err']])) + raise exception.PlatformioException("\n".join( + [result['out'], result['err']])) output = result['out'] start_index = output.index('{"') diff --git a/platformio/maintenance.py b/platformio/maintenance.py index 498f441a..51b77164 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -142,8 +142,9 @@ class Upgrader(object): @staticmethod def _upgrade_to_3_0_0b11(ctx): - current_platforms = [m['name'] - for m in PlatformManager().get_installed()] + current_platforms = [ + m['name'] for m in PlatformManager().get_installed() + ] if "espressif" not in current_platforms: return ctx.invoke(cmd_platform_install, platforms=["espressif8266"]) diff --git a/platformio/managers/lib.py b/platformio/managers/lib.py index fec5020f..0949df37 100644 --- a/platformio/managers/lib.py +++ b/platformio/managers/lib.py @@ -120,8 +120,9 @@ class LibraryManager(BasePkgManager): if item[k] == "*": del item[k] elif isinstance(item[k], basestring): - item[k] = [i.strip() for i in item[k].split(",") - if i.strip()] + item[k] = [ + i.strip() for i in item[k].split(",") if i.strip() + ] return items @staticmethod diff --git a/platformio/managers/package.py b/platformio/managers/package.py index d948e624..6f10bc38 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -164,8 +164,9 @@ class PkgInstallerMixin(object): if not pkgdata: continue try: - pkg_dir = self._install_from_url( - name, pkgdata['url'], requirements, pkgdata.get("sha1")) + pkg_dir = self._install_from_url(name, pkgdata['url'], + requirements, + pkgdata.get("sha1")) break except Exception as e: # pylint: disable=broad-except click.secho("Warning! Package Mirror: %s" % e, fg="yellow") @@ -240,8 +241,9 @@ class PkgInstallerMixin(object): curmanifest['version'], partial=True) # if current package version < new package, backup it if tmpmanver > curmanver: - os.rename(pkg_dir, join(self.package_dir, "%s@%s" % ( - name, curmanifest['version']))) + os.rename(pkg_dir, + join(self.package_dir, "%s@%s" % + (name, curmanifest['version']))) elif tmpmanver < curmanver: pkg_dir = join(self.package_dir, "%s@%s" % (name, tmpmanifest['version'])) @@ -492,10 +494,11 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): label=manifest['name']) return True - def update(self, # pylint: disable=too-many-return-statements - name, - requirements=None, - only_check=False): + def update( # pylint: disable=too-many-return-statements + self, + name, + requirements=None, + only_check=False): name, requirements, url = self.parse_pkg_name(name, requirements) package_dir = self.get_package_dir(name, None, url) if not package_dir: diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index c0b9beac..a7e997c7 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -42,13 +42,13 @@ class PlatformManager(BasePkgManager): def manifest_name(self): return "platform.json" - def install(self, # pylint: disable=too-many-arguments + def install(self, name, requirements=None, with_packages=None, without_packages=None, skip_default_package=False, - **_): + **_): # pylint: disable=too-many-arguments platform_dir = BasePkgManager.install(self, name, requirements) p = PlatformFactory.newPlatform(self.get_manifest_path(platform_dir)) p.install_packages(with_packages, without_packages, @@ -66,8 +66,12 @@ class PlatformManager(BasePkgManager): self.cleanup_packages(p.packages.keys()) return True - def update(self, # pylint: disable=arguments-differ - name, requirements=None, only_packages=False, only_check=False): + def update( # pylint: disable=arguments-differ + self, + name, + requirements=None, + only_packages=False, + only_check=False): name, requirements, _ = self.parse_pkg_name(name, requirements) if not only_packages: BasePkgManager.update(self, name, requirements, only_check) diff --git a/platformio/pioplus.py b/platformio/pioplus.py index 85aef9d3..2dbdf9c4 100644 --- a/platformio/pioplus.py +++ b/platformio/pioplus.py @@ -20,21 +20,29 @@ from platform import system from platformio import app, exception, util from platformio.managers.package import PackageManager -PACKAGE_DEPS = {"pysite": {"name": "pysite-pioplus", - "requirements": ">=0.1.0"}, - "tool": {"name": "tool-pioplus", - "requirements": ">=0.3.0"}} +PACKAGE_DEPS = { + "pysite": { + "name": "pysite-pioplus", + "requirements": ">=0.1.0" + }, + "tool": { + "name": "tool-pioplus", + "requirements": ">=0.3.0" + } +} class PioPlusPackageManager(PackageManager): def __init__(self): - PackageManager.__init__(self, join(util.get_home_dir(), "packages"), [ - "https://dl.bintray.com/platformio/dl-packages/manifest.json", - "https://sourceforge.net/projects/platformio-storage/files/" - "packages/manifest.json/download", - "https://dl.platformio.org/packages/manifest.json" - ]) + PackageManager.__init__( + self, + join(util.get_home_dir(), "packages"), [ + "https://dl.bintray.com/platformio/dl-packages/manifest.json", + "https://sourceforge.net/projects/platformio-storage/files/" + "packages/manifest.json/download", + "https://dl.platformio.org/packages/manifest.json" + ]) def pioplus_install(): diff --git a/platformio/telemetry.py b/platformio/telemetry.py index 6d7d2a95..abefc23f 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.py @@ -227,12 +227,22 @@ def measure_ci(): event = {"category": "CI", "action": "NoName", "label": None} envmap = { - "APPVEYOR": {"label": getenv("APPVEYOR_REPO_NAME")}, - "CIRCLECI": {"label": "%s/%s" % (getenv("CIRCLE_PROJECT_USERNAME"), - getenv("CIRCLE_PROJECT_REPONAME"))}, - "TRAVIS": {"label": getenv("TRAVIS_REPO_SLUG")}, - "SHIPPABLE": {"label": getenv("REPO_NAME")}, - "DRONE": {"label": getenv("DRONE_REPO_SLUG")} + "APPVEYOR": { + "label": getenv("APPVEYOR_REPO_NAME") + }, + "CIRCLECI": { + "label": "%s/%s" % (getenv("CIRCLE_PROJECT_USERNAME"), + getenv("CIRCLE_PROJECT_REPONAME")) + }, + "TRAVIS": { + "label": getenv("TRAVIS_REPO_SLUG") + }, + "SHIPPABLE": { + "label": getenv("REPO_NAME") + }, + "DRONE": { + "label": getenv("DRONE_REPO_SLUG") + } } for key, value in envmap.iteritems(): @@ -263,10 +273,11 @@ def on_event(category, action, label=None, value=None, screen_name=None): def on_exception(e): - skip = any( - [isinstance(e, cls) - for cls in (IOError, exception.AbortedByUser, - exception.NotGlobalLibDir, exception.InternetIsOffline)]) + skip = any([ + isinstance(e, cls) + for cls in (IOError, exception.AbortedByUser, + exception.NotGlobalLibDir, exception.InternetIsOffline) + ]) if skip: return is_crash = any([ diff --git a/platformio/util.py b/platformio/util.py index 4942a01d..4247132e 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -254,13 +254,13 @@ def get_projectsrc_dir(): def get_projecttest_dir(): - return _get_projconf_option_dir("test_dir", join(get_project_dir(), - "test")) + return _get_projconf_option_dir("test_dir", + join(get_project_dir(), "test")) def get_projectboards_dir(): - return _get_projconf_option_dir("boards_dir", join(get_project_dir(), - "boards")) + return _get_projconf_option_dir("boards_dir", + join(get_project_dir(), "boards")) def get_projectpioenvs_dir(force=False): @@ -417,10 +417,11 @@ def _api_request_session(): return requests.Session() -def _get_api_result(url, # pylint: disable=too-many-branches - params=None, - data=None, - auth=None): +def _get_api_result( + url, # pylint: disable=too-many-branches + params=None, + data=None, + auth=None): from platformio.app import get_setting result = None diff --git a/platformio/vcsclient.py b/platformio/vcsclient.py index a509302b..2f271968 100644 --- a/platformio/vcsclient.py +++ b/platformio/vcsclient.py @@ -177,8 +177,9 @@ class SvnClient(VCSClientBase): return self.run_cmd(args) def get_current_revision(self): - output = self.get_cmd_output(["info", "--non-interactive", - "--trust-server-cert", "-r", "HEAD"]) + output = self.get_cmd_output([ + "info", "--non-interactive", "--trust-server-cert", "-r", "HEAD" + ]) for line in output.split("\n"): line = line.strip() if line.startswith("Revision:"):