def fake_execute(*cmd_parts, **kwargs):
 global _fake_execute_repliers
 process_input = kwargs.get('process_input', None)
 check_exit_code = kwargs.get('check_exit_code', 0)
 delay_on_retry = kwargs.get('delay_on_retry', True)
 attempts = kwargs.get('attempts', 1)
 run_as_root = kwargs.get('run_as_root', False)
 cmd_str = ' '.join((str(part) for part in cmd_parts))
 LOG.debug(_('Faking execution of cmd (subprocess): %s'), cmd_str)
 _fake_execute_log.append(cmd_str)
 reply_handler = fake_execute_default_reply_handler
 for fake_replier in _fake_execute_repliers:
  if re.match(fake_replier[0], cmd_str):
   reply_handler = fake_replier[1]
   LOG.debug((_('Faked command matched %s') % fake_replier[0]))
   break
 if isinstance(reply_handler, basestring):
  reply = (reply_handler, '')
 else:
  try:
   reply = reply_handler(cmd_parts, process_input=process_input, delay_on_retry=delay_on_retry, attempts=attempts, run_as_root=run_as_root, check_exit_code=check_exit_code)
  except exception.ProcessExecutionError as e:
   LOG.debug(_('Faked command raised an exception %s'), e)
   raise
 stdout = reply[0]
 stderr = reply[1]
 LOG.debug((_("Reply to faked command is stdout='%(stdout)s' stderr='%(stderr)s'") % locals()))
 greenthread.sleep(0)
 return reply

def fake_execute ( * cmd_parts , ** kwargs ) : global _fake_execute_repliers process_input = kwargs . get ( 'process_input' , None ) check_exit_code = kwargs . get ( 'check_exit_code' , 0 ) delay_on_retry = kwargs . get ( 'delay_on_retry' , True ) attempts = kwargs . get ( 'attempts' , 1 ) run_as_root = kwargs . get ( 'run_as_root' , False ) cmd_str = ' ' . join ( ( str ( part ) for part in cmd_parts ) ) LOG . debug ( _ ( 'Faking execution of cmd (subprocess): %s' ) , cmd_str ) _fake_execute_log . append ( cmd_str ) reply_handler = fake_execute_default_reply_handler for fake_replier in _fake_execute_repliers : if re . match ( fake_replier [ 0 ] , cmd_str ) : reply_handler = fake_replier [ 1 ] LOG . debug ( ( _ ( 'Faked command matched %s' ) % fake_replier [ 0 ] ) ) break if isinstance ( reply_handler , basestring ) : reply = ( reply_handler , '' ) else : try : reply = reply_handler ( cmd_parts , process_input = process_input , delay_on_retry = delay_on_retry , attempts = attempts , run_as_root = run_as_root , check_exit_code = check_exit_code ) except exception . ProcessExecutionError as e : LOG . debug ( _ ( 'Faked command raised an exception %s' ) , e ) raise stdout = reply [ 0 ] stderr = reply [ 1 ] LOG . debug ( ( _ ( "Reply to faked command is stdout='%(stdout)s' stderr='%(stderr)s'" ) % locals ( ) ) ) greenthread . sleep ( 0 ) return reply
this function stubs out execute .