How to use __data_uploader method in yandex-tank

Best Python code snippet using yandex-tank

__init__.py

Source:__init__.py Github

copy

Full Screen

1import logging.handlers2import os3from network.dataUploader import DataUploader4from receptor.rootConfig import DATA_OUTPUT_ENABLED, DATA_OUTPUT_HOST, DATA_OUTPUT_PORT, SERVER_HOST, LOG_DIR5from network.dataOutput import DataOutput6from models import RawData, MessageBuffer, ADSBInfo7from receptor.microADSB import MicroADSB8from systemStats import SystemStats9import time10import threading11from pyModeS import adsb12log = logging.getLogger("receptor")13log.setLevel(logging.DEBUG)14formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")15handler = logging.handlers.RotatingFileHandler(16 os.path.join(LOG_DIR, "receptor.log"), maxBytes=4294967296, backupCount=6)17handler.setFormatter(formatter)18log.addHandler(handler)19__running = False20__RAW_BUFFER = {}21__DATA_UPLOADER = DataUploader(serverHost=SERVER_HOST)22__MICRO_ADSB = MicroADSB(autoReconnect=True)23__DATA_OUTPUT = DataOutput(DATA_OUTPUT_HOST, DATA_OUTPUT_PORT)24__SYSTEM_STATS = SystemStats()25 26def onOpen(err):27 if err:28 log.error("Receptor open: %s" % str(err))29 else:30 log.info("Receptor open: opened!")31def onClose(err):32 if err:33 log.error("Receptor close: %s" % str(err))34 else:35 log.info("Receptor close: closed!")36def onErr(err):37 if err:38 log.error("Receptor error: %s" % str(err))39def onMessage(data):40 if data:41 #(monography tests)42 #__SYSTEM_STATS.saveReceivedMessage(data['frame'][1:-1], __SYSTEM_STATS.all_msg_file)43 44 rawData = RawData(data)45 #startStats = time.clock() (monography tests)46 if rawData.downlinkformat == 17 and len(rawData.frame) == 30:47 48 #(monography tests)49 #__SYSTEM_STATS.saveReceivedMessage(data['frame'][1:-1], __SYSTEM_STATS.adsb_msg_file)50 icao = adsb.icao(rawData.frame[1:29]) 51 #log.info("Raw Message Received: %s" % str(rawData.frame)) 52 #__DATA_OUTPUT.addData(rawData.frame) 53 if not icao in __RAW_BUFFER:54 __RAW_BUFFER[icao] = MessageBuffer(icao=icao)55 __RAW_BUFFER[icao].addRawData(rawData) 56 if __RAW_BUFFER[icao].isComplete():57 #log.info("Complete Message Received: %s" % str(__RAW_BUFFER[icao]))58 adsbInfo = ADSBInfo.createFromMessageBuffer(__RAW_BUFFER[icao])59 60 #(monography tests)61 '''if(adsbInfo.DB_saveData() != 0):62 pass63 #print("The aircraft information couldn't be saved!")64 else:65 #print("Aircraft information saved succesfully!")66 67 info2sent = adsbInfo.DB_readData()68 if(info2sent is None):69 pass70 #print("We coudn't read the aircraft information\n")71 else:72 #print("We read the aircraft information\n")73 #log.info("Processed Complete Message: %s" % str(__RAW_BUFFER[icao]))74 __DATA_UPLOADER.addADSBInfo(info2sent)''' 75 #log.info("Processed Complete Message: %s" % str(__RAW_BUFFER[icao]))76 __DATA_UPLOADER.addADSBInfo(adsbInfo) 77 else:78 pass79 #log.info("Invalid Raw Message Received: %s" % str(rawData.frame))80 81 #(monography tests)82 #endStats = time.clock()83 #__SYSTEM_STATS.saveDecodingTime(endStats - startStats)84def onUploaderStart():85 log.info("Uploader started!")86def onUploaderStop():87 log.info("Uploader stoped!")88def start():89 log.info("Starting receptor...")90 global __MICRO_ADSB91 __MICRO_ADSB.onOpen = onOpen92 __MICRO_ADSB.onClose = onClose93 __MICRO_ADSB.onMessage = onMessage94 __MICRO_ADSB.open()95 global __DATA_UPLOADER96 __DATA_UPLOADER.onStart = onUploaderStart97 __DATA_UPLOADER.onStop = onUploaderStop98 __DATA_UPLOADER.start()99 #(monography tests)100 '''global __SYSTEM_STATS101 readStats = threading.Thread(target=__SYSTEM_STATS.saveSystemStats)102 readStats.daemon = True103 readStats.start()'''104 # if DATA_OUTPUT_ENABLED:105 # global __DATA_OUTPUT106 # __DATA_OUTPUT.start()107 try:108 __running = True109 while __running:110 pass111 except:112 __stop()113def stop():114 global __running115 __running = False116def __stop():117 global __MAP_BUFFER118 log.info("Stopping receptor...")119 __MICRO_ADSB.close()120 __DATA_UPLOADER.stop()121 __DATA_OUTPUT.stop()122 __MAP_BUFFER = None123 ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run yandex-tank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful