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;
def getNaoNickName(): "get the nao name as given by user" # return executeAndGrabOutput( "hostname", True ); return filetools.getFileFirstLine( '/etc/hostname' );
def getNaoNickName(): "get the nao name as given by user" # return executeAndGrabOutput( "hostname", True ); return filetools.getFileFirstLine('/etc/hostname')