Add notification, fix crash if pid does not exist
This commit is contained in:
parent
b90ae26781
commit
24896e1a36
@ -3,6 +3,8 @@ from toggl.TogglPy import Toggl
|
|||||||
from zei.ZeiDelegate import ZeiDelegate
|
from zei.ZeiDelegate import ZeiDelegate
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from Mapping import Mapping
|
from Mapping import Mapping
|
||||||
|
from plyer import notification
|
||||||
|
from os.path import dirname, realpath, join
|
||||||
|
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
import logging
|
import logging
|
||||||
@ -49,12 +51,24 @@ class TogglDelegate(ZeiDelegate):
|
|||||||
_log.info("Stopping currently running entry")
|
_log.info("Stopping currently running entry")
|
||||||
self.toggl.stopTimeEntry(current["id"])
|
self.toggl.stopTimeEntry(current["id"])
|
||||||
|
|
||||||
|
if pid not in self.projects:
|
||||||
|
_log.info("Project not found, aborting")
|
||||||
|
return
|
||||||
|
|
||||||
_log.info(
|
_log.info(
|
||||||
"Now tracking project %s: %s (%s)",
|
"Now tracking project %s: %s (%s)",
|
||||||
self.projects[pid]["name"],
|
self.projects[pid]["name"],
|
||||||
description,
|
description,
|
||||||
", ".join(tags if tags else []),
|
", ".join(tags if tags else []),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
notification.notify(
|
||||||
|
title="Toggl",
|
||||||
|
message=f"Now tracking project {self.projects[pid]['name']} {description} ({', '.join(tags) if tags else ''})",
|
||||||
|
app_name="Toggl",
|
||||||
|
app_icon=join(dirname(realpath(__file__)), "icons/toggl.png"),
|
||||||
|
timeout=5,
|
||||||
|
)
|
||||||
if pid == 0:
|
if pid == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
BIN
icons/toggl.png
Normal file
BIN
icons/toggl.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
@ -1,3 +1,12 @@
|
|||||||
|
beautifulsoup4==4.10.0
|
||||||
bluepy==1.3.0
|
bluepy==1.3.0
|
||||||
|
certifi==2021.10.8
|
||||||
|
charset-normalizer==2.0.12
|
||||||
|
dbus-python==1.2.18
|
||||||
|
idna==3.3
|
||||||
|
plyer==2.0.0
|
||||||
python-dateutil==2.8.1
|
python-dateutil==2.8.1
|
||||||
|
requests==2.27.1
|
||||||
six==1.15.0
|
six==1.15.0
|
||||||
|
soupsieve==2.3.1
|
||||||
|
urllib3==1.26.9
|
||||||
|
Loading…
Reference in New Issue
Block a user