Best Python code snippet using fMBT_python
default.py
Source:default.py  
1import os2import shutil3import fileinput4import xbmc, xbmcgui5	6Addon_NAME='Navi-X freeze fix'7class Main:8	#set main variables9	#andriod_path = ('//storage/sdcard0/Android/data/org.xbmc.xbmc/files/.xbmc/addons')10	#droid = xbmc.validatePath('//storage/sdcard0/Download/navix.py')11	directory_NaviX = (xbmc.translatePath('special://home/addons/Navi-X'))12	directory_navi_src = (xbmc.translatePath('special://home/addons/Navi-X/src' ))13	fix_dir = (xbmc.translatePath('special://home/addons/script.program.Navi-X-freeze-fix/src' ))14	addon_xml = os.path.join((xbmc.translatePath('special://home/addons/Navi-X')), 'addon.xml')15	16	fix_navix = os.path.join(fix_dir,'navix.py')	17	navix = os.path.join(directory_navi_src,'navix.py')18	navix_old = os.path.join(directory_navi_src,'navix.old')19	20	fix_fileloader = os.path.join(fix_dir,'CFileLoader.py')21	fileloader = os.path.join(directory_navi_src,'CFileLoader.py')22	fileloader_old = os.path.join(directory_navi_src,'CFileLoader.old')23	24	fix_playlist = os.path.join(fix_dir,'CPlayList.py')25	playlist = os.path.join(directory_navi_src,'CPlayList.py')26	playlist_old = os.path.join(directory_navi_src,'CPlayList.old')27	28	status = 'failed'29	version = 'invalid'30class Background(xbmcgui.Window):31    def __init__(self	):32    	self.background = (xbmc.translatePath('special://home/addons/script.program.Navi-X-freeze-fix/fanart.jpg'))33    	self.addControl(xbmcgui.ControlImage(0,0,1280,720, self.background, aspectRatio=1)) 34    		35class Display(xbmcgui.Window):36	#background and four input dialog buttons37	ACTION_PREVIOUS_MENU = 1038	ACTION_NAV_BACK = 92 39	def __init__(self):40		self.background = (xbmc.translatePath('special://home/addons/script.program.Navi-X-freeze-fix/fanart.jpg'))41		self.addControl(xbmcgui.ControlImage(0,0,1280,720, self.background, aspectRatio=1))42		self.strActionInfo = xbmcgui.ControlLabel(520, 300, 300, 300, '', 'font30', '0xFFFF00FF')43		self.addControl(self.strActionInfo)44		self.strActionInfo.setLabel(Addon_NAME)45		self.button0 = xbmcgui.ControlButton(385, 380, 135, 30, "  Freeze Fix")46		self.addControl(self.button0)47		self.button1 = xbmcgui.ControlButton(575, 380, 135, 30, "Freeze Undo")48		self.addControl(self.button1)49		self.button2 = xbmcgui.ControlButton(785, 380, 135, 30, "      Exit")50		self.addControl(self.button2)51		self.button3 = xbmcgui.ControlButton(575, 430, 135, 30, " Gotham Fix")52		self.addControl(self.button3)53		54		self.setFocus(self.button2)	55			56		self.button0.controlRight(self.button1)57		self.button0.controlLeft(self.button3)58		self.button0.controlUp(self.button3)59		self.button0.controlDown(self.button3)60		61		self.button1.controlRight(self.button2)62		self.button1.controlLeft(self.button0)63		self.button1.controlUp(self.button3)64		self.button1.controlDown(self.button3)65		66		self.button2.controlRight(self.button3)67		self.button2.controlLeft(self.button1)68		self.button2.controlUp(self.button3)69		self.button2.controlDown(self.button3)70		71		self.button3.controlRight(self.button0)72		self.button3.controlLeft(self.button2)73		self.button3.controlUp(self.button0)74		self.button3.controlDown(self.button0)75		76		77	def onAction(self, action):78		#non Display Button control79		if action == self.ACTION_PREVIOUS_MENU:80			self.close()81		if action == self.ACTION_NAV_BACK:82			self.close()83	def onControl(self, control):84		#Display Button control85		if control == self.button0:86			freeze_install(Main)87			88		if control == self.button1:89			freeze_uninstall(Main)90		91		if control == self.button3:92			xml_mod(Main)93			94		if control == self.button2:95			self.close()96			97		98def freeze_install(Main):    99	#install freeze fix100	LoG("hello. install.")101	if Main.version == ('valid'):102		if (not os.path.exists(Main.navix)) or (not os.path.exists(Main.fileloader)) or (not os.path.exists(Main.fileloader)):103			message("Error", "You do not appear to have Navi-X installed.")104			#notification("Error", "You do not appear to have Navi-X installed.")105			LoG("Error. You do not appear to have Navi-X installed.")106		else:107			###### navix108			if os.path.exists(Main.navix):109				if os.path.exists(Main.navix_old):110					os.remove(Main.navix)111					#devicelog(freezelog," removed navix.\n")112				else:113					os.rename(Main.navix, Main.navix_old)114					#devicelog(freezelog," renamed to navixold.\n") 115			try:116				#devicelog(freezelog," do shutil.copy2.\n")117				shutil.copy2(Main.fix_navix, Main.navix) 118				Main.status = 'success'			119			except :120				if os.path.exists(Main.navix):  # need this for android. it will copy but fault121					Main.status = 'success'122					#devicelog(freezelog," copied navix.\n")123					#message("Notice", "the fix has moved the files")124					'''try:    # for checking files for android125						shutil.copy2(Main.navix, Main.droid)					126					except :    # need this for android. it will copy but fault127						pass'''									128				else:129					LoG("Error. Could not do shutil.copy for navix.")130					#devicelog(freezelog," Could not do navx shutil.copy.\n")			131										132			######  CFileLoader133			if os.path.exists(Main.fileloader):134				if os.path.exists(Main.fileloader_old):135					os.remove(Main.fileloader)136				else:137					os.rename(Main.fileloader, Main.fileloader_old)138					#devicelog(freezelog," renamed to Cfileloaderold\n")139			try:140				#devicelog(freezelog," do shutil.copy2.\n")141				shutil.copy2(Main.fix_fileloader, Main.fileloader)142				Main.status = 'success'	143			except:144				if os.path.exists(Main.fileloader):   # need this for android. it will copy but fault145					Main.status = 'success'146					LoG("copied. fileloader.")147					#devicelog(freezelog,"  copied. Cfileloader.\n")148					#message("Notice", "the fix has moved the files")149					'''try:    # for checking files for android150						shutil.copy2(Main.fileloader, Main.droid)					151					except :    # need this for android. it will copy but fault152						pass'''										153				else:154					LoG("Error. Could not do shutil.copy for fileloader.")155					#devicelog(freezelog," Could not do fileloader shutil.copy.\n")156		157			######  CPlayList158			if os.path.exists(Main.playlist):159				if os.path.exists(Main.playlist_old):160					os.remove(Main.playlist)161				else:162					os.rename(Main.playlist, Main.playlist_old)163					#devicelog(freezelog," renamed to CPlayList\n")164			try:165				#devicelog(freezelog," do shutil.copy2.\n")166				shutil.copy2(Main.fix_playlist, Main.playlist)167				Main.status = 'success'	168			except:169				if os.path.exists(Main.playlist):   # need this for android. it will copy but fault170					Main.status = 'success'171					LoG("copied. CPlayList.")172					#devicelog(freezelog,"  copied. CPlayList.\n")173					#message("Notice", "the fix has moved the files")174					'''try:    # for checking files for android175						shutil.copy2(Main.playlist, Main.droid)					176					except :    # need this for android. it will copy but fault177						pass'''										178				else:179					LoG("Error. Could not do shutil.copy2 for playlist.")180					#devicelog(freezelog," Could not do playlist shutil.copy2.\n")181								182			if Main.status == 'success':183				message("Success", "The fix has been installed.")184				#notification("Success", "The fix has been installed.")185				LoG("fix. installed.")186			else:187				message("Error", "The fix installarion has failed.")188				189	elif Main.version == ('invalid'):190		message("Notice", "You need Navi-X version 3.7.8 to run this fix.")191								192def freeze_uninstall(Main):    193	#uninstall freeze fix194	LoG("hello. uninstall.")195	if Main.version == ('valid'):196		if (not os.path.exists(Main.navix)) or (not os.path.exists(Main.fileloader)) or (not os.path.exists(Main.playlist)):197			message("Error", "You do not appear to have Navi-X installed.")198			LoG("error. You do not appear to have Navi-X installed.") 199		elif (not os.path.exists(Main.navix_old)) or (not os.path.exists(Main.fileloader_old)) or (not os.path.exists(Main.playlist_old)):200			message("Error", "You do not appear to have original files to restore from. \nOr have not run this fix before")201			#notification("Error", "You do not appear to have Navi-X freeze fix installed."); 202		else:203			if os.path.exists(Main.navix):204				os.remove(Main.navix)205				os.rename(Main.navix_old, Main.navix)206		207			if os.path.exists(Main.fileloader):208				os.remove(Main.fileloader)209				os.rename(Main.fileloader_old,Main.fileloader)210				211			if os.path.exists(Main.playlist):212				os.remove(Main.playlist)213				os.rename(Main.playlist_old,Main.playlist)214					215			message("Success", "The fix has been removed.")216			#notification("Success", "The fix has been removed.") 217			LoG("fix. removed.")218			#devicelog(freezelog," The fix has been removed.\n")219	elif Main.version == ('invalid') :220		message("Notice", "You need Navi-X version 3.7.8 to run this fix.")221def xml_mod(Main):    222	#modify addon.xml for use with Gotham223	success = 0224	with open(Main.addon_xml, 'r+') as xml:225		for line in fileinput.input((Main.addon_xml), inplace=1):226			if ('"xbmc.python" version="1.0"') in line:227				line = line.replace('1.0' , '2.1.0')228				success = 1229			elif ('"xbmc.python" version="2.1.0"') in line:230				success = 2				231			print(line),			232	if success == 1:				233		message("Success","Navi-X is now all setup to run on Gotham")								234	elif success == 2:235			message("Notice","Navi-X was already setup to run on Gotham")								236	elif success == 0:237			message("Error","Could not find Python version number")238	xml.close()	239		240def version_chk(Main):    241	#check for Navi-X version 3.7.8 in line 4 of addon.xml242	with open(Main.addon_xml, 'r') as xml:243		for line in xml:244			if ('"3.7.8"') in line:245				print (Addon_NAME+ ": Navi-X " +line)246				LoG("Main.version. valid.")247				Main.version = ('valid')248				break249	xml.close()	250	251def message(title, message):252	#### Output display box253	dialog = xbmcgui.Dialog()254	dialog.ok(title, message)	255			256###### Error reporting257#create an accessable log for debugging android258#freezelog = xbmc.validatePath('//storage/sdcard0/Download/Navi-x-freeze.log')259#open(freezelog, 'w+').close()260def devicelog(path,text='',var=''):    261	with open(path, 'a+') as log:262		log.write(text)263		log.write(var)264	log.close()265#XBMC log	266def LoG(t=''): print Addon_NAME+": "+t267#on screen268def notification(header="", message="", sleep=5000 ): xbmc.executebuiltin( "XBMC.Notification(%s,%s,%i)" % ( header, message, sleep ) )269		270#### Start of program271if os.path.exists(Main.directory_NaviX):	272	version_chk(Main)		273	fix_display = Display()274	fix_display.doModal()275	del fix_display							276else:277	display = Background()278	display.show()279	message(Addon_NAME, "Can not find the Navi-X folder. \nPlease install the official Navi-X addon.")280	display.close()281	del display		282    	...mps_checkout.py
Source:mps_checkout.py  
1#This script will check that all thresholds for an app id are corectly functioning2#The user will then check that the screen shows the expected ouput3#4import sys5import os6from datetime import datetime, date7import time8import argparse9import epics as e10import json11def process_args(argv):12     parser=argparse.ArgumentParser(description='This script is used to verify the MPS system set points')13     parser.add_argument('-AppID', required=True, type = int, help = 'The MPS app id you are checking out')14     parser.add_argument('-SrcFileLoc', required=True, type = str, help='The directory containing the checkout JSON files')15     parser.add_argument('-LogFileLoc', required=True, type = str, help='The directory where the log files will be written to')16     parser.add_argument('-UserName', required=True, type = str, help='Your username')17     parser.add_argument('-FirstName',required=True, type = str)18     parser.add_argument('-LastName',required=True, type = str)19     parser.add_argument('-Auto',required=False, type = str, choices=['True','False'])20     parser=parser.parse_args()21     return parser22def query_yes_no(question, bypass):23    if(bypass):24        return True25    valid = {"yes": True, "y": True, "no": False, "n": False}26    prompt = " [y/n] "27    while True:28        sys.stdout.write(question + prompt)29        choice = input().lower()30        if choice in valid:31            return valid[choice]32        else:33            sys.stdout.write("Please respond with 'yes' or 'no' " "(or 'y' or 'n').\n")34def tell_user_fault():35    print("Thanks you for confirming this problem has been logged")36def enable_thresholds(thresholdCount, device, table, mode):37    for threshold in range(thresholdCount-1, -1, -1):38        e.caput(device+'_T'+str(threshold)+'_'+table+'_EN',mode) 39def set_thresholds_safe(thresholdCount, device, safeMargin, table):40    for threshold in range(thresholdCount-1, -1, -1):41        currentValue = e.caget(device)42        safeSetPoint = (safeMargin+10*threshold)*abs(currentValue)43        e.caput(device+'_T'+str(threshold)+'_'+table,safeSetPoint)44def test_threshold(thresholdCount, safeMargin, testMargin, device, table, logDict ,skipUser):45    for threshold in range(thresholdCount-1, -1, -1):  46        currentValue = e.caget(device)47        safeSetPoint = (safeMargin+10*threshold)*abs(currentValue)48        testSetPoint = (testMargin+10*threshold)*abs(currentValue)49        print(device+'_T'+str(threshold)+'_'+table)50        #test High set point51        e.caput(device+'_T'+str(threshold)+'_'+table,-testSetPoint, wait=True) 52        time.sleep(2)53        thresholdState = e.caget(device+'_T'+str(threshold)+'_SCMPSC', use_monitor=False)54        logicState = e.caget(device+'_LINAC_LOGIC', use_monitor=False)55        if((query_yes_no("Is "+str(device)+' threshold '+str(threshold)+' in state IS_EXCEDED',skipUser)) and thresholdState):56            logDict['threshold'+table+str(threshold)] = [1,1,1] 57        elif(not(thresholdState)):58            tell_user_fault()59            logDict['threshold'+table+str(threshold)] = [0,1,1] 60        else:61            if(query_yes_no('Are you looking at '+device+'_T'+str(threshold),skipUser)):62                tell_user_fault()63                logDict['threshold'+table+str(threshold)] = [1,1,0]64            else:65                if(query_yes_no("Confirm "+str(device)+' threshold '+str(threshold)+' in state IS_EXCEDED',skipUser)):66                    logDict['threshold'+table+str(threshold)] = [1,1,1]67                else:68                    tell_user_fault()69                    logDict['threshold'+table+str(threshold)] = [1,1,0]        70        if((query_yes_no("Is "+device+'_LINAC_LOGIC in state: B'+ str(threshold),skipUser)) and ((thresholdCount-threshold)==logicState)):71            logDict['logic'+table+str(threshold)] = [1,1,1]72        elif(not((thresholdCount-threshold)==logicState)):73            tell_user_fault()74            logDict['logic'+table+str(threshold)] = [0,1,1]75        else:76            if(query_yes_no('Are you looking at '+device+'_LINAC_LOGIC',skipUser)):77                tell_user_fault()78                logDict['logic'+table+str(threshold)] = [1,1,0]79            else:80                if(query_yes_no("Confirm "+device+'_LINAC_LOGIC is in state: B'+ str(threshold),skipUser)):81                    logDict['logic'+table+str(threshold)] = [1,1,1]82                else:83                    tell_user_fault()84                    logDict['logic'+table+str(threshold)] = [1,1,0]85def main(argv):86    controls =  process_args(argv)87    if(controls.Auto == 'True'):88        skip = True89    else:90        skip = False91    with open(controls.SrcFileLoc+ "/" + "App"+str(controls.AppID) + "_checkout.json") as json_file:92        appInfo = json.load(json_file)93    checkOutLog = {"UserInfo":{'DateTime':datetime.now().strftime("%d/%m/%Y %H:%M:%S"),'UserName':controls.UserName, 'FirstName': controls.FirstName, 'LastName': controls.LastName},94                   "AppInfo": {'AppID': controls.AppID, 'devices':appInfo['devices']}}95    #add software and firmware version to App info96    #add appid related things enable the whole device to chekcout and log97    #each item checked has a list [value of bool, computer check, person check] 1 is considered normal 0 is considered fault98    print(checkOutLog)99    print("Checking out mps device: ", controls.AppID)#, " with software version ", softwareVersion, "\n")100    for device in appInfo['devices']:101        deviceFault = False102        deviceLog = {}103        print("\n\nWorking on device: ", device)104        #verify threshold count105        thresholdCount = e.caget(device+'_THR_CNT')106        confirmScreen = False107        while(not(confirmScreen)):108            if(query_yes_no("Verify for device "+str(device)+ " threshold count = "+ str(thresholdCount),skip)):109                deviceLog['ThresholdNum']= [thresholdCount, 1,1]110                confirmScreen = True111            elif(query_yes_no("Verify you are looking at the display for: "+ device),skip):112                tell_user_fault()113                deviceLog['ThresholdNum']= [thresholdCount, 1,0]114                deviceFault = True115                break    116            else:117                print("Please open the display for ", device)118        if(not(deviceFault)):   119            print("Setting all thresholds to non fault state")120########### ########### ########### ########### ########### ########### ########### ########### ########### ########### ###########            121            #temporary workaround since threshold 7 PVs are not hosted122            if(thresholdCount == 8):123               thresholdCount -= 1124########### ########### ########### ########### ########### ########### ########### ########### ########### ########### ###########               125            enable_thresholds(thresholdCount, device, 'H', 1)126            enable_thresholds(thresholdCount, device, 'L', 1)127            safeMargin = 1000128            testMargin =500        129            set_thresholds_safe(thresholdCount, device, safeMargin, 'H')        130            set_thresholds_safe(thresholdCount, device, -safeMargin, 'L') 131            time.sleep(2)132            logicState = e.caget(device+'_LINAC_LOGIC', use_monitor=False)133            confirmAllInBounds = False134            while(not(confirmAllInBounds)):   135                if((query_yes_no("Is "+str(device)+' in state IS_OK for all thresholds',skip))and(logicState==0)):136                    deviceLog['AllThreshold'] = [1, 1, 1]137                    confirmAllInBounds = True138                elif(not(logicState==0)):139                    deviceLog['AllThreshold'] = [0, 1, 1]140                    tell_user_fault()141                    break142                else:143                    if(query_yes_no('Are you looking at '+device+'_LINAC_LOGIC',skip)):144                        tell_user_fault()145                        deviceLog['AllThreshold'] = [1, 1, 0]146                    else:147                        if(query_yes_no("Confirm "+device+'_LINAC_LOGIC is in state: B'+ str(threshold),skip)):148                            deviceLog['AllThreshold'] = [1, 1, 1]149                        else:150                            tell_user_fault()151                            deviceLog['AllThreshold'] = [1, 1, 0]152            thresholdFault = False153            #test the standard table high limits   154            print("Testing high thresholds for device: ", device)155            test_threshold(thresholdCount, safeMargin, testMargin, device, 'H', deviceLog, skip)156            print("Thank you for checking out the high thresholds")157            print("We will now test the low thresholds\n")158            print("Setting the thresholds to a safe possition\n")159            set_thresholds_safe(thresholdCount, device, safeMargin, 'H')        160            set_thresholds_safe(thresholdCount, device, -safeMargin, 'L')  161            #test standard table low limits 162            print("Testing low thresholds for device: ", device)163            test_threshold(thresholdCount, -safeMargin, -testMargin, device, 'L', deviceLog, skip)164            print(deviceLog)165            checkOutLog[device] = deviceLog166            deviceLog={}167            print("Thank you for checking out the low thresholds")168            print("You have now checked the entire standard table")169        deviceFault = False170    print("MPS AppID ", controls.AppID, " has now been checked out.")171    logInfo = json.dumps(checkOutLog)172    checkOutFile = open(os.path.join(controls.LogFileLoc, "App"+str(controls.AppID)+"_checkout.json"), 'w')173    checkOutFile.write(logInfo)174    print("A checkout file named: ", "App"+str(controls.AppID)+"_checkout.json", " has been written to: ", controls.LogFileLoc)175    return 0176if __name__ == "__main__":177    main(sys.argv[1:])178© 2022 GitHub, Inc.179Terms180Privacy181Security182Status183Docs184Contact GitHub185Pricing186API187Training188Blog...json_reader.py
Source:json_reader.py  
1import json2import datetime3from collections import OrderedDict4class SuuntoJSON:5    def __init__(self):6        self.name = None7        self.datetime = None8        self.gnss = str()9        self.altibaro = str()10        self.fusedalti = False11        self.steps = 012        self.duration = 013        self.distance = 014        self.running_distance = OrderedDict()15        self.ascent = 016        self.descent = 017        self.sensors = []18        self.apps = []19        self.temperature = OrderedDict()20        self.altitude = OrderedDict()21        self.gps_altitude = OrderedDict()22        self.gps_snr = OrderedDict()23        self.ehpe = OrderedDict()24        self.evpe = OrderedDict()25        self.battery_charge = OrderedDict()26        self.cadence = OrderedDict()27        self.hr = OrderedDict()28        self.rr = []29        self.power = OrderedDict()30    def load_file(self, filename: str):31        with open(filename) as file:32            temp = json.load(file)33        # Header34        try:35            self.name = f"{temp['DeviceLog']['Header']['Device']['Name']} {temp['DeviceLog']['Header']['Device']['Info']['SW']}"36        except KeyError:37            pass38        try:39            self.datetime = datetime.datetime.fromisoformat(temp["DeviceLog"]["Header"]["DateTime"])40        except KeyError:41            pass42        try:43            self.gnss = temp["DeviceLog"]["Header"]["Settings"]["EnabledNavigationSystems"]44        except KeyError:45            pass46        try:47            self.altibaro = temp["DeviceLog"]["Header"]["Settings"]["AltiBaroProfile"]48        except KeyError:49            pass50        try:51            self.duration = float(temp["DeviceLog"]["Header"]["Duration"])52        except KeyError:53            pass54        try:55            self.distance = float(temp["DeviceLog"]["Header"]["Distance"]) / 100056        except KeyError:57            pass58        try:59            if temp["DeviceLog"]["Header"]["Ascent"] is not None:60                self.ascent = temp["DeviceLog"]["Header"]["Ascent"]61        except KeyError:62            pass63        try:64            if temp["DeviceLog"]["Header"]["Descent"] is not None:65                self.descent = temp["DeviceLog"]["Header"]["Descent"]66        except KeyError:67            pass68        try:69            if temp["DeviceLog"]["Header"]["Settings"]["BikePodUsed"] is True:70                self.sensors.append("Bike Pod")71        except KeyError:72            pass73        try:74            if temp["DeviceLog"]["Header"]["Settings"]["FootPodUsed"] is True:75                self.sensors.append("Foot Pod")76        except KeyError:77            pass78        try:79            if temp["DeviceLog"]["Header"]["Settings"]["PowerPodUsed"] is True:80                self.sensors.append("Power Pod")81        except KeyError:82            pass83        try:84            if temp["DeviceLog"]["Header"]["Settings"]["FusedAltiUsed"] is True:85                self.fusedalti = True86        except KeyError:87            pass88        try:89            if temp["DeviceLog"]["Header"]["Settings"]["HrUsed"] is True:90                self.sensors.append("Heart Rate")91        except KeyError:92            pass93        try:94            if temp["DeviceLog"]["Header"]["StepCount"] is not None:95                self.steps = temp["DeviceLog"]["Header"]["StepCount"]96        except KeyError:97            pass98        # Samples99        for sample in temp["DeviceLog"]["Samples"]:100            timestamp = sample["TimeISO8601"]101            # Temperature102            try:103                if sample["Temperature"] is not None:104                    self.temperature[timestamp] = sample["Temperature"]105            except KeyError:106                pass107            # Altitude108            try:109                if sample["Altitude"] is not None:110                    self.altitude[timestamp] = sample["Altitude"]111            except KeyError:112                pass113            # GPS altitude114            try:115                if sample["GPSAltitude"] is not None:116                    self.gps_altitude[timestamp] = sample["GPSAltitude"]117            except KeyError:118                pass119            # SNR 5 best satellites120            try:121                self.gps_snr[timestamp] = sample["Satellite5BestSNR"]122            except KeyError:123                pass124            # EHPE and EVPE125            try:126                self.ehpe[timestamp] = sample["EHPE"]127            except KeyError:128                pass129            try:130                self.evpe[timestamp] = sample["EVPE"]131            except KeyError:132                pass133            # Battery charge134            try:135                self.battery_charge[timestamp] = sample["BatteryCharge"]136            except KeyError:137                pass138            # Cadence139            try:140                if sample["Cadence"] is not None:141                    self.cadence[timestamp] = sample["Cadence"] * 60.0142            except KeyError:143                pass144            # Power145            try:146                if sample["Power"] is not None:147                    self.power[timestamp] = sample["Power"]148            except KeyError:149                pass150            # Distance over time151            try:152                if sample["Distance"] is not None:153                    self.running_distance[timestamp] = sample["Distance"]154            except KeyError:155                pass156            # Internal HR157            try:158                if sample["HR"] is not None:159                    self.hr[timestamp] = sample["HR"] * 60.0160            except KeyError:161                pass162        # External HR163        try:164            for value in temp["DeviceLog"]["R-R"]["Data"]:165                self.rr.append(value)166        except KeyError:167            pass168        # S+ apps169        try:170            for app in temp["DeviceLog"]["Zapps"]:171                self.apps.append(app["Name"])172        except KeyError:173            pass...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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
