<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def set_mav_version(mav10, mav20, autoProtocol, mavversionArg):
    '''Set the Mavlink version based on commandline options'''
#    if(mav10 == True or mav20 == True or autoProtocol == True):
#        print("Warning: Using deprecated --mav10, --mav20 or --auto-protocol options. Use --mavversion instead")

    #sanity check the options
    if (mav10 == True or mav20 == True) and autoProtocol == True:
        print("Error: Can't have [--mav10, --mav20] and --auto-protocol both True")
        sys.exit(1)
    if mav10 == True and mav20 == True:
        print("Error: Can't have --mav10 and --mav20 both True")
        sys.exit(1)
    if mavversionArg is not None and (mav10 == True or mav20 == True or autoProtocol == True):
        print("Error: Can't use --mavversion with legacy (--mav10, --mav20 or --auto-protocol) options")
        sys.exit(1)

    #and set the specific mavlink version (False = autodetect)
    global mavversion
    if mavversionArg == "1.0" or mav10 == True:
        os.environ['MAVLINK09'] = '1'
        mavversion = "1"
    else:
        os.environ['MAVLINK20'] = '1'
        mavversion = "2"