From c79ccf00e8c59d32a6ed8b0981a92e85c1205769 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Sun, 22 Jul 2012 19:38:19 -0500 Subject: [PATCH] Print a correct PYOPENCL_CTX even if answers were pre-provided. --- pyopencl/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index d6a9bf3f..0e213376 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -621,6 +621,11 @@ def create_some_context(interactive=True, answers=None): ctx_spec = os.environ["PYOPENCL_CTX"] answers = ctx_spec.split(":") + if answers is not None: + pre_provided_answers = answers[:] + else: + pre_provided_answers = None + user_inputs = [] def get_input(prompt): @@ -699,6 +704,8 @@ def create_some_context(interactive=True, answers=None): devices = [parse_device(i) for i in answer.split(",")] if user_inputs: + if pre_provided_answers is not None: + user_inputs = pre_provided_answers + user_inputs print("Set the environment variable PYOPENCL_CTX='%s' to " "avoid being asked again." % ":".join(user_inputs)) return Context(devices) -- GitLab