Peano
Loading...
Searching...
No Matches
InvokeExternalTool.py
Go to the documentation of this file.
1# This file is part of the Peano project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3import os
4import re
5import subprocess
6
7class InvokeExternalTool(object):
8 def __init__(self,instruction_stream,subdirectory):
9 """
10 call_string How to invoke tool. The invokation will change into subdirectory
11 prior to the program launch.
12 """
13 self.instruction_stream = instruction_stream
14 self.subdirectory = subdirectory
15
16 def generate(self,overwrite,directory):
17 if not os.path.exists( directory + "/" + self.subdirectory ):
18 os.mkdir(directory + "/" + self.subdirectory)
19
20 try:
21 print( "invoke " + self.instruction_stream )
22 returnCode = subprocess.check_call( self.instruction_stream, stdout=subprocess.PIPE, shell=True, cwd=self.subdirectory )
23 if returnCode!=0:
24 print( "Error: something went wrong with the program invocation (error code=" + str(returnCode) + ")" )
25 except Exception as e:
26 print( "Error: " + str(e) )
__init__(self, instruction_stream, subdirectory)
call_string How to invoke tool.