3636mutex_group .add_argument ('-z' , '--zip' ,
3737 help = """Path to zip file of test scripts. Mutually exclusive with --path""" , )
3838parser .add_argument ('-l' , '--local_log' , '--local-log' ,
39- help = """Overrides the logging path to the current working directory""" ,
39+ help = """Deprecated. Use the -c config to set up reporting to a different directory
40+ Overrides the logging path to the current working directory""" ,
4041 action = "store_true" )
4142parser .add_argument ('-q' , '--qtgui' ,
4243 help = """Argument to select the qt gui mode. This is still in early development""" ,
4546 help = """Activate Dev Mode for more debug information""" ,
4647 action = "store_true" )
4748parser .add_argument ('-c' , '--config' ,
48- help = """Specify config file""" )
49+ help = """Specify the path to a configuration file.
50+ Configuration files are in yaml format.
51+ Values in this file take precedence over those in a global config file.
52+ This argument can be used multiple times with later config files taking precedence over earlier ones
53+ """ ,
54+ action = 'append' ,
55+ default = []
56+ )
4957parser .add_argument ('-n' , '--n_loops' , '--n-loops' ,
5058 help = """Loop the test. Use -1 for infinite loops""" ,
5159 action = "store" )
@@ -115,11 +123,10 @@ class FixateController:
115123 It may be subclassed for different execution environments
116124 """
117125
118- def __init__ (self , sequencer , test_script_path , csv_output_path , args , loop ):
126+ def __init__ (self , sequencer , test_script_path , args , loop ):
119127 register_cmd_line ()
120128 # self.register()
121- self .worker = FixateWorker (sequencer = sequencer , test_script_path = test_script_path ,
122- csv_output_path = csv_output_path , args = args , loop = loop )
129+ self .worker = FixateWorker (sequencer = sequencer , test_script_path = test_script_path , args = args , loop = loop )
123130
124131 def fixate_exec (self ):
125132 exit_code = self .worker .ui_run ()
@@ -129,26 +136,26 @@ def fixate_exec(self):
129136
130137
131138class FixateSupervisor :
132- def __init__ (self , test_script_path , csv_output_path , args ):
139+ def __init__ (self , test_script_path , args ):
133140
134141 # General setup
135142 self .test_script_path = test_script_path
136- self .csv_output_path = csv_output_path
137143 self .args = args
138144 self .loop = asyncio .get_event_loop ()
139145 self .sequencer = RESOURCES ["SEQUENCER" ]
140146
141147 # Environment specific setup
148+ # TODO remove this to plugin architecture
142149 if self .args .qtgui : # Run with the QT GUI
143150 self .loop = asyncio .new_event_loop ()
144151
145152 class QTController (FixateController ):
146- def __init__ (self , sequencer , test_script_path , csv_output_path , args , loop ):
153+ def __init__ (self , sequencer , test_script_path , args , loop ):
147154 from PyQt5 import QtWidgets , QtCore
148155 import fixate .ui_gui_qt as gui
149156
150- self .worker = FixateWorker (test_script_path = test_script_path , csv_output_path = csv_output_path ,
151- args = args , loop = loop , sequencer = sequencer )
157+ self .worker = FixateWorker (test_script_path = test_script_path , args = args , loop = loop ,
158+ sequencer = sequencer )
152159
153160 QtWidgets .QApplication .setAttribute (QtCore .Qt .AA_EnableHighDpiScaling )
154161 self .fixateApp = QtWidgets .QApplication (sys .argv )
@@ -166,21 +173,20 @@ def fixate_exec(self):
166173 self .fixateApp .closeAllWindows ()
167174 return exit_code
168175
169- self .controller = QTController (sequencer = self .sequencer , test_script_path = test_script_path ,
170- csv_output_path = csv_output_path , args = args , loop = self .loop )
176+ self .controller = QTController (sequencer = self .sequencer , test_script_path = test_script_path , args = args ,
177+ loop = self .loop )
171178 else : # Command line execution
172179 self .controller = FixateController (sequencer = self .sequencer , test_script_path = test_script_path ,
173- csv_output_path = csv_output_path , args = args , loop = self .loop )
180+ args = args , loop = self .loop )
174181
175182 def run_fixate (self ):
176183 return self .controller .fixate_exec ()
177184
178185
179186class FixateWorker :
180- def __init__ (self , sequencer , test_script_path , csv_output_path , args , loop ):
187+ def __init__ (self , sequencer , test_script_path , args , loop ):
181188 self .sequencer = sequencer
182189 self .test_script_path = test_script_path
183- self .csv_output_path = csv_output_path
184190 self .args = args
185191 self .loop = loop
186192 self .start = False
@@ -214,23 +220,6 @@ def stop(self):
214220
215221 return 11
216222
217- def read_config (self , path = None ):
218- """
219- Loads yaml config file, and reads in parameters
220- :param path:
221- :return:
222- """
223-
224- if path is None :
225- return {}
226-
227- try :
228- with open (os .path .join (path ), 'rb' ) as f :
229- yaml = ruamel .yaml .YAML (typ = "safe" , pure = True )
230- return yaml .load (f )
231- except (IOError , OSError ) as e :
232- raise e ("Error opening config file" )
233-
234223 def ui_run (self ):
235224
236225 asyncio .set_event_loop (self .loop )
@@ -266,13 +255,13 @@ def ui_run(self):
266255 test_suite = load_test_suite (self .args .path , self .args .zip , self .args .zip_selector )
267256 test_data = retrieve_test_data (test_suite , self .args .index )
268257 self .sequencer .load (test_data )
258+
269259 if self .args .local_log :
270- self .csv_output_path = os .path .join (os .path .dirname (self .test_script_path ))
271- if self .csv_output_path is None :
272- self .config = self .read_config (self .args .config )
273- self .csv_output_path = os .path .join (self .config .get ('BASE_CSV_PATH' , "" ), self .sequencer .context_data .get ("part_number" , "" ),
274- self .sequencer .context_data .get ("module" , "" ))
275- register_csv (self .csv_output_path )
260+ try :
261+ fixate .config .plg_csv ["tpl_csv_path" ] = ["{tpl_time_stamp}-{index}.csv" ]
262+ except (AttributeError , KeyError ):
263+ pass
264+ register_csv ()
276265 self .sequencer .status = 'Running'
277266
278267 def init_tasks ():
@@ -332,12 +321,26 @@ def retrieve_test_data(test_suite, index):
332321 return sequence
333322
334323
335- def run_main_program (test_script_path = None , csv_output_path = None ):
324+ def run_main_program (test_script_path = None ):
336325 args , unknown = parser .parse_known_args ()
337- supervisor = FixateSupervisor (test_script_path , csv_output_path , args )
326+ load_config (args .config )
327+ supervisor = FixateSupervisor (test_script_path , args )
338328 exit (supervisor .run_fixate ())
339329
340330
331+ def load_config (config : list = None ):
332+ # Load python environment fixate config
333+ env_config = os .path .join (sys .prefix , "fixate.yml" )
334+ if os .path .exists (env_config ):
335+ fixate .config .load_yaml_config (env_config )
336+ # TODO Load script config
337+
338+ # Load a list of config files
339+ if config is not None :
340+ for conf in config :
341+ fixate .config .load_yaml_config (conf )
342+
343+
341344# Setup configuration
342345if __name__ == "__main__" :
343346 run_main_program ()
0 commit comments