How to use home_interface method in Airtest

Best Python code snippet using Airtest

Config.py

Source:Config.py Github

copy

Full Screen

1#import python Module2import csv3import time4from matplotlib.animation import FuncAnimation5import sys6#import Dolmen Module7import Windows8import Widgets9import Graph10import Dolmen11import Sensors12#Dolmen variables13CONFIG_TXT=""14CSV=""15THEME="normal"16LOG_TYPE=""17PATH = ""18NAME = ""19UPDATE_DELAY = None20LOG_FILE = ""21SAVE_REPORT_FOLDER = ""22ROCKET_NAME=""23#init time session24TIME_FOLDER=Dolmen.currentTime()25#init saving folder26NAME_SAVE_FOLDER = Dolmen.currentDate() + TIME_FOLDER27#Log file28Log=None29#figure name file whe, rapport generation30NAME_SAVE_FIGURE = ""31LOGO_IMAGE="DolmenV3.png"32# name logo in About windows33NAME_ABOUT_IMAGE = "logos.png"34#Windows text and fig color35colorFont = ""36colorText = ""37colorSelect = ""38xColor = ""39yColor = ""40axeLabelColor = ""41gridColor = ""42facecolor2d = ""43facecolor3d = ""44graphLegend = ""45xFig_size=None46yFig_size=None47police="Times"48#button of fire interface49start_button=None50stop_button=None51#current mode online or offline52currentMode=None53#create Dolmen color profil54#you can create other profil if you want55def theme(Theme):56 global colorFont, colorText, colorSelect,xColor,yColor,axeLabelColor,gridColor,facecolor2d,facecolor3d,graphLegend57 if Theme == "normal":58 colorFont = "white"59 colorText = "black"60 colorSelect = "grey"61 xColor = "black"62 yColor = "black"63 axeLabelColor = "black"64 gridColor = "black"65 facecolor2d = "white"66 facecolor3d = "white"67 graphLegend = "white"68 return True69 if Theme == "dark":70 colorFont = "black"71 colorText = "white"72 colorSelect = "grey"73 xColor = "white"74 yColor = "white"75 axeLabelColor = "white"76 gridColor = "white"77 facecolor2d = "grey"78 facecolor3d = "grey"79 graphLegend = "black"80 return True81 else :82 return False83 84# Figure and Graph variable85figure=None86myFigure=None87sensors_list_set_time=[]88sensors=[]89def createGraph():# function to create and intit graph90 global sensors_list_set_time, sensors, figure, myFigure91 92 #My figure creationm93 # for row and colum in figure 0->value94 #you can change Figure's parameters if you want => see Graph.py for more details95 figure=Graph.Graph(xFig_size,yFig_size,3,4,[1,1,1,1],[3,2,2],colorText,xColor,yColor,axeLabelColor,gridColor,colorFont)96 myFigure = figure.figure97 #you can create another graph if you want here => see Graph.py for more details98 f1= Graph.GraphPlot(figure,figure.grid[1, 0:3],"Temperature","time","Temperature (°c)",[],[-100, 100],facecolor2d,graphLegend,"left",False)99 f2= Graph.GraphPlot(figure,figure.grid[2, 0:3],"Pression","time","Pression (Pascal)",[],[0,500000],facecolor2d,graphLegend,"left",False)100 f3= Graph.Graph3d(figure,figure.grid[0, 0],"Acceleration","x (ms-2)","y (ms-2)","z (ms-2)",[-5,5],[-5,5],[-5,5],True,'-',facecolor3d,graphLegend)101 f4= Graph.Graph3d(figure,figure.grid[0, 1],"Gyroscope","x (ms-2)","y (ms-2)","z (ms-2)",[-10,10],[-10,10],[-10,10],True,'-',facecolor3d,graphLegend)102 f5= Graph.GraphPlot(figure,figure.grid[0, 2],"GPS","x","y",[-100,100],[-100,100],facecolor2d,graphLegend,"right",True)103 f6=Graph.GraphPlot(figure,figure.grid[0:3, 3],"Altitude","time","Altitude (m)",[],[],facecolor2d,graphLegend,"right",False)104 #sensors Creation => see Sensors.py for more details105 #you can create another sensors if you want here106 temp1=Sensors.Sensors("temperature","","temperature (degres celcius)","",4,0,"2d_time",f1,"Sensor 1","blue")107 temp2=Sensors.Sensors("temperature","","temperature (degres celcius)","",5,1,"2d_time",f1,"Sensor 2","red")108 pressure1=Sensors.Sensors("pressure","","pressure (Pa)","",6,0,"2d_time",f2,"Sensor 1","red")109 pressure2=Sensors.Sensors("pressure","","pressure (Pa)","",7,1,"2d_time",f2,"Sensor 2","green")110 altitude=Sensors.Sensors("altitude","","altitude (m)","",8,0,"2d_time",f6,"","red")111 acc = Sensors.Sensors("accelerometer","accelerometer_X (ms-2)","accelerometer_Y (ms-2)","accelerometer_Z (ms-2)",2,0,"3d",f3,'o','black')112 gyro = Sensors.Sensors("gyroscope","gyroscope_X (ms-2)","gyroscope_Y (ms-2)","gyroscope_Z (ms-2)",3,0,"3d",f4,'o','black')113 gps = Sensors.Sensors("GPS","gps_latDeg","gps_lonDeg","",1,0,"gps",f5,"","blue")114 #create sensors list115 sensors_list_set_time=[f1,f2,f6]#place here all time graph created (to update the time)116 sensors = [temp1,temp2,pressure1,pressure2,altitude,gps,acc,gyro]#place here all sensors created117 Dolmen.initFigure()118#Home windows119def home_Function(last_windows):120 global xFig_size,yFig_size121 # set theme color122 if theme(THEME)==False:123 Log.InfoSaveLog("warning","no theme color given make default theme")124 print("no theme color given make default theme")125 theme("normal")126 127 #destroy the last windows (if there is one)128 if(last_windows!=None):129 last_windows.windows.destroy()130 131 Log.InfoSaveLog("info",'Entering in home mode')132 #Creating home_interface windows133 home_interface = Windows.Windows("Welcome",colorFont,400,550,Windows.exit,6,3)134 #set Figure size135 xFig_size=home_interface.windows.winfo_screenwidth()/100136 yFig_size=0.75*home_interface.windows.winfo_screenheight()/100137 #Adding widgets 138 Widgets.TextToPrint(home_interface,"DOLMEN Alpha version",colorFont,colorText,1,1,25,"italic",police,1,3) 139 fire_mode_button = Widgets.ButtonDisplay(home_interface,"Fire Mode",colorFont,colorText,colorSelect,lambda: choose_fire_mode(home_interface),10,2,2,1,10,"normal",police,1,1)140 about_button = Widgets.ButtonDisplay(home_interface,"About Dolmen",colorFont,colorText,colorSelect,lambda: about_Function(home_interface),15,2,2,2,10,"normal",police,1,1)141 admin_mode_button = Widgets.ButtonDisplay(home_interface,"Administrator Mode",colorFont,colorText,colorSelect,lambda: admin_Function(home_interface),15,2,2,3,10,"normal",police,1,1)142 Widgets.TextToPrint(home_interface,"",colorFont,colorText,3,1,8,"italic",police,1,3) 143 quit_dolmen_button = Widgets.ButtonDisplay(home_interface,"Quit Dolmen",colorFont,colorText,colorSelect,Windows.exit,10,2,4,2,10,"normal",police,1,1)144 Widgets.TextToPrint(home_interface,"",colorFont,colorText,5,1,8,"italic",police,1,3) 145 Widgets.addImage(home_interface,LOGO_IMAGE,colorFont,6,1,1,3,400,400)146 home_interface.windows.mainloop()147 #home_interface.destroy()148def admin_Function(last_windows):149 #destroy the last windows (if there is one)150 if(last_windows!=None):151 last_windows.windows.destroy()152 Log.InfoSaveLog("info",'Entering in admin mode')153 #Creating admin_mode_interface windows154 admin_mode_interface = Windows.Windows("Administrator Mode",colorFont,650,150,lambda: home_Function(admin_mode_interface),1,3)155 #Adding widgets 156 graph_management_button = Widgets.ButtonDisplay(admin_mode_interface,"Graph management",colorFont,colorText,colorSelect,None,25,10,1,1,10,"normal",police,1,1)157 windows_management_button = Widgets.ButtonDisplay(admin_mode_interface,"Windows management",colorFont,colorText,colorSelect,None,25,10,1,2,10,"normal",police,1,1)158 sensors_management_button = Widgets.ButtonDisplay(admin_mode_interface,"Sensor management",colorFont,colorText,colorSelect,lambda: sensors_management_Function(admin_mode_interface),25,10,1,3,10,"normal",police,1,1)159 160 admin_mode_interface.windows.mainloop()161 #admin_mode_interface.destroy()162def sensors_management_Function(last_windows):163 #destroy the last windows (if there is one)164 if(last_windows!=None):165 last_windows.windows.destroy()166 Log.InfoSaveLog("info",'Entering in sensor management')167 #Creating sensors_management_interface windows168 sensors_management_interface = Windows.Windows("Sensors management mode",colorFont,700,250,lambda: admin_Function(sensors_management_interface),1,3)169 170 #Adding widgets 171 sensors_management_add_button = Widgets.ButtonDisplay(sensors_management_interface,"Add new sensor",colorFont,colorText,colorSelect,lambda: add_sensor(sensors_management_interface),25,10,1,1,10,"normal",police,1,1)172 sensors_management_modify_button = Widgets.ButtonDisplay(sensors_management_interface,"Modify sensor",colorFont,colorText,colorSelect,None,25,10,1,2,10,"normal",police,1,1)173 sensors_management_variable_button = Widgets.ButtonDisplay(sensors_management_interface,"Add sensor variable",colorFont,colorText,colorSelect,None,25,10,1,3,10,"normal",police,1,1)174 sensors_management_interface.windows.mainloop()175def add_sensor(last_windows):176 177 #destroy the last windows (if there is one)178 if(last_windows!=None):179 last_windows.windows.destroy()180 181 Log.InfoSaveLog("info",'Entering in add sensor mode')182 183 #Create the add_sensor_interface windows184 add_sensor_interface = Windows.Windows("Add Sensors",colorFont,220,100,lambda:sensors_management_Function(add_sensor_interface),3,3)185 186 #Enter sensor Name187 sensor_add_name = Widgets.TextInput(add_sensor_interface,"Sensor name : ",colorFont,colorText,1,2,2,2,"",10,"normal",police,1,1)188 189 #Saving Button190 add_sensor_save_button = Widgets.ButtonDisplay(add_sensor_interface,"Save",colorFont,colorText,colorSelect,lambda :Dolmen.add_sensor_save_Function(add_sensor_interface,sensor_add_name),20,3,3,2,10,"normal",police,1,1)191 192 #update the add_sensor_interface windows193 add_sensor_interface.windows.update()194 add_sensor_interface.windows.mainloop()195 #add_sensor_interface.destroy()196def about_Function(last_windows):197 #destroy the last windows (if there is one)198 if(last_windows!=None):199 last_windows.windows.destroy()200 201 Log.InfoSaveLog("info",'Entering in about team')202 203 #Creating about_interface windows204 about_interface = Windows.Windows("About Dolmen : ",colorFont,900,600,lambda:home_Function(about_interface),7,1)205 #Adding widgets 206 Widgets.TextToPrint(about_interface,"Timothée Allègre (t7allegr@enib.fr):",colorFont,colorText,1,1,10,"italic",police,1,1)207 Widgets.TextToPrint(about_interface,"""208 En tant que membre du BDI depuis quelques années, et suivant le projet FUSEX depuis ses débuts, j’ai souhaité m'investir 209 dans ce projet autant que possible. J’ai rapidement tenté de formuler les besoins auxquels une telle interface pourrait 210 répondre, et ai tenté de mettre ma connaissance du projet FUSEX au profit du projet DOLMEN. Je souhaite que ce projet 211 puisse servir non seulement à notre équipe de cette année, mais aussi à d’autres équipes dans le futur, et qu’il puisse 212 vivre quelques années supplémentaires.213 """,colorFont,colorText,2,1,10,"normal",police,1,1)214 Widgets.TextToPrint(about_interface,"Nathan De Saint Just (n6desain@enib.fr):",colorFont,colorText,3,1,10,"italic",police,1,1)215 Widgets.TextToPrint(about_interface,"""216 En tant que président du BDI depuis 2 ans et fondateur du Pôle KSP au sein de celui-ci avec Evan Roué, Il me tenait à coeur de 217 participer à ce projet que je vois ce développer depuis sa création. Avec grand espoir que tout soit opérationnelle pour la C’space 218 2020 avec le tire de la fusée avec le projet DOLMEN en base sol. Montrer qu’il marche nous permettra de le réutiliser et de la219 partager à tous les autres associations spatiales.220 """,colorFont,colorText,4,1,10,"normal",police,1,1)221 Widgets.TextToPrint(about_interface,"Axel Nougier (a7nougie@enib.fr):",colorFont,colorText,5,1,10,"italic",police,1,1)222 Widgets.TextToPrint(about_interface,"""223 En tant que membre du BDI depuis quelques années, et suivant le projet Enigma Robotics, j’ai souhaité mettre mes connaissances à 224 profit dans le projet Dolmen afin de découvrir le Pôle KSP. Je souhaite que Dolmen soit un logiciel, simple, mais à la fois 225 robuste et modulable afin qu’il puisse être appliqué à d’autres projets et pouvoir être modifié selon d’autres besoin et être226 amélioré par d’autres personnes.227 """,colorFont,colorText,6,1,10,"normal",police,1,1)228 229 230 Widgets.addImage(about_interface,NAME_ABOUT_IMAGE,colorFont,7,1,1,1,900,200)231 about_interface.windows.mainloop()232 #about_interface.destroy()233#Help windows in choose_fire_mode windows234def help_fire_mode():235 help_fire_mode = Windows.messageShowinfo("Witch Fire mode you can use ?",236 """237- The Online Fire mode must be use with an emitter to view data in real time 238- The Offline Fire mode must be use when you don't have an emitter or if you want to simulate a rocket launch239WARNING : ONLINE MODE IS NOT TESTED, PLEASE CONSIDER THIS AS A NON WORKING MODE240 """241 )242#choose_fire_mode windows243def choose_fire_mode(last_windows):244 #destroy the last windows (if there is one)245 if(last_windows!=None):246 last_windows.windows.destroy()247 Log.InfoSaveLog("info",'Entering in choose fire mode')248 #reset and init graph249 createGraph()250 #disable c++ decoding251 config=open(CONFIG_TXT, "w")252 config.write("false")253 config.close()254 255 #Creating fire_mode_interface windows256 fire_mode_interface = Windows.Windows("Fire Mode Choose",colorFont,300,100,lambda:home_Function(fire_mode_interface),2,3)257 #Adding widgets 258 Widgets.TextToPrint(fire_mode_interface,"Please choose a fire mode :",colorFont,colorText,1,1,10,"normal",police,1,3)259 online_button = Widgets.ButtonDisplay(fire_mode_interface,"Online Mode",colorFont,colorText,colorSelect,lambda:fire_Function_online(fire_mode_interface),10,5,2,1,10,"normal",police,1,1)260 offline_button = Widgets.ButtonDisplay(fire_mode_interface,"Offline Mode",colorFont,colorText,colorSelect,lambda:fire_Function_offline(fire_mode_interface),10,5,2,3,10,"normal",police,1,1)261 help_fire_button = Widgets.ButtonDisplay(fire_mode_interface,"Help",colorFont,colorText,colorSelect,help_fire_mode ,10,5,2,2,10,"normal",police,1,1)262 263 fire_mode_interface.windows.mainloop()264def fire_Function_offline(last_windows): 265 global start_button, stop_button,currentMode266 #destroy the last windows (if there is one)267 if(last_windows!=None):268 last_windows.windows.destroy()269 Log.InfoSaveLog("info",'Entering in offline mode')270 currentMode="offline" #set current mode271 if Windows.askopenfilename(figure,PATH):# if frame is imported272 #Creating fire__offline_interface windows273 fire__offline_interface = Windows.Windows("Fire Offline Mode",colorFont,0,0,lambda:choose_fire_mode(fire__offline_interface),3,6) 274 #Adding graph in windows 275 figure.addToWindows(fire__offline_interface,1,1,6,2,3,6)276 277 start_button = None278 stop_button = None279 280 #Adding widgets 281 start_button = Widgets.ButtonDisplay(fire__offline_interface,"Start",colorFont,colorText,colorSelect,lambda:Dolmen.state_set_communication(start_button,stop_button,True,currentMode,figure.file,True),10,10,3,1,10,"normal",police,1,1)282 stop_button = Widgets.ButtonDisplay(fire__offline_interface,"Stop",colorFont,colorText,colorSelect,lambda:Dolmen.state_set_communication(start_button,stop_button,False,currentMode,figure.file,True),10,10,3,3,10,"normal",police,1,1)283 rapport_button = Widgets.ButtonDisplay(fire__offline_interface,"Generate Rapport",colorFont,colorText,colorSelect,Dolmen.report_Function,15,5,3,2,10,"normal",police,1,1)284 Widgets.DisplayTime(fire__offline_interface,colorFont,colorText,3,4,10,"normal",police,1,1)285 Widgets.TextToPrint(fire__offline_interface,"Rocket Name :\n" + str(ROCKET_NAME),colorFont,colorText,3,5,10,"normal",police,1,1)286 287 #initial conditions :288 #enable start button289 start_button.enable()290 291 #disable stop button292 stop_button.disable()293 #decoding data and updating graph 294 ani = FuncAnimation(myFigure, Dolmen.updateOffline,fargs = (start_button,stop_button), frames=200, interval=UPDATE_DELAY, repeat=True) #or ani = FuncAnimation(plt.gcf(), update, 200)295 296 fire__offline_interface.windows.mainloop()297 #fire__offline_interface.destroy()298 else :299 Log.InfoSaveLog("warning",'No file chosen')300 Windows.messageShowwarning("Open Filename", "Warning, you must choose a file ")301 choose_fire_mode(None)302#ONLINE MODE IS NOT TESTED, PLEASE CONSIDER THIS AS A NO WORKING MODE303def fire_Function_online(last_windows):304 global start_button, stop_button,currentMode305 Windows.messageShowinfo("Developpment Info", "ONLINE MODE IS NOT TESTED, PLEASE CONSIDER THIS AS A NO WORKING MODE")306 307 #destroy the last windows (if there is one)308 if(last_windows!=None):309 last_windows.windows.destroy()310 311 currentMode="online" #set current mode 312 # add CSV file to figure313 figure.file = NAME314 315 Log.InfoSaveLog("info",'Entering in online mode')316 #Creating fire__online_interface windows 317 fire__online_interface = Windows.Windows("Fire Online Mode",colorFont,0,0,lambda:choose_fire_mode(fire__online_interface),4,9) 318 319 #Adding graph in windows 320 figure.addToWindows(fire__online_interface,1,1,6,2,4,6) 321 start_button = None322 stop_button = None323 #Adding widgets 324 start_button = Widgets.ButtonDisplay(fire__online_interface,"Start",colorFont,colorText,colorSelect,lambda:Dolmen.state_set_communication(start_button,stop_button,True,currentMode,figure.file,True),10,10,3,1,10,"normal",police,1,1)325 stop_button = Widgets.ButtonDisplay(fire__online_interface,"Stop",colorFont,colorText,colorSelect,lambda:Dolmen.state_set_communication(start_button,stop_button,False,currentMode,figure.file,True),10,10,3,3,10,"normal",police,1,1)326 rapport_button = Widgets.ButtonDisplay(fire__online_interface,"Generate Rapport",colorFont,colorText,colorSelect,Dolmen.report_Function,15,5,3,2,10,"normal",police,1,1)327 Widgets.DisplayTime(fire__online_interface,colorFont,colorText,3,4,10,"normal",police,1,1)328 Widgets.TextToPrint(fire__online_interface,"Rocket Name :\n" + str(ROCKET_NAME),colorFont,colorText,3,5,10,"normal",police,1,1)329 Widgets.TextToPrint(fire__online_interface,"Signal :" + "\n",colorFont,colorText,3,6,10,"normal",police,1,1)330 #initial conditions : 331 #enable start button332 start_button.enable()333 #disable stop button334 stop_button.disable() 335 #decoding data and updating graph 336 ani = FuncAnimation(myFigure, Dolmen.updateOnline,fargs = (start_button,stop_button), frames=200, interval=UPDATE_DELAY, repeat=True) #or ani = FuncAnimation(plt.gcf(), update, 200) 337 338 fire__online_interface.windows.mainloop()339 #fire__offline_interface.destroy()...

Full Screen

Full Screen

home_interface.py

Source:home_interface.py Github

copy

Full Screen

1import library.commands.global_interface.clear as clear2import library.commands.global_interface.quit as quit3import library.commands.global_interface.python as python4import library.commands.global_interface.local as local5import library.commands.global_interface.help as help6import library.commands.home_interface.regen as regen7import library.commands.home_interface.add as add8import library.commands.home_interface.show as show9import library.commands.home_interface.rm as rm10import library.commands.home_interface.reset as reset11import library.interfaces.listener_interface as listener_interface12import library.interfaces.scout_interface as scout_interface13import library.interfaces.generator_interface as generator_interface14import library.modules.config as config15try:16 import readline17except ImportError:18 import gnureadline as readline19config.main()20home_commands = ['clear', 'help', 'local', 'python', 'quit', 'add', 'regen', 'reset', 'rm', 'show', 'generator',21 'listeners',22 'scouts']23def home_completer(text, state):24 for cmd in home_commands:25 if cmd.startswith(text):26 if not state:27 return cmd28 else:29 state -= 130def main():31 readline.parse_and_bind("tab: complete")32 readline.set_completer(home_completer)33 while True:34 try:35 prompt = input('\x1b[1m\x1b[37mPyIris (Home) > \x1b[0m').strip()36 command = prompt.split(' ', 1)[0].lower()37 if command == 'add':38 add.main(prompt)39 elif command == 'clear':40 clear.main()41 elif command == 'generator':42 print(config.inf + 'Switching...')43 generator_interface.main()44 readline.parse_and_bind("tab: complete")45 readline.set_completer(home_completer)46 elif command in ('?', 'help'):47 help.main('home', prompt)48 elif command == 'listeners':49 print(config.inf + 'Switching...')50 listener_interface.main()51 readline.parse_and_bind("tab: complete")52 readline.set_completer(home_completer)53 elif command in ('!', 'local'):54 local.main(prompt)55 elif command == 'python':56 python.main()57 elif command == 'quit':58 quit.main()59 elif command == 'regen':60 regen.main()61 elif command == 'reset':62 reset.main(prompt)63 elif command == 'rm':64 rm.main(prompt)65 elif command == 'scouts':66 print(config.inf + 'Switching...')67 scout_interface.main()68 readline.parse_and_bind("tab: complete")69 readline.set_completer(home_completer)70 elif command == 'show':71 show.main(prompt)72 elif not command:73 pass74 else:75 print(config.neg + 'Invalid command, run "help" for help menu')76 except KeyboardInterrupt:...

Full Screen

Full Screen

PyIris.py

Source:PyIris.py Github

copy

Full Screen

1# Version 1.1.62import library.modules.bootstrap as bootstrap3import time4import logging5if __name__ == '__main__':6 try:7 start = bootstrap.main()8 if start:9 import library.interfaces.home_interface as home_interface10 import library.commands.global_interface.clear as clear11 clear.main()12 home_interface.main()13 except EOFError:14 try:15 time.sleep(2)16 except KeyboardInterrupt:17 print('[!]User aborted bootstrap, requesting shutdown...')18 quit()19 except KeyboardInterrupt:20 print('[!]User aborted bootstrap, requesting shutdown...')21 quit()22 except Exception as e:...

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