Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TaskWarrior.load_config() ignores TASKRC environment variable #94

Closed
khaeru opened this issue Feb 24, 2015 · 4 comments
Closed

TaskWarrior.load_config() ignores TASKRC environment variable #94

khaeru opened this issue Feb 24, 2015 · 4 comments

Comments

@khaeru
Copy link
Contributor

khaeru commented Feb 24, 2015

I have set the TASKRC environment variable to set a custom location for the taskwarrior configuration file:

$ env | grep TASK
TASKRC=/home/khaeru/vc/dotfiles/taskwarrior

I installed the taskwarrior-time-tracking-hook by @kostajh, but it fails because taskw does not check this environment variable and instead looks for the configuration file at ~/.taskrc:

$ task 43 stop
Traceback (most recent call last):
  File "/home/khaeru/.local/share/taskwarrior/hooks/on-modify.timetracking", line 9, in <module>
    load_entry_point('taskwarrior-time-tracking-hook==0.1.4', 'console_scripts', 'taskwarrior_time_tracking_hook')()
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 356, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2476, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2190, in load
    ['__name__'])
  File "/home/khaeru/vc/other/taskwarrior-time-tracking-hook/taskwarrior_time_tracking_hook/__init__.py", line 11, in <module>
    w = TaskWarrior()
  File "/home/khaeru/.local/lib/python3.4/site-packages/taskw/warrior.py", line 453, in __init__
    super(TaskWarriorShellout, self).__init__(config_filename)
  File "/home/khaeru/.local/lib/python3.4/site-packages/taskw/warrior.py", line 54, in __init__
    self.config = TaskWarriorBase.load_config(config_filename)
  File "/home/khaeru/.local/lib/python3.4/site-packages/taskw/warrior.py", line 173, in load_config
    with open(os.path.expanduser(config_filename), 'r') as f:
  File "/home/khaeru/.local/lib/python3.4/site-packages/taskw/warrior.py", line 37, in <lambda>
    open = lambda fname, mode: codecs.open(fname, mode, "utf-8")
  File "/usr/lib/python3.4/codecs.py", line 896, in open
    file = builtins.open(filename, mode, buffering)
FileNotFoundError: [Errno 2] No such file or directory: '/home/khaeru/.taskrc'
Hook Error: Expected feedback from a failing hook script.
@ralphbean
Copy link
Owner

Hm, since taskw is a library.. I'm not sure it should be responsible for checking environment variables. Should taskwarrior-time-tracking-hook do this instead and pass the value to taskw? @kostajh, do you have an opinion on this?

@coddingtonbear
Copy link
Collaborator

Hrm -- I hadn't realized that that environment variable could be used to
point at one's Taskrc file. Given that we already automatically calculate
where one's Taskrc file is in taskw, though, I think it might make the most
sense to do this calculation in taskw. Even better: if it's possible for
us to ask taskwarrior where it will be reading its config from, we could
use that path?

On Tue, Feb 24, 2015 at 12:19 PM, Ralph Bean notifications@github.com
wrote:

Hm, since taskw is a library.. I'm not sure it should be responsible for
checking environment variables. Should taskwarrior-time-tracking-hook do
this instead and pass the value to taskw? @kostajh
https://github.com/kostajh, do you have an opinion on this?


Reply to this email directly or view it on GitHub
#94 (comment).

@khaeru
Copy link
Contributor Author

khaeru commented Feb 24, 2015

This could be as simple as replacing "~/.taskrc" with os.getenv('TASKRC', '~/.taskrc'). Since the former appears in multiple places, perhaps set a global variable near the top of warrior.py:

TASKRC = os.getenv('TASKRC', '~/.taskrc')

…if that's consistent with your coding style.

@ralphbean
Copy link
Owner

Sure. Want to submit the pull-request @khaeru?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants