Skip to content

Commit

Permalink
Added support for Click 8.0; updated other deps
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed May 19, 2021
1 parent 2be7e0f commit 27feb1d
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 26 deletions.
2 changes: 1 addition & 1 deletion docs
3 changes: 2 additions & 1 deletion platformio/commands/boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import json
import shutil

import click
from tabulate import tabulate
Expand Down Expand Up @@ -40,7 +41,7 @@ def cli(query, installed, json_output): # pylint: disable=R0912
grpboards[board["platform"]] = []
grpboards[board["platform"]].append(board)

terminal_width, _ = click.get_terminal_size()
terminal_width, _ = shutil.get_terminal_size()
for (platform, boards) in sorted(grpboards.items()):
click.echo("")
click.echo("Platform: ", nl=False)
Expand Down
3 changes: 2 additions & 1 deletion platformio/commands/check/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import json
import os
import shutil
from collections import Counter
from os.path import dirname, isfile
from time import time
Expand Down Expand Up @@ -193,7 +194,7 @@ def print_processing_header(tool, envname, envdump):
"Checking %s > %s (%s)"
% (click.style(envname, fg="cyan", bold=True), tool, "; ".join(envdump))
)
terminal_width, _ = click.get_terminal_size()
terminal_width, _ = shutil.get_terminal_size()
click.secho("-" * terminal_width, bold=True)


Expand Down
3 changes: 2 additions & 1 deletion platformio/commands/run/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import operator
import os
import shutil
from multiprocessing import cpu_count
from time import time

Expand Down Expand Up @@ -200,7 +201,7 @@ def print_processing_header(env, config, verbose=False):
"Processing %s (%s)"
% (click.style(env, fg="cyan", bold=True), "; ".join(env_dump))
)
terminal_width, _ = click.get_terminal_size()
terminal_width, _ = shutil.get_terminal_size()
click.secho("-" * terminal_width, bold=True)


Expand Down
3 changes: 2 additions & 1 deletion platformio/commands/test/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import fnmatch
import os
import shutil
from time import time

import click
Expand Down Expand Up @@ -192,7 +193,7 @@ def print_processing_header(test, env):
click.style(env, fg="cyan", bold=True),
)
)
terminal_width, _ = click.get_terminal_size()
terminal_width, _ = shutil.get_terminal_size()
click.secho("-" * terminal_width, bold=True)


Expand Down
30 changes: 15 additions & 15 deletions platformio/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from os import getenv
from os.path import join
import os
import shutil
from time import time

import click
Expand Down Expand Up @@ -75,19 +75,19 @@ def on_platformio_exception(e):


def set_caller(caller=None):
caller = caller or getenv("PLATFORMIO_CALLER")
caller = caller or os.getenv("PLATFORMIO_CALLER")
if caller:
return app.set_session_var("caller_id", caller)
if getenv("VSCODE_PID") or getenv("VSCODE_NLS_CONFIG"):
if os.getenv("VSCODE_PID") or os.getenv("VSCODE_NLS_CONFIG"):
caller = "vscode"
elif getenv("GITPOD_INSTANCE_ID") or getenv("GITPOD_WORKSPACE_URL"):
elif os.getenv("GITPOD_INSTANCE_ID") or os.getenv("GITPOD_WORKSPACE_URL"):
caller = "gitpod"
elif is_container():
if getenv("C9_UID"):
if os.getenv("C9_UID"):
caller = "C9"
elif getenv("USER") == "cabox":
elif os.getenv("USER") == "cabox":
caller = "CA"
elif getenv("CHE_API", getenv("CHE_API_ENDPOINT")):
elif os.getenv("CHE_API", os.getenv("CHE_API_ENDPOINT")):
caller = "Che"
return app.set_session_var("caller_id", caller)

Expand Down Expand Up @@ -139,7 +139,7 @@ def _update_pkg_metadata(_):


