tbabej / taskpirate Goto Github PK
View Code? Open in Web Editor NEWA pluggable system for tasklib based TaskWarrior hooks. Faster, less boilerplate code!
License: Other
A pluggable system for tasklib based TaskWarrior hooks. Faster, less boilerplate code!
License: Other
Traceback (most recent call last):
File "/home/janek/.local/share/task/hooks/on-add-pirate", line 9, in <module>
from tasklib import TaskWarrior, Task
File "/usr/local/lib/python3.8/dist-packages/tasklib/__init__.py", line 1, in <module>
from .backends import TaskWarrior
File "/usr/local/lib/python3.8/dist-packages/tasklib/backends.py", line 11, in <module>
from .task import Task, TaskQuerySet, ReadOnlyDictView
File "/usr/local/lib/python3.8/dist-packages/tasklib/task.py", line 9, in <module>
from .serializing import SerializingObject
File "/usr/local/lib/python3.8/dist-packages/tasklib/serializing.py", line 11, in <module>
local_zone = tzlocal.get_localzone()
File "/usr/local/lib/python3.8/dist-packages/tzlocal/unix.py", line 165, in get_localzone
_cache_tz = _get_localzone()
File "/usr/local/lib/python3.8/dist-packages/tzlocal/unix.py", line 90, in _get_localzone
utils.assert_tz_offset(tz)
File "/usr/local/lib/python3.8/dist-packages/tzlocal/utils.py", line 38, in assert_tz_offset
raise ValueError(msg)
ValueError: Timezone offset does not match system offset: 7200 != 0. Please, check your config files.
Hook Error: Expected feedback from a failing hook script.
I am a developer, but I rarely use python, so idk what I'm supposed to do with this. The hook shouldn't care about my system time at all?
I live in Germany (CEST) btw.
Note that calling these functions manually works without issues:
❯ python3 -c "import tzlocal; print(tzlocal.get_localzone())"
Europe/Berlin
❯ python -c "import tzlocal; print(tzlocal.get_localzone())"
Europe/Berlin
❯ python3.8 -c "import tzlocal; print(tzlocal.get_localzone())"
Europe/Berlin
Same reportin tasklib: GothenburgBitFactory/tasklib#84
I am unable to get it to work properly. It depends on functools (which should be mentioned in the readme) which I don't get working in Python 2, but the shebang implies Python 2 (at least on Ubuntu).
After installing functools and changing the shebang it finally worked.
In my system, python is installed to /usr/local/bin/python, so bad interpreter is raised when executing the hook.
#!/usr/bin/env python
should be used instead of #!/usr/bin/python
I use task pirate in combination with taskwarrior. When upgrading to the latest version of taskwarrior (2.6.0
at this time) I notice a hook error as follows:
Hook Error: Expected 1 JSON task(s), found 0, in hook script: on-modify-pirate
Downgrading back to taskwarrior 2.5.3
seems to not have this problem.
Feel free to ping for any more info I can provide to help. I'm not entirely sure what info will help debug this issue better.
The README Currently has you download from pip install --user git+https://github.com/tbabej/tasklib@develop
But I think this should be update to: pip install --user git+https://github.com/GothenburgBitFactory/tasklib@develop
I installed bugwarrior
today and got this message during of process of two tasks. I don't know if this problem is related to taskpirate or should I post in the tasklib repo.
Here is the error.
ERROR:bugwarrior.db:Unable to modify task: b'Traceback (most recent call last):\n File "/home/mhalano/.task/hooks/on-modify-pirate", line 43, in <module>\n task = Task.from_input()\n File "/home/mhalano/.local/lib/python3.9/site-packages/tasklib/task.py", line 236, in from_input\n task._load_data(json.loads(input_file.readline().strip()))\n File "/usr/lib/python3.9/codecs.py", line 322, in decode\n (result, consumed) = self._buffer_decode(data, self.errors, final)\nUnicodeDecodeError: \'utf-8\' codec can\'t decode byte 0xed in position 2666: invalid continuation byte\nHook Error: Expected feedback from failing hook script: on-modify-pirate'
Traceback (most recent call last):
File "/home/mhalano/.local/lib/python3.9/site-packages/bugwarrior/db.py", line 465, in synchronize
_, updated_task = tw.task_update(issue)
File "/home/mhalano/.local/lib/python3.9/site-packages/taskw/warrior.py", line 821, in task_update
self._execute(task_uuid, 'modify', *modification)
File "/home/mhalano/.local/lib/python3.9/site-packages/taskw/warrior.py", line 497, in _execute
raise TaskwarriorError(command, stderr, stdout, proc.returncode)
taskw.exceptions.TaskwarriorError: <unprintable TaskwarriorError object>
taskpirate uses the module imp
:
Line 4 in c0d91da
importlib
.I have a hook called on-modify.dump
, that simply dumps the JSON into a temp file.
Output without taskpirate:
❯ t 85 mod +t5
Modifying task 85 'test'.
Modified 1 task.
❯ b /tmp/on-modify.dump
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: /tmp/on-modify.dump
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ {"description":"test","entry":"20200528T075419Z","modified":"20200528T075519Z","status":"pending","tags":["t1","t2","t3","t4"],"uuid":"39c380b9-9c20-45f4-83d3-6cd3c7fa0a87"}
2 │ {"description":"test","entry":"20200528T075419Z","modified":"20200528T075519Z","status":"pending","tags":["t1","t2","t3","t4","t5"],"uuid":"39c380b9-9c20-45f4-83d3-6cd3c7fa0a87"}
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
With taskpirate:
❯ t 85 mod -t5
Modifying task 85 'test'.
Modified 1 task.
❯ b /tmp/on-modify.dump
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: /tmp/on-modify.dump
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ {"description":"test","entry":"20200528T075419Z","modified":"20200528T075545Z","status":"pending","tags":["t1","t2","t3","t4","t5"],"uuid":"39c380b9-9c20-45f4-83d3-6cd3c7fa0a87"}
2 │ {"description":"test","entry":"20200528T075419Z","modified":"20200528T075545Z","status":"pending","tags":"t2,t4,t1,t3","uuid":"39c380b9-9c20-45f4-83d3-6cd3c7fa0a87"}
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
This is breaking timewarrior, because instead of taking each element of the tags array as tags, it takes each character individually!
My hooks directory currently only contains the dump hook and the taskpirate hooks, nothing else, so it can't be something else.
Thank you for making/maintaining taskpirate
!
Per https://taskwarrior.org/docs/hooks.html (my emphasis):
Output from a hook script is a combination of a JSON-formatted task and text. Just as the JSON for a task must occupy a single line, so must a single feedback message. Feedback text is optional for a successful hook script, but required for a failing script. If provided it will be displayed by Taskwarrior according to the verbosity setting.
Here is sample output from a hypothetical spell-checking hook script:
{"description":"Buy some milk","entry":"20141118T050231Z","status":"pending","uuid":"a360fc44-315c-4366-b70c-ea7e7520b749"} Spell checking found no errors.
The output is a single line JSON object which represents an optionally modified task, and a single line of feedback text to be displayed.
There may only be one line of JSON, and it must be for the same task that was provided as input.
tasklib
does not explicitly support feedback text yet, but in some ways that is less of an issue, as it interfaces with TaskWarrior more directly.
taskpirate
, adding as it does an abstraction layer between tasklib
and hooks, does not seem to have a (documented) mechanism for sending feedback text from a hook back to taskpirate, together with JSON. That is, it has no (documented) mechanism for fully utilising TaskWarrior's hook support. This should probably be addressed.
So... #11 is still an issue by 2023 and I just wasted 2 hours on that.
Just using taskpirate with the default timewarrior on-modify hook results in this:
Tracking "Testing" Project a e i p r t v
Started 2023-04-17T20:35:33
Current 33
Total 0:00:00
(the set tag was "private")
Please make an annotation in the README that hooks should be named in a way, that stuff that isn't meant to run with taskpirate comes alphabetically prior to taskpirate.
The order of execution can simply be checked with task diagnostics
:
Active: on-addZZ-pirate (executable)
on-modify01-timewarrior (executable)
on-modifyZZ-pirate (executable)
Inactive: pirate_add_shift_recurrence.py (executable)unrecognized hook name
I fully acknowledge that this isn't a bug of this project, but this bug makes taskpirate just incompatible with the default upstream timewarrior hook if people take the default naming scheme of taskwarrior and timewarrior.
Running taskwarrior 2.6.1 with latest version of tasklib, python 3.9 installed with homebrew on mac.
I'm using taskwarrior with a couple of python hooks installed that get triggered when issuing certain taskwarrior commands. The hooks run fine when I use taskwarrior normally from the command line.
But I'm running into problems when the the hooks are trigged by a hotkey app called Karabiner Elements. Karabiner calls a simple perl script which in turn execute this bash command containing the task
command:
/bin/bash -c 'TASKRC=/Users/me/.taskrc /usr/local/bin/task add \'the task\''
Unfortunately, the stack error generated is cutoff in the Karabiner log. This is as much as I get:
[2021-12-07 06:24:51.797] [error] [console_user_server] shell_command stderr:Traceback (most recent call last): File "/Users/me/.task_work/hooks/on-add-pirate", line 9, in <module> from tasklib import TaskWarrior, Task File "/Users/me/Library/Python/3.8/lib/python/site-packages/tasklib/__init__.py", l...
I'm guessing the python script is choking because it can't figure out where needed libraries are. But I don't see any shell environment variables that I might be able to set. I have python3 installed with brew and the tasklib
library installed with pip3
(I believe). I'm totally unfamiliar with python environment and libraries so a hand would be greatly appreciated.
I'm actually not entirely sure this is a task pirate issue (could actually just be a hooks + taskwarrior in general problem), but starting with an issue here, will move over to the right tool if folks have more input.
I recently moved to using XDG based directory structure for task warrior. I did this after upgrading to 2.6.1
.
I notice this error happens only after one of my hooks (in this case the shift recurrence one) attempt to execute.
Some noteworthy environment variables:
task --version # 2.6.1
set --export XDG_CONFIG_HOME $HOME/.config
set --export XDG_DATA_HOME $HOME/.data
data.location=$XDG_DATA_HOME/task/
hooks.location=$XDG_CONFIG_HOME/task/hooks/
Another peculiar observation is that there were .data
files being created in my ~/.config/task/
directory
Let me know if I can provide any more information or if I should instead open these in the main taskwarrior project.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.