def writeTmpFile(processPid, content): """ Write the temp file """ fileName = os.path.join(tempfile.gettempdir(), 'mms-' + str(processPid)) f = open(fileName, 'wb', 0) try: f.write(bson.BSON.encode(content)) finally: f.close() if __name__ == "__main__": logger = logConfig.initLogger() logger.info('Starting agent process - version %s' % (_agentVersion)) sessionKey = generateSessionKey() parentPid = None try: if len(sys.argv) > 1: parentPid = sys.argv[1] currentState = readTmpFile(parentPid) if currentState is not None: if 'sessionKey' in currentState: sessionKey = currentState['sessionKey'] else:
f.close() def writeTmpFile( processPid, content ): """ Write the temp file """ fileName = os.path.join( tempfile.gettempdir(), 'mms-' + str( processPid ) ) f = open( fileName, 'wb', 0 ) try: f.write( bson.BSON.encode( content) ) finally: f.close() if __name__ == "__main__": logger = logConfig.initLogger() logger.info( 'Starting agent process - version %s' % ( _agentVersion ) ) sessionKey = generateSessionKey() parentPid = None try: if len( sys.argv ) > 1: parentPid = sys.argv[1] currentState = readTmpFile( parentPid ) if currentState is not None: if 'sessionKey' in currentState: sessionKey = currentState['sessionKey'] else: