'PlatformioCLI' object has no attribute 'resultcallback'

Bug #2033388 reported by Nuno Sucena Almeida
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
platformio (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

~$ pio
Traceback (most recent call last):
  File "/usr/bin/pio", line 33, in <module>
    sys.exit(load_entry_point('platformio==4.3.4', 'console_scripts', 'pio')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/pio", line 25, in importlib_load_entry_point
    return next(matches).load()
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 202, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3/dist-packages/platformio/__main__.py", line 66, in <module>
    @cli.resultcallback()
     ^^^^^^^^^^^^^^^^^^
AttributeError: 'PlatformioCLI' object has no attribute 'resultcallback'. Did you mean: 'result_callback'?

Seems related to https://github.com/platformio/platformio-core/issues/4075

ProblemType: Bug
DistroRelease: Ubuntu 23.04
Package: platformio 4.3.4-3
ProcVersionSignature: Ubuntu 6.2.0-27.28-generic 6.2.15
Uname: Linux 6.2.0-27-generic x86_64
ApportVersion: 2.26.1-0ubuntu2
Architecture: amd64
CasperMD5CheckResult: pass
CurrentDesktop: ubuntu:GNOME
Date: Tue Aug 29 06:07:18 2023
InstallationDate: Installed on 2023-07-22 (37 days ago)
InstallationMedia: Ubuntu 23.04 "Lunar Lobster" - Release amd64 (20230418)
PackageArchitecture: all
ProcEnviron:
 LANG=en_US.UTF-8
 PATH=(custom, no user)
 SHELL=/bin/bash
 TERM=xterm-256color
 XDG_RUNTIME_DIR=<set>
SourcePackage: platformio
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Nuno Sucena Almeida (slug-debian) wrote :
Revision history for this message
Nuno Sucena Almeida (slug-debian) wrote :
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "0007-result-callback.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Todd Fisher (taf2) wrote :

I tried out your patch and i think there is one issue which is easy to fix in the legacy Click case:

    @cli.resultcallback()

Should become:

    @cli.result_callback()

Otherwise this got the base command to run but any of the sub commands all fail with:

  File "/usr/bin/pio", line 33, in <module>
    sys.exit(load_entry_point('platformio==4.3.4', 'console_scripts', 'pio')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/platformio/__main__.py", line 129, in main
    maintenance.on_platformio_exception(e)
  File "/usr/lib/python3/dist-packages/platformio/maintenance.py", line 65, in on_platformio_exception
    telemetry.on_exception(e)
  File "/usr/lib/python3/dist-packages/platformio/telemetry.py", line 309, in on_exception
    send_exception(description, is_fatal)
  File "/usr/lib/python3/dist-packages/platformio/telemetry.py", line 381, in send_exception
    mp = MeasurementProtocol()
         ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/platformio/telemetry.py", line 77, in __init__
    self["sr"] = "%dx%d" % click.get_terminal_size()
                           ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'click' has no attribute 'get_terminal_size'

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in platformio (Ubuntu):
status: New → Confirmed
Revision history for this message
Emilio (emilio-moretti) wrote :

Newer versions of the "click" package have dropped get_terminal_size support. The latest version of platform io already imports it from shutil. The issue here is that the platformio package installed from the repositories is not compatible with the click version:

platformio/noble,noble,now 4.3.4-3
python3-click/noble,noble,now 8.1.6-2

Click>=8.0 is only supported since platformio 5.2 according to the commit information.

The right fix is to bump the platformio version from the repositories.

Tested on Ubuntu 24.04 beta.

Source:
https://github.com/platformio/platformio-core/commit/27feb1ddd79d310d8be69706042a4166cf3f5f74
https://github.com/pallets/click/pull/2130
https://github.com/tiangolo/typer/pull/375

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.