@@ -278,45 +278,50 @@ def pre_work(self):
278278 self .policy ._configure_low_priority ()
279279
280280 def execute (self ):
281- self .pre_work ()
282- if self .from_cmdline :
283- self .intro ()
284- self .archive = self .opts .upload_file
285- self .caseid = self .policy .prompt_for_case_id (
286- cmdline_opts = self .opts
287- )
288- cmdline_target = self .opts .upload_target
289- if cmdline_target and cmdline_target != 'local' :
290- self .upload_target = self .upload_targets [cmdline_target ]
291- else :
292- self .determine_upload_target ()
293- if not self .upload_target :
294- # There was no upload target set, so we'll throw
295- # an error here and exit
296- self .ui_log .error (
297- "No upload target set via command line options or"
298- " autodetected.\n "
299- "Please specify one using the option --upload-target.\n "
300- "Exiting."
301- )
302- sys .exit (1 )
303- self .upload_target .pre_work (self .get_commons ())
304281 try :
305- if os .stat (self .archive ).st_size > 0 :
306- if os .path .isfile (self .archive ):
307- try :
308- self .upload_target .upload_archive (self .archive )
309- self .ui_log .info (
310- _ (f"File { self .archive } uploaded successfully" )
311- )
312- except Exception as err :
313- self .ui_log .error (_ (f"Upload attempt failed: { err } " ))
314- sys .exit (1 )
315- else :
316- self .ui_log .error (_ (f"{ self .archive } is not a file." ))
282+ self .pre_work ()
283+ if self .from_cmdline :
284+ self .intro ()
285+ self .archive = self .opts .upload_file
286+ self .caseid = self .policy .prompt_for_case_id (
287+ cmdline_opts = self .opts
288+ )
289+ cmdline_target = self .opts .upload_target
290+ if cmdline_target and cmdline_target != 'local' :
291+ self .upload_target = self .upload_targets [cmdline_target ]
317292 else :
318- self .ui_log .error (_ (f"File { self .archive } is empty." ))
319- except Exception as e :
320- self .ui_log .error (_ (f"Cannot upload { self .archive } : { e } " ))
293+ self .determine_upload_target ()
294+ if not self .upload_target :
295+ # There was no upload target set, so we'll throw
296+ # an error here and exit
297+ self .ui_log .error (
298+ "No upload target set via command line options or"
299+ " autodetected.\n "
300+ "Please specify one using the option --upload-target.\n "
301+ "Exiting."
302+ )
303+ sys .exit (1 )
304+ self .upload_target .pre_work (self .get_commons ())
305+ try :
306+ if os .stat (self .archive ).st_size > 0 :
307+ if os .path .isfile (self .archive ):
308+ try :
309+ self .upload_target .upload_archive (self .archive )
310+ self .ui_log .info (
311+ _ (f"File { self .archive } uploaded successfully" )
312+ )
313+ except Exception as err :
314+ self .ui_log .error (_ (
315+ f"Upload attempt failed: { err } " ))
316+ sys .exit (1 )
317+ else :
318+ self .ui_log .error (_ (f"{ self .archive } is not a file." ))
319+ else :
320+ self .ui_log .error (_ (f"File { self .archive } is empty." ))
321+ except Exception as e :
322+ self .ui_log .error (_ (f"Cannot upload { self .archive } : { e } " ))
323+ except KeyboardInterrupt :
324+ self ._exit ("Exiting on user cancel" , 130 )
325+
321326
322327# vim: set et ts=4 sw=4 :
0 commit comments