Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

Commit

Permalink
Add version and cwd to the sentry context
Browse files Browse the repository at this point in the history
  • Loading branch information
GaretJax committed Jun 5, 2015
1 parent 6e3d95f commit 3647604
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions lancet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])


def get_sentry_client(sentry_dsn):
return raven.Client(
sentry_dsn,
release=__version__,
processors=(
'raven.processors.SanitizePasswordsProcessor',
)
)


class SubprocessExecuter(click.BaseCommand):
def parse_args(self, ctx, args):
ctx.args = args
Expand Down Expand Up @@ -182,14 +192,18 @@ def exception_handler(type, value, traceback):
else:
config = load_config()

ctx.obj = Lancet(config, integration_helper)
ctx.obj.call_on_close = ctx.call_on_close
ctx.call_on_close(integration_helper.close)

sentry_dsn = config.get('lancet', 'sentry_dsn')
if not debug and sentry_dsn:
if not raven:
click.secho('You provided a Sentry DSN but the raven module is '
'not installed. Sentry logging will not be enabled.',
fg='yellow')
else:
sentry_client = raven.Client(sentry_dsn)
sentry_client = get_sentry_client(sentry_dsn)

def exception_handler(type, value, traceback):
settings_diff = diff_config(
Expand All @@ -212,15 +226,12 @@ def exception_handler(type, value, traceback):
(type, value, traceback),
extra={
'settings': as_dict(settings_diff),
'working_dir': os.getcwd(),
},
)[0]
click.secho('\n {}\n'.format(error_id), fg='yellow')
sys.excepthook = exception_handler

ctx.obj = Lancet(config, integration_helper)
ctx.obj.call_on_close = ctx.call_on_close
ctx.call_on_close(integration_helper.close)


@main.command()
def _setup_helper():
Expand Down

0 comments on commit 3647604

Please sign in to comment.