def after_upgrade(ctx):
terminal_width, _ = click.get_terminal_size()
terminal_width, _ = shutil.get_terminal_size()
last_version = app.get_state_item("last_version", "0.0.0")
if last_version == __version__:
return
Expand Down Expand Up @@ -204,7 +204,7 @@ def after_upgrade(ctx):
click.style("https://github.com/platformio/platformio", fg="cyan"),
)
)
if not getenv("PLATFORMIO_IDE"):
if not os.getenv("PLATFORMIO_IDE"):
click.echo(
"- %s PlatformIO IDE for embedded development > %s"
% (
Expand Down Expand Up @@ -235,7 +235,7 @@ def check_platformio_upgrade():
if pepver_to_semver(latest_version) <= pepver_to_semver(__version__):
return

terminal_width, _ = click.get_terminal_size()
terminal_width, _ = shutil.get_terminal_size()

click.echo("")
click.echo("*" * terminal_width)
Expand All @@ -245,10 +245,10 @@ def check_platformio_upgrade():
fg="yellow",
nl=False,
)
if getenv("PLATFORMIO_IDE"):
if os.getenv("PLATFORMIO_IDE"):
click.secho("PlatformIO IDE Menu: Upgrade PlatformIO", fg="cyan", nl=False)
click.secho("`.", fg="yellow")
elif join("Cellar", "platformio") in fs.get_source_dir():
elif os.path.join("Cellar", "platformio") in fs.get_source_dir():
click.secho("brew update && brew upgrade", fg="cyan", nl=False)
click.secho("` command.", fg="yellow")
else:
Expand Down Expand Up @@ -288,7 +288,7 @@ def check_internal_updates(ctx, what): # pylint: disable=too-many-branches
if not outdated_items:
return

terminal_width, _ = click.get_terminal_size()
terminal_width, _ = shutil.get_terminal_size()

click.echo("")
click.echo("*" * terminal_width)
Expand Down Expand Up @@ -350,7 +350,7 @@ def check_prune_system():
if (unnecessary_size / 1024) < threshold_mb:
return

terminal_width, _ = click.get_terminal_size()
terminal_width, _ = shutil.get_terminal_size()
click.echo()
click.echo("*" * terminal_width)
click.secho(
Expand Down
4 changes: 2 additions & 2 deletions platformio/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
import json
import os
import re
import shutil
import sys
import threading
from collections import deque
from time import sleep, time
from traceback import format_exc

import click
import requests

from platformio import __version__, app, exception, util
Expand Down Expand Up @@ -74,7 +74,7 @@ def __init__(self):
self["cid"] = app.get_cid()

try:
self["sr"] = "%dx%d" % click.get_terminal_size()
self["sr"] = "%dx%d" % shutil.get_terminal_size()
except ValueError:
pass

Expand Down
3 changes: 2 additions & 1 deletion platformio/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import os
import platform
import re
import shutil
import time
from functools import wraps
from glob import glob
Expand Down Expand Up @@ -269,7 +270,7 @@ def merge_dicts(d1, d2, path=None):


def print_labeled_bar(label, is_error=False, fg=None):
terminal_width, _ = click.get_terminal_size()
terminal_width, _ = shutil.get_terminal_size()
width = len(click.unstyle(label))
half_line = "=" * int((terminal_width - width - 2) / 2)
click.secho("%s %s %s" % (half_line, label, half_line), fg=fg, err=is_error)
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

minimal_requirements = [
"bottle==0.12.*",
"click>=5,<8%s" % (",!=7.1,!=7.1.1" if WINDOWS else ""),
"click>=5,<9%s" % (",!=7.1,!=7.1.1" if WINDOWS else ""),
"colorama",
"marshmallow%s" % (">=2,<3" if PY2 else ">=2,<4"),
"pyelftools>=0.27,<1",
Expand All @@ -39,10 +39,10 @@
]

if not PY2:
minimal_requirements.append("zeroconf==0.29.*")
minimal_requirements.append("zeroconf==0.31.*")

home_requirements = [
"aiofiles==0.6.*",
"aiofiles==0.7.*",
"ajsonrpc==1.1.*",
"starlette==0.14.*",
"uvicorn==0.13.*",
Expand Down

0 comments on commit 27feb1d

Please sign in to comment.