ddkasa / ulauncher-toggl-extension

Toggl time tracker extension for Ulauncher on Linux.
MIT License
5 stars 1 forks source link

Extension crashes when trying to parse project ID #2

Closed swantzter closed 4 months ago

swantzter commented 4 months ago

Hi,

I kept getting that the extension crashed before first launch and have tried running it in debug mode:

VERBOSE=1 ULAUNCHER_WS_API=ws://127.0.0.1:5054/com.github.ddkasa.ulauncher-toggl-extension PYTHONPATH=/usr/lib/python3.12/site-packages /bin/python ~/.local/share/ulauncher/extensions/com.github.ddkasa.ulauncher-toggl-extension/main.py

I get the following output:

/home/sbe/.local/share/ulauncher/extensions/com.github.ddkasa.ulauncher-toggl-extension/ulauncher_toggl_extension/utils.py:24: PyGIWarning: Notify was imported without specifying a version first. Use gi.require_version('Notify', '0.7') before import to ensure that the right version gets loaded.
  from gi.repository import Notify
com.github.ddkasa.ulauncher-toggl-extension | 2024-06-18 17:50:29,559 | DEBUG | ulauncher_toggl_extension.extension: __init__() | Updating trackers
com.github.ddkasa.ulauncher-toggl-extension | 2024-06-18 17:50:29,568 | INFO | ulauncher_toggl_extension.toggl.cli.tracker: fetch_objects() | Refreshing Toggl Tracker List...
com.github.ddkasa.ulauncher-toggl-extension | 2024-06-18 17:50:29,568 | INFO | ulauncher_toggl_extension.toggl.cli.meta: base_command() | Running subcommand: /home/sbe/.local/bin/toggl ls --fields +project,+id,+tags
Traceback (most recent call last):
  File "/home/sbe/.local/share/ulauncher/extensions/com.github.ddkasa.ulauncher-toggl-extension/main.py", line 4, in <module>
    TogglExtension().run()
    ^^^^^^^^^^^^^^^^
  File "/home/sbe/.local/share/ulauncher/extensions/com.github.ddkasa.ulauncher-toggl-extension/ulauncher_toggl_extension/extension.py", line 89, in __init__
    tcli.fetch_objects()
  File "/home/sbe/.local/share/ulauncher/extensions/com.github.ddkasa.ulauncher-toggl-extension/ulauncher_toggl_extension/toggl/cli/tracker.py", line 115, in fetch_objects
    tracker = TogglTracker(
              ^^^^^^^^^^^^^
  File "<string>", line 10, in __init__
  File "/home/sbe/.local/share/ulauncher/extensions/com.github.ddkasa.ulauncher-toggl-extension/ulauncher_toggl_extension/toggl/dataclasses.py", line 62, in __post_init__
    self.project = self.project_name_formatter()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sbe/.local/share/ulauncher/extensions/com.github.ddkasa.ulauncher-toggl-extension/ulauncher_toggl_extension/toggl/dataclasses.py", line 111, in project_name_formatter
    return project, int(project_id[:-1])
                    ^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '198286470)                    3'

cross-referencing that with the output of toggl ls --fields +project,+id,+tags it seems to struggle with emoji in project names:

$ toggl ls --fields +project,+id,+tags
 Description     Duration                  Start                    Stop  Project                            Id          Tags
                  0:08:57  5:45:04 PM 06/18/2024                 running                                     3493328779       
 Various          8:25:01             9:20:03 AM   5:45:04 PM 06/18/2024  Central Team (#168806266)          3492674303       
 🍵               0:47:22             1:00:06 PM   1:47:28 PM 06/12/2024  🍵 (#198286470)                    3485456825
 H*               1:23:17             5:41:43 PM   7:05:00 PM 06/10/2024  Hopprepsgruppen (#163248044)       3482316547       
ddkasa commented 4 months ago

Hi @swantzter,

Thank you for the report.

I am currently in the process of refactoring the extension completely. I will make sure to take emojis into account with this.

So this issue should be fixed by the end of the week, when I merge with the main branch.

You can check out the development branch for now.