import tempfile from os import environ from os.path import join act_root = environ['SUGAR_ACTIVITY_ROOT'] tmp_dir = join(act_root, 'tmp') self._jobject.file_path = tempfile.TemporaryFile(tmp_dir)