if data: return data else: return '' if __name__ == '__main__': """ To run tests : python b3/parsers/q3a_rcon.py <rcon_ip> <rcon_port> <rcon_password> """ from b3.fake import fakeConsole r = Rcon(fakeConsole, (sys.argv[1], int(sys.argv[2])), sys.argv[3]) for cmd in ['say "test1"', 'say "test2"', 'say "test3"', 'say "test4"', 'say "test5"']: fakeConsole.info('Writing %s', cmd) data = r.write(cmd) fakeConsole.info('Recieved %s', data) print '----------------------------------------' for cmd in ['say "test1"', 'say "test2"', 'say "test3"', 'say "test4"', 'say "test5"']: fakeConsole.info('Writing %s', cmd) data = r.write(cmd, socketTimeout=0.45) fakeConsole.info('Recieved %s', data) print '----------------------------------------' for cmd in ['.B3', '.Administrator', '.Admin', 'status', 'sv_mapRotation', 'players']: fakeConsole.info('Writing %s', cmd) data = r.write(cmd) fakeConsole.info('Recieved %s', data)
host = sys.argv[1] port = int(sys.argv[2]) pw = sys.argv[3] from b3.fake import fakeConsole import b3.parsers.frostbite.connection as fbConnection fbConnection.debug = True r = Rcon(fakeConsole, (host, port), pw) r.write(('admin.yell', 'test', 1400, 'player', 'Courgette')) for cmd in ['version', 'serverInfo', 'help', 'version', 'admin.currentLevel', ('admin.listPlayers', 'all')]: fakeConsole.info('Writing %s', cmd) data = r.write(cmd) fakeConsole.info('Recieved %s', data) print '----------------------------' varlist = ( '3dSpotting', 'bannerUrl', 'crossHair', 'currentPlayerLimit', 'friendlyFire', 'gamePassword', 'hardCore', 'killCam', 'maxPlayerLimit',
port = int(sys.argv[2]) pw = sys.argv[3] from b3.fake import fakeConsole import b3.parsers.frostbite.connection as fbConnection fbConnection.debug = True r = Rcon(fakeConsole, (host, port), pw) r.write(('admin.yell', 'test', 1400, 'player', 'Courgette')) for cmd in [ 'version', 'serverInfo', 'help', 'version', 'admin.currentLevel', ('admin.listPlayers', 'all') ]: fakeConsole.info('Writing %s', cmd) data = r.write(cmd) fakeConsole.info('Recieved %s', data) print '----------------------------' varlist = ('3dSpotting', 'bannerUrl', 'crossHair', 'currentPlayerLimit', 'friendlyFire', 'gamePassword', 'hardCore', 'killCam', 'maxPlayerLimit', 'miniMap', 'miniMapSpotting', 'playerLimit', 'punkBuster', 'rankLimit', 'ranked', 'serverDescription', 'teamBalance', 'thirdPersonVehicleCameras') #for var in varlist: #time.sleep(0.5) #print r.write('vars.%s' % var)[0] print '----------------------------'