示例#1
0
def executeAndGrabOutput( strCommand, bLimitToFirstLine = False ):
  "execute a command in system shell and return grabbed output"
  "WARNING: it's a 'not efficient' function!"
  strTimeStamp = filetools.getFilenameFromTime();
  strOutputFilename = pathtools.getVolatilePath() + "grab_output_" + strTimeStamp+ ".tmp"; # generate a different file each call for multithreading capabilities
  mySystemCall( strCommand + " > " + strOutputFilename );
  if( bLimitToFirstLine ):
    strBufferRead = filetools.getFileFirstLine( strOutputFilename );
  else:
    strBufferRead = filetools.getFileContents( strOutputFilename );
  try:
    os.unlink( strOutputFilename );
  except:
    pass
  debug.debug( "executeAndGrabOutput: '%s'" % strBufferRead );
  return strBufferRead;
示例#2
0
def executeAndGrabOutput( strCommand, bLimitToFirstLine = False ):
  "execute a command in system shell and return grabbed output"
  "WARNING: it's a 'not efficient' function!"
  strTimeStamp = filetools.getFilenameFromTime();
  strOutputFilename = pathtools.getVolatilePath() + "grab_output_" + strTimeStamp+ ".tmp"; # generate a different file each call for multithreading capabilities
  mySystemCall( strCommand + " > " + strOutputFilename );
  if( bLimitToFirstLine ):
    strBufferRead = filetools.getFileFirstLine( strOutputFilename );
  else:
    strBufferRead = filetools.getFileContents( strOutputFilename );
  try:
    os.unlink( strOutputFilename );
  except:
    pass
  debug.debug( "executeAndGrabOutput: '%s'" % strBufferRead );
  return strBufferRead;
示例#3
0
def getNaoNickName():
    "get the nao name as given by user"
    # return executeAndGrabOutput( "hostname", True );
    return filetools.getFileFirstLine( '/etc/hostname' );
示例#4
0
def getNaoNickName():
    "get the nao name as given by user"
    # return executeAndGrabOutput( "hostname", True );
    return filetools.getFileFirstLine('/etc/hostname')