Skip to content

Commit

Permalink
Merge pull request #239 from minrk/extend-env
Browse files Browse the repository at this point in the history
POST env extends default env
  • Loading branch information
parente committed Apr 6, 2017
2 parents f2dc1b3 + 66dc88a commit 6a7526b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions kernel_gateway/services/kernels/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"""Tornado handlers for kernel CRUD and communication."""

import json
import os

import tornado
import notebook.services.kernels.handlers as notebook_handlers
from tornado import gen
Expand Down Expand Up @@ -51,9 +53,11 @@ def post(self):
if model is not None and 'env' in model:
if not isinstance(model['env'], dict):
raise tornado.web.HTTPError(400)
# start with current env
env = dict(os.environ)
# Whitelist KERNEL_* args and those allowed by configuration
env = {key: value for key, value in model['env'].items()
if key.startswith('KERNEL_') or key in self.env_whitelist}
env.update({key: value for key, value in model['env'].items()
if key.startswith('KERNEL_') or key in self.env_whitelist})
# No way to override the call to start_kernel on the kernel manager
# so do a temporary partial (ugh)
orig_start = self.kernel_manager.start_kernel
Expand Down

0 comments on commit 6a7526b

Please sign in to comment.