def process_stdin(line):
 if (line is None):
  sys.exit(0)
 if (mpstate.functions.input_handler is not None):
  mpstate.functions.input_handler(line)
  return
 line = line.strip()
 if mpstate.status.setup_mode:
  if (line == '.'):
   mpstate.status.setup_mode = False
   mpstate.status.flightmode = 'MAV'
   mpstate.rl.set_prompt('MAV> ')
   return
  if (line != '+++'):
   line += '\r'
  for c in line:
   time.sleep(0.01)
   mpstate.master().write(c)
  return
 if (not line):
  return
 args = shlex_quotes(line)
 cmd = args[0]
 while (cmd in mpstate.aliases):
  line = mpstate.aliases[cmd]
  args = (shlex.split(line) + args[1:])
  cmd = args[0]
 if (cmd == 'help'):
  k = command_map.keys()
  k.sort()
  for cmd in k:
   (fn, help) = command_map[cmd]
   print ('%-15s : %s' % (cmd, help))
  return
 if ((cmd == 'exit') and mpstate.settings.requireexit):
  mpstate.status.exit = True
  return
 if (not (cmd in command_map)):
  for (m, pm) in mpstate.modules:
   if hasattr(m, 'unknown_command'):
    try:
     if m.unknown_command(args):
      return
    except Exception as e:
     print ('ERROR in command: %s' % str(e))
  print ("Unknown command '%s'" % line)
  return
 (fn, help) = command_map[cmd]
 try:
  fn(args[1:])
 except Exception as e:
  print ('ERROR in command %s: %s' % (args[1:], str(e)))
  if (mpstate.settings.moddebug > 1):
   traceback.print_exc()

def process_stdin ( line ) : if ( line is None ) : sys . exit ( 0 ) if ( mpstate . functions . input_handler is not None ) : mpstate . functions . input_handler ( line ) return line = line . strip ( ) if mpstate . status . setup_mode : if ( line == '.' ) : mpstate . status . setup_mode = False mpstate . status . flightmode = 'MAV' mpstate . rl . set_prompt ( 'MAV> ' ) return if ( line != '+++' ) : line += '\r' for c in line : time . sleep ( 0.01 ) mpstate . master ( ) . write ( c ) return if ( not line ) : return args = shlex_quotes ( line ) cmd = args [ 0 ] while ( cmd in mpstate . aliases ) : line = mpstate . aliases [ cmd ] args = ( shlex . split ( line ) + args [ 1 : ] ) cmd = args [ 0 ] if ( cmd == 'help' ) : k = command_map . keys ( ) k . sort ( ) for cmd in k : ( fn , help ) = command_map [ cmd ] print ( '%-15s : %s' % ( cmd , help ) ) return if ( ( cmd == 'exit' ) and mpstate . settings . requireexit ) : mpstate . status . exit = True return if ( not ( cmd in command_map ) ) : for ( m , pm ) in mpstate . modules : if hasattr ( m , 'unknown_command' ) : try : if m . unknown_command ( args ) : return except Exception as e : print ( 'ERROR in command: %s' % str ( e ) ) print ( "Unknown command '%s'" % line ) return ( fn , help ) = command_map [ cmd ] try : fn ( args [ 1 : ] ) except Exception as e : print ( 'ERROR in command %s: %s' % ( args [ 1 : ] , str ( e ) ) ) if ( mpstate . settings . moddebug > 1 ) : traceback . print_exc ( )
handle commands from user .