@@ -363,28 +363,33 @@ for index, item in enumerate(sys.argv):
363363# Print help
364364if "--help" in OPT :
365365 print (help_text .strip ())
366+ zypperoni_cleanup ()
366367 sys .exit ()
367368
368369# Print version
369370if "--version" in OPT :
370371 print (f"zypperoni v{ ZYPPERONI_VERSION } " )
372+ zypperoni_cleanup ()
371373 sys .exit ()
372374
373375# Validate command
374376if not COMMAND :
375377 print ("No valid command provided. See usage below.\n " )
376378 print (help_text .strip ())
379+ zypperoni_cleanup ()
377380 sys .exit (1 )
378381if COMMAND in ["in" , "in-download" ] and not ARG :
379382 print (f"No arguments (packages) provided for command { COMMAND !r} . See usage below.\n " )
380383 print (help_text .strip ())
384+ zypperoni_cleanup ()
381385 sys .exit (1 )
382386
383387# Validate options
384388for opt in OPT :
385389 if opt not in VALID_OPT :
386390 print (f"Invalid option { opt !r} . See usage below.\n " )
387391 print (help_text .strip ())
392+ zypperoni_cleanup ()
388393 sys .exit (1 )
389394
390395DEBUG = True if "--debug" in OPT else False
@@ -399,9 +404,11 @@ if "--max-jobs" in OPT:
399404 raise ValueError
400405 except ValueError :
401406 print ("Invalid value for option '--max-jobs'. Must be between 1 to 20 (inclusive)" )
407+ zypperoni_cleanup ()
402408 sys .exit (2 )
403409 except IndexError :
404410 print ("No value provided for option '--max-jobs'" )
411+ zypperoni_cleanup ()
405412 sys .exit (2 )
406413
407414
@@ -415,6 +422,7 @@ logging.basicConfig(
415422# Bail out if we're not root
416423if os .getuid () != 0 :
417424 logging .error ("Bailing out, program must be run with root privileges" )
425+ zypperoni_cleanup ()
418426 sys .exit (3 )
419427
420428# Bail out if required dependecies are not available
@@ -426,6 +434,7 @@ for program in programs:
426434 f"for user { os .environ .get ('USER' )!r} . The following shell tools " \
427435 f"are required for zypperoni to function: { ', ' .join (programs )} "
428436 )
437+ zypperoni_cleanup ()
429438 sys .exit (4 )
430439
431440# Check if zypper is already running
@@ -444,6 +453,7 @@ if os.path.isfile(ZYPPER_PID_FILE):
444453 msg = f"zypper is already invoked by the application with pid { pid } ({ pid_program } ).\n " \
445454 "Close this application before trying again."
446455 logging .error (msg )
456+ zypperoni_cleanup ()
447457 sys .exit (5 )
448458
449459# Handle commands: ref, force-ref
0 commit comments