meshlabxml/mlx.py
def handle_error(program_name, cmd, log=None):
    """Subprocess program error handling

    Args:
        program_name (str): name of the subprocess program

    Returns:
        break_now (bool): indicate whether calling program should break out of loop

    """
    print('\nHouston, we have a problem.',
          '\n%s did not finish successfully. Review the log' % program_name,
          'file and the input file(s) to see what went wrong.')
    print('%s command: "%s"' % (program_name, cmd))
    if log is not None:
        print('log: "%s"' % log)
    print('Where do we go from here?')
    print(' r  - retry running %s (probably after' % program_name,
          'you\'ve fixed any problems with the input files)')
    print(' c  - continue on with the script (probably after',
          'you\'ve manually re-run and generated the desired',
          'output file(s)')
    print(' x  - exit, keeping the TEMP3D files and log')
    print(' xd - exit, deleting the TEMP3D files and log')
    while True:
        choice = input('Select r, c, x (default), or xd: ')
        if choice not in ('r', 'c', 'x', 'xd'):
            #print('Please enter a valid option.')
            choice = 'x'
        #else:
        break
    if choice == 'x':
        print('Exiting ...')
        sys.exit(1)
    elif choice == 'xd':
        print('Deleting TEMP3D* and log files and exiting ...')
        util.delete_all('TEMP3D*')
        if log is not None:
            os.remove(log)
        sys.exit(1)
    elif choice == 'c':
        print('Continuing on ...')
        break_now = True
    elif choice == 'r':
        print('Retrying %s cmd ...' % program_name)
        break_now = False
    return break_now
def handle_error(program_name, cmd, log=None):
    print('\nHouston, we have a problem.',
          '\n%s did not finish successfully. Review the log' % program_name,
          'file and the input file(s) to see what went wrong.')
    print('%s command: "%s"' % (program_name, cmd))
    if log is not None:
        print('log: "%s"' % log)
    print('Where do we go from here?')
    print(' r  - retry running %s (probably after' % program_name,
          'you\'ve fixed any problems with the input files)')
    print(' c  - continue on with the script (probably after',
          'you\'ve manually re-run and generated the desired',
          'output file(s)')
    print(' x  - exit, keeping the TEMP3D files and log')
    print(' xd - exit, deleting the TEMP3D files and log')
    while True:
        choice = input('Select r, c, x (default), or xd: ')
        if choice not in ('r', 'c', 'x', 'xd'):
            #print('Please enter a valid option.')
            choice = 'x'
        #else:
        break
    if choice == 'x':
        print('Exiting ...')
        sys.exit(1)
    elif choice == 'xd':
        print('Deleting TEMP3D* and log files and exiting ...')
        util.delete_all('TEMP3D*')
        if log is not None:
            os.remove(log)
        sys.exit(1)
    elif choice == 'c':
        print('Continuing on ...')
        break_now = True
    elif choice == 'r':
        print('Retrying %s cmd ...' % program_name)
        break_now = False
    return break_now
def handle_error ( program_name , cmd , log = None ) : print ( '\nHouston, we have a problem.' , '\n%s did not finish successfully. Review the log' % program_name , 'file and the input file(s) to see what went wrong.' ) print ( '%s command: "%s"' % ( program_name , cmd ) ) if log is not None : print ( 'log: "%s"' % log ) print ( 'Where do we go from here?' ) print ( ' r  - retry running %s (probably after' % program_name , 'you\'ve fixed any problems with the input files)' ) print ( ' c  - continue on with the script (probably after' , 'you\'ve manually re-run and generated the desired' , 'output file(s)' ) print ( ' x  - exit, keeping the TEMP3D files and log' ) print ( ' xd - exit, deleting the TEMP3D files and log' ) while True : choice = input ( 'Select r, c, x (default), or xd: ' ) if choice not in ( 'r' , 'c' , 'x' , 'xd' ) : #print('Please enter a valid option.') choice = 'x' #else: break if choice == 'x' : print ( 'Exiting ...' ) sys . exit ( 1 ) elif choice == 'xd' : print ( 'Deleting TEMP3D* and log files and exiting ...' ) util . delete_all ( 'TEMP3D*' ) if log is not None : os . remove ( log ) sys . exit ( 1 ) elif choice == 'c' : print ( 'Continuing on ...' ) break_now = True elif choice == 'r' : print ( 'Retrying %s cmd ...' % program_name ) break_now = False return break_now
Subprocess program error handling

    Args:
        program_name (str): name of the subprocess program

    Returns:
        break_now (bool): indicate whether calling program should break out of loop
Subprocess program error handling