@@ -159,18 +159,18 @@ def _run_commands(commands, num_workers=5):
159159def _concat_files (source_paths , target_path ):
160160 with open (target_path , 'wb' ) as tfileobj :
161161 for path in source_paths :
162- with open (path , 'rb' ) as sfileobj :
163- shutil .copyfileobj (sfileobj , tfileobj )
162+ try :
163+ with open (path , 'rb' ) as sfileobj :
164+ shutil .copyfileobj (sfileobj , tfileobj )
165+ except FileNotFoundError :
166+ logger .warning (f"Skipping non-extant { path } " )
164167
165168
166- def _move_file (source_path , target_path ):
167- # for Windows people, remove target first, but don't try too hard (Windows is notoriously bad at this)
168- # this two-stage delete-rename approach does have a tiny (irrelevant) race condition (thx Windows)
169+ def _remove_file (path ):
169170 try :
170- os .remove (target_path )
171+ os .remove (path )
171172 except FileNotFoundError :
172173 pass
173- os .rename (source_path , target_path )
174174
175175
176176@cli .command ()
@@ -213,18 +213,17 @@ def run(cfg, scopes, subjects, sections, preset, num_workers, monitor_url, repor
213213 logger .debug (f'running tests for scope(s) { ", " .join (scopes )} and subject(s) { ", " .join (subjects )} ' )
214214 logger .debug (f'monitor url: { monitor_url } , num_workers: { num_workers } , output: { report_yaml } ' )
215215 with tempfile .TemporaryDirectory (dir = cfg .cwd ) as tdirname :
216- report_yaml_tmp = os .path .join (tdirname , 'report.yaml' )
217216 jobs = [(scope , subject ) for scope in scopes for subject in subjects ]
218217 outputs = [os .path .join (tdirname , f'report-{ idx } .yaml' ) for idx in range (len (jobs ))]
219218 commands = [cfg .build_check_command (job [0 ], job [1 ], sections , output ) for job , output in zip (jobs , outputs )]
220219 _run_commands (commands , num_workers = num_workers )
221- _concat_files (outputs , report_yaml_tmp )
222220 if report_yaml is None :
223- report_yaml = report_yaml_tmp
224- else :
225- _move_file ( report_yaml_tmp , report_yaml )
221+ report_yaml = os . path . join ( tdirname , 'report.yaml' )
222+ _concat_files ( outputs , report_yaml )
223+ _remove_file ( report_yaml + '.sig' )
226224 subprocess .run (** cfg .build_sign_command (report_yaml ))
227225 subprocess .run (** cfg .build_upload_command (report_yaml , monitor_url ))
226+ sys .stdout .write ('\n ' ) # curl output does not end in newline
228227 return 0
229228
230229
0 commit comments