From b5d25d63e8c938aa113b6c2a0e0dc1f2bb600044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 7 Jun 2018 10:18:46 +0200 Subject: [PATCH] scripts: include __file__ in globals() (#24341) --- wcs/scripts.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wcs/scripts.py b/wcs/scripts.py index 51972a25..c11b6ae0 100644 --- a/wcs/scripts.py +++ b/wcs/scripts.py @@ -29,6 +29,7 @@ class Script(object): for path in paths: script_path = os.path.join(path, script_name + '.py') if os.path.exists(script_path): + self.__file__ = script_path self.code = open(script_path).read() break else: @@ -45,6 +46,7 @@ class Script(object): def __call__(self, *args): data = get_publisher().substitutions.get_context_variables().copy() data['args'] = args + data['__file__'] = self.__file__ code_object = compile(self.code, self.script_name, 'exec') eval(code_object, data) return data.get('result') -- 2.17.1