- Timestamp:
- 02/18/21 19:06:53 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
framspy/FramsticksLib.py
r1081 r1084 18 18 FramsticksLib.py -h""" 19 19 20 PRINT_FRAMSTICKS_OUTPUT: bool = False # set to True for debugging 20 21 DETERMINISTIC: bool = False # set to True to have the same results in each run 21 22 … … 24 25 25 26 26 def __init__(self, framspath, framsexe, pid=""): 27 self.pid = pid if pid is not None else "" 28 self.frams_path = framspath 29 self.frams_exe = framsexe if framsexe is not None else 'frams.exe' if os.name == "nt" else 'frams.linux' 30 self.writing_path = None 31 mainpath = os.path.join(self.frams_path, self.frams_exe) 32 # exe_call = [mainpath, '-Q', '-s', '-c', '-icliutils.ini'] # -c will be ignored in Windows Framsticks (this option is meaningless because the Windows version does not support color console, so no need to deactivate this feature using -c) 33 # exe_call_to_get_version = [mainpath, '-V'] 34 # exe_call_to_get_path = [mainpath, '-?'] 35 36 frams.init(framspath, "-Ddata") # "-D"+os.path.join(framspath,"data")) # not possible (maybe python windows issue) because of the need for os.chdir(). So we assume "data" is where the dll/so is 27 def __init__(self, frams_path, frams_lib_name): 28 frams.init(frams_path, frams_lib_name, "-Ddata") # "-D"+os.path.join(frams_path,"data")) # not possible (maybe python windows issue) because of the need for os.chdir(). So we assume "data" is where the dll/so is 37 29 38 30 print('Available objects:', dir(frams)) 39 31 print() 40 32 41 self.__spawnFramsticksCLI()42 43 44 def __spawnFramsticksCLI(self):45 33 print('Performing a basic test 1/2... ', end='') 46 34 simplest = self.getSimplest("1") … … 68 56 assert isinstance(genotype_list, list) # because in python str has similar capabilities as list and here it would pretend to work too, so to avoid any ambiguity 69 57 70 # TODO use Logger to mute stdout (optinally just like in FramsticksCLI.py) 58 if not self.PRINT_FRAMSTICKS_OUTPUT: 59 ec = frams.MessageCatcher.new() # mute potential errors, warnings, messages 60 71 61 frams.GenePools[0].clear() 72 62 frams.Simulator.ximport(self.EVALUATION_SETTINGS_FILE, 2 + 4 + 8 + 16) … … 79 69 while frams.Simulator.running._int(): # standard-eval.expdef sets running to 0 when the evaluation is complete 80 70 step() 71 72 if not self.PRINT_FRAMSTICKS_OUTPUT: 73 if ec.error_count._value() > 0: # errors are important and should not be ignored, at least display how many 74 print("[ERROR]", ec.error_count, "error(s) and", ec.warning_count, "warning(s) while evaluating", len(genotype_list), "genotype(s)") 75 ec.close() 81 76 82 77 results = [] … … 150 145 def parseArguments(): 151 146 parser = argparse.ArgumentParser(description='Run this program with "python -u %s" if you want to disable buffering of its output.' % sys.argv[0]) 152 parser.add_argument('-path', type=ensureDir, required=True, help='Path to Framsticks CLIwithout trailing slash.')153 parser.add_argument('- exe', required=False, help='Library name. If not given, "frams.dll" or "frams.so" is assumed depending on the platform.') # TODO dll,so, allow to change name?147 parser.add_argument('-path', type=ensureDir, required=True, help='Path to the Framsticks library (.dll or .so) without trailing slash.') 148 parser.add_argument('-lib', required=False, help='Library name. If not given, "frams-objects.dll" or "frams-objects.so" is assumed depending on the platform.') 154 149 parser.add_argument('-genformat', required=False, help='Genetic format for the demo run, for example 4, 9, or S. If not given, f1 is assumed.') 155 150 return parser.parse_args() … … 171 166 172 167 parsed_args = parseArguments() 173 framsDLL = FramsticksLib(parsed_args.path, parsed_args. exe, None) # parsed_args.pid)168 framsDLL = FramsticksLib(parsed_args.path, parsed_args.lib) 174 169 175 170 print("Sending a direct command to Framsticks CLI that calculates \"4\"+2 yields", frams.Simulator.eval("return \"4\"+2;"))
Note: See TracChangeset
for help on using the changeset viewer.