From b9cd946110d167237d609f60124c3fc081c166e8 Mon Sep 17 00:00:00 2001 From: Joey Payne Date: Wed, 11 Nov 2015 17:07:21 -0700 Subject: [PATCH] Store bat file in a temp directory. --- command_line.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/command_line.py b/command_line.py index cc4aa19..498e4f8 100644 --- a/command_line.py +++ b/command_line.py @@ -897,6 +897,7 @@ class CommandBase(object): export_dirs.append('{}{}{}'.format(export_dir, os.path.sep, opt)) command = None + bat_file = None if ext == '.py': env_file = get_file('files/env_vars.py') @@ -948,15 +949,20 @@ class CommandBase(object): num_dirs=len(export_dirs), export_dirs=ex_dir_vars, **export_dict) - batcontents = '{}{}'.format(env_vars, contents) + batcontents = '{}\n{}'.format(env_vars, contents) - command = ['cmd', '/c', batcontents] + bat_file = utils.path_join(TEMP_DIR, '{}.bat'.format(self.project_name())) - proc = subprocess.Popen(' '.join(command), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + command = [bat_file] + + proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) output, error = proc.communicate() output = output.strip() error = error.strip() + if bat_file: + os.remove(bat_file) + with open(get_file('script-output.txt'), 'w+') as f: f.write('Output:\n{}'.format(output)) if error: