How to use startlog method in pyatom

Best Python code snippet using pyatom_python

ProjectAFinalWithBuzzer.py

Source:ProjectAFinalWithBuzzer.py Github

copy

Full Screen

1import busio2import digitalio3import board4import threading5import datetime6import adafruit_mcp3xxx.mcp3008 as MCP7from adafruit_mcp3xxx.analog_in import AnalogIn8import RPi.GPIO as GPIO9import time10import ES2EEPROMUtils11import os12EPROM= ES2EEPROMUtils.ES2EEPROM() 13from time import sleep1415#global variables16global delay #used to store and set the delay17global runtime #stores the program rutime181920#setup mode21GPIO.setmode(GPIO.BCM)2223#initialise the button pins and buzzer pin24buttonPin=17 #the button pin for turning logging on/off25buttonPin2=27 #the button pin for switching between time delays26buzzer=222728#Set the buttons as Pull-Up buttons29GPIO.setup(buttonPin,GPIO.IN,pull_up_down=GPIO.PUD_UP)30GPIO.setup(buttonPin2,GPIO.IN,pull_up_down=GPIO.PUD_UP)313233# create the spi bus34spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI)3536# create the cs (chip select)37cs = digitalio.DigitalInOut(board.D5)38394041# create the mcp object42mcp = MCP.MCP3008(spi, cs)4344# create an analog input channel on pin 145chan = AnalogIn(mcp, MCP.P1)4647#setup buzzer as output48GPIO.setup(buzzer,GPIO.OUT)4950#setup global variables51global start52global startlog535455#setup pins56def setup():57 58 #global values reset59 global delay #refer to the global value of delay60 global startlog #refer to the global value of startlog61 delay=5 #set delay to be 562 startlog=0 #turn off logging63 #Initialise buzzrr to be off64 GPIO.output(buzzer,GPIO.HIGH)65 66 #Print headings before logging starts67 str = ('Time',"Sys Timer", "Temp")68 print("{0: <20} {1: <20} {2: <20}".format(*str))69 7071def button_pressed():72 global memory #this stores the string that will be sent to the EEPROM73 #set delay to 5 seconds74 delay=575 76 #refer to buzzer77 global buzzer78 79 #create threads80 thread = threading.Timer(delay, button_pressed)81 thread.daemon = True #thread.daemon = True # Daemon threads exit when the program does82 thread.start()8384 if(startlog==1): #check whether to log or not85 #convert the reading to the temperature value in degrees86 temp = round((chan.voltage-0.5)/0.01)87 88 #create and initialise variable for storing the CPU time to be printed out89 mtime=time.strftime('%H:%M:%S')90 91 #calculate runtime using the datetime library92 end=datetime.datetime.now()93 runtime=str((end-start))94 runtime=runtime.split(".")[0] #extract millisdeconds from the runtime reading95 96 97 98 #printout the time; system runtime and temperature to the console. 99 print("{0: <20} {1: <20} {2: <20} ".format(mtime,runtime,str(temp)+" C"))100 101 #setup the "output" string that willbe saved to the EEPROM.102 output=str(mtime+runtime+str(temp))103 104 #create variable which will be used to extract seconds from runtime so as to calculate time to trigger buzzer105 buzzertime=int(str(runtime)[5:7])106 107 if(buzzertime%20==0): #check if runtime has reached a multiple of 20 secons108 GPIO.output(buzzer,GPIO.LOW)#set GPIO to low to trigger buzzer109 sleep(0.5) # Delay in seconds110 GPIO.output(buzzer,GPIO.HIGH)#set GPIO to high to stop buzzer111 112 #this for loop saves the characters of the word "output" to the EEPROM which saves our logging data to EEPROM113 for i in range (17):114 EPROM.write_byte(i,ord(output[i]))#write logging information to EEprom115 116 117 118 119 120def run_program(channel):121 #variable to store the program start time122 global start123 124 #variable startlog to set and track logging125 global startlog126 127 #initialise program start-time128 start= datetime.datetime.now()129 130 #check to turn on/off logging131 if(startlog==1):132 startlog=0133 elif startlog==0:134 startlog=1135 136 #call the threads to run and start logging or stop logging137 button_pressed()138 139 if(startlog==0):#check whether to start/stop logging140 clear = lambda: os.system('clear')#clear shell141 print("Logging has been stopped!")#printout logging stopped message142 143 144 145#add an event listener to check whether the start/stop logging button has been pressed146GPIO.add_event_detect(buttonPin,GPIO.FALLING,callback=run_program,bouncetime=700)147148149150if __name__ == "__main__":151 #setup the environment152 setup()153 154155 while True:156 pass ...

Full Screen

Full Screen

xml_operation.py

Source:xml_operation.py Github

copy

Full Screen

1import os2import re3from xml.dom.minidom import parse4def ExtractLinker(ProjectLocation,MakeFileName):5 XmlFileName = os.path.join(os.path.join(ProjectLocation,"nbproject"),"configurations.xml")6 ScanforLkrFile = 07 LinkerName = ''8 AllLinkerList = []9 Configuration = MakeFileName[9: -3]10 XmlFilePtr = open(XmlFileName,'r')11 for Line in XmlFilePtr:12 Line = Line.strip("\n|\r")13 Line = Line.strip(" ")14 if re.search("</logicalFolder>",Line):15 ScanforLkrFile = 016 if 1 == ScanforLkrFile:17 if re.search("<itemPath>",Line):18 #Line = re.sub(" ",'',Line)19 LinkerName = re.sub("<itemPath>|</itemPath>",'',Line)20 AllLinkerList.append(LinkerName)21 if re.search("\<logicalFolder name=\"LinkerScript\"",Line):22 ScanforLkrFile = 123 XmlFilePtr.close()24 25 ########################################26 ########################################27 XmlFilePtr = open(XmlFileName,'r')28 StartLog = 029 LineLog = ''30 for Line in XmlFilePtr:31 Line = Line.strip("\n|\r")32 Line = Line.strip(" ")33 if re.search("</conf>",Line):34 ScanforLkrFile = 035 if 1 == ScanforLkrFile:36 37 if re.search(">",Line) and 1 == StartLog: 38 StartLog = 039 for i in AllLinkerList:40 if re.search(i,LineLog):41 if re.search("ex=\"true\"",LineLog):42 AllLinkerList.remove(i)43 break 44 45 if 1 == StartLog: 46 LineLog = LineLog + Line47 48 if re.search("<item path=",Line):49 50 LineLog = Line51 52 if re.search(">",Line): ## if the item ends in the same line, then, look for the existance to EX=TRUE53 StartLog = 054 for i in AllLinkerList:55 if re.search(i,LineLog):56 if re.search("ex=\"true\"",LineLog):57 AllLinkerList.remove(i)58 break59 else: ## Else, log the line, till the end of the item path.60 StartLog = 161 ConfName = "<conf name=\"" + Configuration + '"'62 if re.search(ConfName,Line):63 ScanforLkrFile = 164 StartLog = 065 66 return(AllLinkerList)67def get_all_project_config(project_location):68 all_config = []69 all_compiler = []70 71 config_xml_path = os.path.join(project_location, "nbproject/configurations.xml")72 config_xml_path = os.path.normpath(config_xml_path)73 74 if os.path.exists(config_xml_path):75 try:76 dom = parse(config_xml_path)77 all_confs = dom.getElementsByTagName("conf")78 for all_conf in all_confs:79 if all_conf.ELEMENT_NODE == all_conf.nodeType:80 if all_conf.attributes: 81 for i in range(all_conf.attributes.length): 82 a = all_conf.attributes.item(i)83 if a.name == "name": 84 all_config.append(a.value.encode('ascii','ignore'))85 tgt_compiler = ''86 tgt_compiler_node = all_conf.getElementsByTagName("languageToolchain")[0]87 if len(tgt_compiler_node.childNodes) >= 1:88 tgt_compiler = tgt_compiler_node.childNodes[0].data.encode('ascii','ignore') 89 all_compiler.append(tgt_compiler)90 except:91 print "corrupted project_files"92 93 return(all_config, all_compiler)94 95 96def get_compiler(project_location, configuration):97 rtn_comp = ""98 all_config, all_compiler = get_all_project_config(project_location)99 for i in range(len(all_config)):100 if all_config[i] == configuration:101 rtn_comp = all_compiler[i]102 break103 return(rtn_comp)104 105 106def find_valid_xml(xml_file_name):107 error = 1108 if os.path.exists(xml_file_name): 109 try:110 dom = parse(xml_file_name)111 error = 0112 except:113 print "XML file Error"114 ...

Full Screen

Full Screen

lewis.py

Source:lewis.py Github

copy

Full Screen

1#2# jython examples for jas.3# $Id: lewis.py 2167 2008-10-03 21:48:26Z kredel $4#5import sys;6from jas import Ring7from jas import Ideal8from jas import startLog9from jas import terminate10#startLog();11# Lewis example 12# integral function coefficients13#r = Ring( "IntFunc(a1,a2,a3,b1,b2,b3,c1,c2,c3,d1,d2,d3,e1,e2,e3) (t1,t2,t3) G" );14r = Ring( "RatFunc(a1,a2,a3,b1,b2,b3,c1,c2,c3,d1,d2,d3,e1,e2,e3) (t1,t2,t3) G" );15print "Ring: " + str(r);16print;17ps = """18(19( { a1 } * t1^2 * t2^2 + { b1 } * t1^2 + { 2 c1 } * t1 * t2 + { d1 } * t2^2 + { e1 } ),20( { a2 } * t2^2 * t3^2 + { b2 } * t2^2 + { 2 c2 } * t2 * t3 + { d2 } * t3^2 + { e2 } ),21( { a3 } * t1^2 * t3^2 + { b3 } * t1^2 + { 2 c3 } * t1 * t3 + { d3 } * t3^2 + { e3 } )22) 23""";24#a1 = e2 + s2225#+ s2726#− s2527#− 2e ∗ s2 + 2e ∗ s7 − 2s2 ∗ s728f = r.ideal( ps );29print "ParamIdeal: " + str(f);30print;31sys.exit();32#startLog();33rg = f.GB();34#rg = f.GB();35print "GB:", rg;36print;37bg = rg.isGB();38print "isGB:", bg;39print;40#startLog();41terminate();...

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 pyatom 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