Skip to content

Commit

Permalink
Add app directory overriding w/ WATSON_DIR env var
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Maupetit committed Feb 6, 2016
1 parent d168b2b commit bfa175c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions watson/cli.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# -*- coding: utf-8 -*-

import json
import datetime
import operator
import itertools
import json
import operator
import os

from functools import reduce
from dateutil import tz
from functools import reduce

import click
import arrow
import click

from . import watson
from .frames import Frame
Expand Down Expand Up @@ -83,10 +84,10 @@ def cli(ctx):
project with the `start` command, and you can stop the timer
when you're done with the `stop` command.
"""

# This is the main command group, needed by click in order
# to handle the subcommands

ctx.obj = watson.Watson()
ctx.obj = watson.Watson(config_dir=os.environ.get('WATSON_DIR'))


@cli.command()
Expand Down
2 changes: 1 addition & 1 deletion watson/watson.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, **kwargs):
self._config = None
self._config_changed = False

self._dir = kwargs.pop('config_dir', click.get_app_dir('watson'))
self._dir = kwargs.pop('config_dir') or click.get_app_dir('watson')

This comment has been minimized.

Copy link
@SpotlightKid

SpotlightKid Feb 9, 2016

Contributor

This should be kwargs.pop('config_dir', None) here. Otherwise you get a KeyError when config_dir is not passed in the kwargs.

This comment has been minimized.

Copy link
@jmaupetit

jmaupetit Feb 9, 2016

Member

You are right. And it's not tested as the watson feature always passes the config_dir argument. Let's fix this.


self.config_file = os.path.join(self._dir, 'config')
self.frames_file = os.path.join(self._dir, 'frames')
Expand Down

0 comments on commit bfa175c

Please sign in to comment.