diff --git a/platformio/commands/debug/client.py b/platformio/commands/debug/client.py index 7e9aebb9..ac97243f 100644 --- a/platformio/commands/debug/client.py +++ b/platformio/commands/debug/client.py @@ -20,7 +20,10 @@ from hashlib import sha1 from os.path import abspath, basename, dirname, isdir, join, splitext from tempfile import mkdtemp -from twisted.internet import protocol, reactor, stdio, task +from twisted.internet import protocol # pylint: disable=import-error +from twisted.internet import reactor # pylint: disable=import-error +from twisted.internet import stdio # pylint: disable=import-error +from twisted.internet import task # pylint: disable=import-error from platformio import app, exception, util from platformio.commands.debug import helpers, initcfgs diff --git a/platformio/commands/debug/process.py b/platformio/commands/debug/process.py index 3f1fbd22..0079e18c 100644 --- a/platformio/commands/debug/process.py +++ b/platformio/commands/debug/process.py @@ -15,7 +15,7 @@ import os import click -from twisted.internet import protocol +from twisted.internet import protocol # pylint: disable=import-error from platformio import util from platformio.commands.debug import helpers diff --git a/platformio/commands/debug/server.py b/platformio/commands/debug/server.py index 977fe812..ca5c2a2e 100644 --- a/platformio/commands/debug/server.py +++ b/platformio/commands/debug/server.py @@ -15,7 +15,7 @@ import os from os.path import isdir, isfile, join -from twisted.internet import reactor +from twisted.internet import reactor # pylint: disable=import-error from platformio import exception, util from platformio.commands.debug import helpers diff --git a/platformio/commands/home/command.py b/platformio/commands/home/command.py index 0685670a..917187fb 100644 --- a/platformio/commands/home/command.py +++ b/platformio/commands/home/command.py @@ -33,9 +33,11 @@ from platformio.managers.core import (get_core_package_dir, def cli(port, host, no_open): # import contrib modules inject_contrib_pysite() + # pylint: disable=import-error from autobahn.twisted.resource import WebSocketResource from twisted.internet import reactor from twisted.web import server + # pylint: enable=import-error from platformio.commands.home.rpc.handlers.app import AppRPC from platformio.commands.home.rpc.handlers.ide import IDERPC from platformio.commands.home.rpc.handlers.misc import MiscRPC diff --git a/platformio/commands/home/helpers.py b/platformio/commands/home/helpers.py index abac9416..20b9503c 100644 --- a/platformio/commands/home/helpers.py +++ b/platformio/commands/home/helpers.py @@ -18,8 +18,9 @@ import os import socket import requests -from twisted.internet import threads -from twisted.internet.defer import ensureDeferred +from twisted.internet import defer # pylint: disable=import-error +from twisted.internet import reactor # pylint: disable=import-error +from twisted.internet import threads # pylint: disable=import-error from platformio import util @@ -28,7 +29,6 @@ class AsyncSession(requests.Session): def __init__(self, n=None, *args, **kwargs): if n: - from twisted.internet import reactor pool = reactor.getThreadPool() pool.adjustPoolsize(0, n) @@ -39,7 +39,7 @@ class AsyncSession(requests.Session): return threads.deferToThread(func, *args, **kwargs) def wrap(self, *args, **kwargs): # pylint: disable=no-self-use - return ensureDeferred(*args, **kwargs) + return defer.ensureDeferred(*args, **kwargs) @util.memoized(expire=5000) diff --git a/platformio/commands/home/rpc/handlers/ide.py b/platformio/commands/home/rpc/handlers/ide.py index d5c2bf74..5f8f31a4 100644 --- a/platformio/commands/home/rpc/handlers/ide.py +++ b/platformio/commands/home/rpc/handlers/ide.py @@ -14,8 +14,8 @@ import time -from jsonrpc.exceptions import JSONRPCDispatchException -from twisted.internet import defer +import jsonrpc # pylint: disable=import-error +from twisted.internet import defer # pylint: disable=import-error class IDERPC(object): @@ -25,7 +25,7 @@ class IDERPC(object): def send_command(self, command, params): if not self._queue: - raise JSONRPCDispatchException( + raise jsonrpc.exceptions.JSONRPCDispatchException( code=4005, message="PIO Home IDE agent is not started") while self._queue: self._queue.pop().callback({ diff --git a/platformio/commands/home/rpc/handlers/misc.py b/platformio/commands/home/rpc/handlers/misc.py index d7deff19..d3b53383 100644 --- a/platformio/commands/home/rpc/handlers/misc.py +++ b/platformio/commands/home/rpc/handlers/misc.py @@ -16,8 +16,8 @@ import json import re import time -from bs4 import BeautifulSoup -from twisted.internet import defer, reactor +from bs4 import BeautifulSoup # pylint: disable=import-error +from twisted.internet import defer, reactor # pylint: disable=import-error from platformio import app from platformio.commands.home import helpers diff --git a/platformio/commands/home/rpc/handlers/os.py b/platformio/commands/home/rpc/handlers/os.py index f581c469..780dbec8 100644 --- a/platformio/commands/home/rpc/handlers/os.py +++ b/platformio/commands/home/rpc/handlers/os.py @@ -22,7 +22,7 @@ from functools import cmp_to_key from os.path import expanduser, isdir, isfile, join import click -from twisted.internet import defer +from twisted.internet import defer # pylint: disable=import-error from platformio import app, util from platformio.commands.home import helpers diff --git a/platformio/commands/home/rpc/handlers/piocore.py b/platformio/commands/home/rpc/handlers/piocore.py index 85255a9c..80a642cb 100644 --- a/platformio/commands/home/rpc/handlers/piocore.py +++ b/platformio/commands/home/rpc/handlers/piocore.py @@ -19,8 +19,8 @@ import os import re import sys -from jsonrpc.exceptions import JSONRPCDispatchException -from twisted.internet.utils import getProcessOutputAndValue +import jsonrpc # pylint: disable=import-error +from twisted.internet import utils # pylint: disable=import-error from platformio import __version__, util from platformio.commands.home import helpers @@ -37,9 +37,9 @@ class PIOCoreRPC(object): arg, util.string_types) else str(arg) for arg in args ] except UnicodeError: - raise JSONRPCDispatchException( + raise jsonrpc.exceptions.JSONRPCDispatchException( code=4002, message="PIO Core: non-ASCII chars in arguments") - d = getProcessOutputAndValue( + d = utils.getProcessOutputAndValue( helpers.get_core_fullpath(), args, path=(options or {}).get("cwd"), @@ -73,7 +73,7 @@ class PIOCoreRPC(object): @staticmethod def _call_errback(failure): - raise JSONRPCDispatchException( + raise jsonrpc.exceptions.JSONRPCDispatchException( code=4003, message="PIO Core Call Error", data=failure.getErrorMessage()) diff --git a/platformio/commands/home/rpc/handlers/project.py b/platformio/commands/home/rpc/handlers/project.py index 02961ed8..2a4c4032 100644 --- a/platformio/commands/home/rpc/handlers/project.py +++ b/platformio/commands/home/rpc/handlers/project.py @@ -21,7 +21,7 @@ import time from os.path import (basename, expanduser, getmtime, isdir, isfile, join, realpath, sep) -from jsonrpc.exceptions import JSONRPCDispatchException +import jsonrpc # pylint: disable=import-error from platformio import exception, util from platformio.commands.home.rpc.handlers.app import AppRPC @@ -189,7 +189,7 @@ class ProjectRPC(object): for ext in ("ino", "pde") ]) if not is_arduino_project: - raise JSONRPCDispatchException( + raise jsonrpc.exceptions.JSONRPCDispatchException( code=4000, message="Not an Arduino project: %s" % arduino_project_dir) @@ -265,7 +265,7 @@ class ProjectRPC(object): @staticmethod def import_pio(project_dir): if not project_dir or not util.is_platformio_project(project_dir): - raise JSONRPCDispatchException( + raise jsonrpc.exceptions.JSONRPCDispatchException( code=4001, message="Not an PlatformIO project: %s" % project_dir) new_project_dir = join( diff --git a/platformio/commands/home/rpc/server.py b/platformio/commands/home/rpc/server.py index cd4f05b9..bf339994 100644 --- a/platformio/commands/home/rpc/server.py +++ b/platformio/commands/home/rpc/server.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=import-error + import json import jsonrpc diff --git a/platformio/commands/home/web.py b/platformio/commands/home/web.py index 313ce084..df48b1fa 100644 --- a/platformio/commands/home/web.py +++ b/platformio/commands/home/web.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from twisted.internet import reactor -from twisted.web import static +from twisted.internet import reactor # pylint: disable=import-error +from twisted.web import static # pylint: disable=import-error class WebRoot(static.File):