Skip to content
This repository has been archived by the owner on Mar 4, 2018. It is now read-only.

Commit

Permalink
Make sure environment is also set when running the program
Browse files Browse the repository at this point in the history
This prepare #241
  • Loading branch information
ColinDuquesnoy committed Nov 2, 2015
1 parent 2cffbb7 commit 3d9a4d0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion open_cobol_ide/__init__.py
Expand Up @@ -2,4 +2,4 @@
This package contains the code of the OpenCobolIDE application.
"""

__version__ = '4.7.dev57'
__version__ = '4.7.dev58'
12 changes: 6 additions & 6 deletions open_cobol_ide/compilers.py
Expand Up @@ -355,12 +355,12 @@ def prepare_bin_dir(self, path, output_full_path):
assert not os.path.isfile(path) # must be a directory
if not os.path.exists(path):
os.makedirs(path)
if sys.platform == "win32":
# copy the dll
files = glob.glob(os.path.join(
os.path.dirname(Settings().full_compiler_path), "*.dll"))
for f in files:
shutil.copy(f, path)
# if sys.platform == "win32":
# # copy the dll
# files = glob.glob(os.path.join(
# os.path.dirname(Settings().full_compiler_path), "*.dll"))
# for f in files:
# shutil.copy(f, path)
if os.path.exists(output_full_path):
try:
os.remove(output_full_path)
Expand Down
19 changes: 14 additions & 5 deletions open_cobol_ide/controllers/cobol.py
Expand Up @@ -324,19 +324,23 @@ def _run_in_external_terminal(self, program, wd, file_type):
self.ui.consoleOutput.append(
"Launched in external terminal")
pyqode_console = system.which('pyqode-console')
env = os.environ.copy()
env['PATH'] = GnuCobolCompiler.setup_process_environment().value(
'PATH')
if file_type == FileType.MODULE:
program = QtCore.QFileInfo(program).baseName()
if system.windows:
cmd = [pyqode_console, program]
if file_type == FileType.MODULE:
cmd.insert(1, system.which('cobcrun'))
subprocess.Popen(cmd, cwd=wd,
creationflags=subprocess.CREATE_NEW_CONSOLE)
creationflags=subprocess.CREATE_NEW_CONSOLE,
env=env)
elif system.darwin:
cmd = ['open', program]
if file_type == FileType.MODULE:
cmd.insert(1, system.which('cobcrun'))
subprocess.Popen(cmd, cwd=wd)
subprocess.Popen(cmd, cwd=wd, env=env)
else:
if file_type == FileType.EXECUTABLE:
cmd = ['"%s %s"' % (pyqode_console, program)]
Expand All @@ -345,7 +349,8 @@ def _run_in_external_terminal(self, program, wd, file_type):
program)]
cmd = system.shell_split(
Settings().external_terminal_command.strip()) + cmd
subprocess.Popen(' '.join(cmd), cwd=wd, shell=True)
subprocess.Popen(' '.join(cmd), cwd=wd, shell=True,
env=env)
_logger().info('running program in external terminal: %s',
' '.join(cmd))

Expand Down Expand Up @@ -382,12 +387,16 @@ def _run(self):
self.ui.consoleOutput.setFocus(True)
for item in self.run_buttons + [self.ui.actionRun]:
item.setEnabled(False)
path = GnuCobolCompiler.setup_process_environment().value('PATH')
env = {'PATH': path}
if file_type == FileType.MODULE:
cobcrun = system.which('cobcrun')
self.ui.consoleOutput.start_process(
cobcrun, [os.path.splitext(editor.file.name)[0]], cwd=wd)
cobcrun, [os.path.splitext(editor.file.name)[0]], cwd=wd,
env=env)
else:
self.ui.consoleOutput.start_process(program, cwd=wd)
self.ui.consoleOutput.start_process(program, cwd=wd,
env=env)

def _on_run_finished(self):
self.enable_compile(True)
Expand Down

0 comments on commit 3d9a4d0

Please sign in to comment.