How to use halt method in autotest

Best Python code snippet using autotest_python

a_views.py

Source:a_views.py Github

copy

Full Screen

...414 data.append(tempo)415 return Response(data=data)416class ChartPieIncidentView(generics.ListAPIView):417 permission_classes = (AllowAny,)418 def get_calc_halt(self, queryset_halt):419 sum_halt = datetime.timedelta(0, 0, 0)420 halt_dic = {}421 for q_h in queryset_halt:422 sum_halt += q_h['resuming_hour'] - q_h['stopping_hour']423 halt_dic.update({"total_seconds": sum_halt})424 halt_obj = {}425 halt_count = HaltEvent.objects.all().count()426 i = 0427 while i < halt_count:428 halt_ref = Halt.objects.filter(halt_event_ref=i)429 sum_halt_in = datetime.timedelta(0, 0, 0)430 for h in halt_ref:431 queryset_halt_event = queryset_halt.filter(halt_ref=h)432 sum_halt_indepth = datetime.timedelta(0, 0, 0)433 for x in queryset_halt_event:434 sum_halt_in += x['resuming_hour'] - x['stopping_hour']435 sum_halt_indepth += sum_halt_in436 if sum_halt_indepth != datetime.timedelta(0, 0, 0):437 halt_obj.update(438 {str(HaltEvent.objects.get(id=i)): sum_halt_indepth})439 i += 1440 halt_dic.update(halt_obj)441 return halt_dic442 def get_calc_incident(self, queryset_incident):443 sum_incident = datetime.timedelta(0, 0, 0)444 incident_dic = {}445 for q_i in queryset_incident:446 sum_incident += q_i['resuming_hour'] - q_i['stopping_hour']447 incident_dic.update({"total_seconds": sum_incident})448 incident_obj = {}449 incident_count = IncidentEvent.objects.all().count()450 i = 0451 while i < incident_count:452 incident_spec = IncidentSpecs.objects.filter(incident_event_ref=i)453 sum_inc_in = datetime.timedelta(0, 0, 0)454 for inc in incident_spec:455 queryset_incident_ref = queryset_incident.filter(456 incident_spec_ref=inc)457 sum_inc_indepth = datetime.timedelta(0, 0, 0)458 for x in queryset_incident_ref:459 sum_inc_in = x['resuming_hour'] - x['stopping_hour']460 sum_inc_indepth += sum_inc_in461 if sum_inc_indepth != datetime.timedelta(0, 0, 0):462 incident_obj.update(463 {str(IncidentEvent.objects.get(id=i)): sum_inc_indepth})464 i += 1465 incident_dic.update(incident_obj)466 return incident_dic467 def query_filter_master(self, definer, start_date=None, end_date=None):468 if definer:469 queryset_halt = IncidentDetails.objects.filter(stopping_hour__range=(start_date, end_date),470 related="HALT").exclude(resuming_hour=None).values('stopping_hour', 'resuming_hour')471 queryset_incident = IncidentDetails.objects.filter(stopping_hour__range=(start_date, end_date),472 related="PRODUCT").exclude(resuming_hour=None).values('stopping_hour', 'resuming_hour')473 queryset_weather = IncidentDetails.objects.filter(stopping_hour__range=(start_date, end_date),474 related="WEATHER").exclude(resuming_hour=None).values('stopping_hour', 'resuming_hour')475 else:476 queryset_halt = IncidentDetails.objects.filter(477 related="HALT").exclude(resuming_hour=None).values('stopping_hour', 'resuming_hour')478 queryset_incident = IncidentDetails.objects.filter(479 related="PRODUCT").exclude(resuming_hour=None).values('stopping_hour', 'resuming_hour')480 queryset_weather = IncidentDetails.objects.filter(481 related="WEATHER").exclude(resuming_hour=None).values('stopping_hour', 'resuming_hour')482 return queryset_halt, queryset_incident, queryset_weather483 def get(self, request):484 definer = False485 if "start_date" in request.GET:486 start_date = request.GET['start_date']487 end_date = request.GET['end_date']488 definer = True489 if definer:490 queryset = IncidentDetails.objects.filter(stopping_hour__range=(491 start_date, end_date)).values('stopping_hour', 'resuming_hour')492 else:493 queryset = IncidentDetails.objects.all().values('stopping_hour', 'resuming_hour')494 data = {}495 if definer:496 queryset_halt, queryset_incident, queryset_weather = self.query_filter_master(497 definer, start_date, end_date)498 else:499 queryset_halt, queryset_incident, queryset_weather = self.query_filter_master(500 definer)501 drill = {}502 sum_weather = datetime.timedelta(0, 0, 0)503 for q_w in queryset_weather:504 sum_weather += q_w['resuming_hour'] - q_w['stopping_hour']505 halt_dic = self.get_calc_halt(queryset_halt)506 incident_dic = self.get_calc_incident(queryset_incident)507 weather_dic = self.get_calc_halt(queryset_weather)508 data.update({"halt": halt_dic})509 data.update({"incident": incident_dic})510 data.update({"weather": weather_dic})511 return Response(data=data)512class AllTimeChartView(generics.ListAPIView):513 permission_classes = (AllowAny,)514 def get_query_custom(self, related):515 data = {}516 if related == "PRODUCT":517 product = IncidentDetails.objects.filter(518 related=related).exclude(resuming_hour=None)519 for prod in product:520 incident = IncidentSpecs.objects.filter(521 id=prod.incident_spec_ref.id)...

Full Screen

Full Screen

collide.py~

Source:collide.py~ Github

copy

Full Screen

1#!/usr/bin/env python2#coding=utf-83import roslib4import rospy5from sensor_msgs.msg import Range6from std_msgs.msg import Bool7#global variables8COLLIDE_HALT_0 = False9COLLIDE_HALT_1 = False10COLLIDE_HALT_2 = False11COLLIDE_HALT_3 = False12COLLIDE_HALT_4 = False13COLLIDE_HALT_5 = False14COLLIDE_HALT_6 = False15COLLIDE_HALT_7 = False16COLLIDE_HALT_8 = False17COLLIDE_HALT_9 = False18COLLIDE_HALT_10 = False19COLLIDE_HALT_11 = False20def sonar_0CB(msg):21 global COLLIDE_HALT_022 #print ("sonar_0 call back start!")23 if msg.range == float("-inf"):24 COLLIDE_HALT_0 = True25def sonar_1CB(msg):26 global COLLIDE_HALT_127 #print ("sonar_1 call back start!")28 if msg.range == float("-inf"):29 COLLIDE_HALT_1 = True30def sonar_2CB(msg):31 global COLLIDE_HALT_232 #print ("sonar_2 call back start!")33 if msg.range == float("-inf"):34 COLLIDE_HALT_2 = True35'''36def sonar_3CB(msg):37 global COLLIDE_HALT_338 #print ("sonar_3 call back start!")39 if msg.range == float("-inf"):40 COLLIDE_HALT_3 = True41def sonar_4CB(msg): 42 global COLLIDE_HALT_443 #print ("sonar_4 call back start!")44 if msg.range == float("-inf"):45 COLLIDE_HALT_4 = True46def sonar_5CB(msg):47 global COLLIDE_HALT_548 #print ("sonar_5 call back start!")49 if msg.range == float("-inf"):50 COLLIDE_HALT_5 = True51def sonar_6CB(msg):52 global COLLIDE_HALT_653 #print ("sonar_6 call back start!")54 if msg.range == float("-inf"):55 COLLIDE_HALT_6 = True56def sonar_7CB(msg):57 global COLLIDE_HALT_758 #print ("sonar_7 call back start!")59 if msg.range == float("-inf"):60 COLLIDE_HALT_7 = True61def sonar_8CB(msg):62 global COLLIDE_HALT_863 #print ("sonar_8 call back start!")64 if msg.range == float("-inf"):65 COLLIDE_HALT_8 = True66def sonar_9CB(msg):67 global COLLIDE_HALT_968 #print ("sonar_9 call back start!")69 if msg.range == float("-inf"):70 COLLIDE_HALT_9 = True71'''72def sonar_10CB(msg):73 global COLLIDE_HALT_1074 #print ("sonar_10 call back start!")75 if msg.range == float("-inf"):76 COLLIDE_HALT_10 = True77def sonar_11CB(msg):78 global COLLIDE_HALT_1179 #print ("sonar_11 call back start!")80 if msg.range == float("-inf"):81 COLLIDE_HALT_11 = True82 83def collide():84 global COLLIDE_HALT_085 global COLLIDE_HALT_186 global COLLIDE_HALT_287 ''' 88 global COLLIDE_HALT_389 global COLLIDE_HALT_490 global COLLIDE_HALT_591 global COLLIDE_HALT_692 global COLLIDE_HALT_793 global COLLIDE_HALT_894 global COLLIDE_HALT_995 ''' 96 global COLLIDE_HALT_1097 global COLLIDE_HALT_1198 rospy.init_node('collide')99 rospy.Subscriber("/robot0/sonar_0", Range, sonar_0CB)100 rospy.Subscriber("/robot0/sonar_1", Range, sonar_1CB)101 rospy.Subscriber("/robot0/sonar_2", Range, sonar_2CB)102 '''103 rospy.Subscriber("/robot0/sonar_3", Range, sonar_3CB)104 rospy.Subscriber("/robot0/sonar_4", Range, sonar_4CB)105 rospy.Subscriber("/robot0/sonar_5", Range, sonar_5CB)106 rospy.Subscriber("/robot0/sonar_6", Range, sonar_6CB)107 rospy.Subscriber("/robot0/sonar_7", Range, sonar_7CB)108 rospy.Subscriber("/robot0/sonar_8", Range, sonar_8CB)109 rospy.Subscriber("/robot0/sonar_9", Range, sonar_9CB)110 '''111 rospy.Subscriber("/robot0/sonar_10", Range, sonar_10CB)112 rospy.Subscriber("/robot0/sonar_11", Range, sonar_11CB)113 pub = rospy.Publisher('/collide/halt', Bool, queue_size = 10)114 rate = rospy.Rate(10)#10hz115 halt_msg = Bool()116 while not rospy.is_shutdown():117 '''118 if (COLLIDE_HALT_0 or COLLIDE_HALT_1 or COLLIDE_HALT_2 or COLLIDE_HALT_3 or 119 COLLIDE_HALT_4 or COLLIDE_HALT_5 or COLLIDE_HALT_6 or COLLIDE_HALT_7 or 120 COLLIDE_HALT_8 or COLLIDE_HALT_9 or COLLIDE_HALT_10 or COLLIDE_HALT_11):121 '''122 if (COLLIDE_HALT_0 or COLLIDE_HALT_1 or COLLIDE_HALT_2 or COLLIDE_HALT_10 or COLLIDE_HALT_11):123 halt_msg.data = True124 pub.publish(halt_msg)125 print "The robot will be halted!"126 COLLIDE_HALT_0 = False127 COLLIDE_HALT_1 = False128 COLLIDE_HALT_2 = False129 COLLIDE_HALT_3 = False130 COLLIDE_HALT_4 = False131 COLLIDE_HALT_5 = False132 COLLIDE_HALT_6 = False133 COLLIDE_HALT_7 = False134 COLLIDE_HALT_8 = False135 COLLIDE_HALT_9 = False136 COLLIDE_HALT_10 = False137 COLLIDE_HALT_11 = False 138 else:139 halt_msg.data = False140 pub.publish(halt_msg)141 print "The robot won't be halted!" 142 rate.sleep()143 rospy.spin()144if __name__ == '__main__':145 try:146 collide()147 except rospy.ROSInterruptException:...

Full Screen

Full Screen

collide.py

Source:collide.py Github

copy

Full Screen

1#!/usr/bin/env python2#coding=utf-83import roslib4import rospy5from sensor_msgs.msg import Range6from std_msgs.msg import Bool7#global variables8COLLIDE_HALT_0 = False9COLLIDE_HALT_1 = False10COLLIDE_HALT_2 = False11COLLIDE_HALT_3 = False12COLLIDE_HALT_4 = False13COLLIDE_HALT_5 = False14COLLIDE_HALT_6 = False15COLLIDE_HALT_7 = False16COLLIDE_HALT_8 = False17COLLIDE_HALT_9 = False18COLLIDE_HALT_10 = False19COLLIDE_HALT_11 = False20def sonar_0CB(msg):21 global COLLIDE_HALT_022 #print ("sonar_0 call back start!")23 if msg.range == float("-inf"):24 COLLIDE_HALT_0 = True25def sonar_1CB(msg):26 global COLLIDE_HALT_127 #print ("sonar_1 call back start!")28 if msg.range == float("-inf"):29 COLLIDE_HALT_1 = True30def sonar_2CB(msg):31 global COLLIDE_HALT_232 #print ("sonar_2 call back start!")33 if msg.range == float("-inf"):34 COLLIDE_HALT_2 = True35'''36def sonar_3CB(msg):37 global COLLIDE_HALT_338 #print ("sonar_3 call back start!")39 if msg.range == float("-inf"):40 COLLIDE_HALT_3 = True41def sonar_4CB(msg): 42 global COLLIDE_HALT_443 #print ("sonar_4 call back start!")44 if msg.range == float("-inf"):45 COLLIDE_HALT_4 = True46def sonar_5CB(msg):47 global COLLIDE_HALT_548 #print ("sonar_5 call back start!")49 if msg.range == float("-inf"):50 COLLIDE_HALT_5 = True51def sonar_6CB(msg):52 global COLLIDE_HALT_653 #print ("sonar_6 call back start!")54 if msg.range == float("-inf"):55 COLLIDE_HALT_6 = True56def sonar_7CB(msg):57 global COLLIDE_HALT_758 #print ("sonar_7 call back start!")59 if msg.range == float("-inf"):60 COLLIDE_HALT_7 = True61def sonar_8CB(msg):62 global COLLIDE_HALT_863 #print ("sonar_8 call back start!")64 if msg.range == float("-inf"):65 COLLIDE_HALT_8 = True66def sonar_9CB(msg):67 global COLLIDE_HALT_968 #print ("sonar_9 call back start!")69 if msg.range == float("-inf"):70 COLLIDE_HALT_9 = True71'''72def sonar_10CB(msg):73 global COLLIDE_HALT_1074 #print ("sonar_10 call back start!")75 if msg.range == float("-inf"):76 COLLIDE_HALT_10 = True77def sonar_11CB(msg):78 global COLLIDE_HALT_1179 #print ("sonar_11 call back start!")80 if msg.range == float("-inf"):81 COLLIDE_HALT_11 = True82 83def collide():84 global COLLIDE_HALT_085 global COLLIDE_HALT_186 global COLLIDE_HALT_287 ''' 88 global COLLIDE_HALT_389 global COLLIDE_HALT_490 global COLLIDE_HALT_591 global COLLIDE_HALT_692 global COLLIDE_HALT_793 global COLLIDE_HALT_894 global COLLIDE_HALT_995 ''' 96 global COLLIDE_HALT_1097 global COLLIDE_HALT_1198 rospy.init_node('collide')99 rospy.Subscriber("/robot0/sonar_0", Range, sonar_0CB)100 rospy.Subscriber("/robot0/sonar_1", Range, sonar_1CB)101 rospy.Subscriber("/robot0/sonar_2", Range, sonar_2CB)102 '''103 rospy.Subscriber("/robot0/sonar_3", Range, sonar_3CB)104 rospy.Subscriber("/robot0/sonar_4", Range, sonar_4CB)105 rospy.Subscriber("/robot0/sonar_5", Range, sonar_5CB)106 rospy.Subscriber("/robot0/sonar_6", Range, sonar_6CB)107 rospy.Subscriber("/robot0/sonar_7", Range, sonar_7CB)108 rospy.Subscriber("/robot0/sonar_8", Range, sonar_8CB)109 rospy.Subscriber("/robot0/sonar_9", Range, sonar_9CB)110 '''111 rospy.Subscriber("/robot0/sonar_10", Range, sonar_10CB)112 rospy.Subscriber("/robot0/sonar_11", Range, sonar_11CB)113 pub = rospy.Publisher('/collide/halt', Bool, queue_size = 10)114 rate = rospy.Rate(10)#10hz115 halt_msg = Bool()116 while not rospy.is_shutdown():117 '''118 if (COLLIDE_HALT_0 or COLLIDE_HALT_1 or COLLIDE_HALT_2 or COLLIDE_HALT_3 or 119 COLLIDE_HALT_4 or COLLIDE_HALT_5 or COLLIDE_HALT_6 or COLLIDE_HALT_7 or 120 COLLIDE_HALT_8 or COLLIDE_HALT_9 or COLLIDE_HALT_10 or COLLIDE_HALT_11):121 '''122 if (COLLIDE_HALT_0 or COLLIDE_HALT_1 or COLLIDE_HALT_2 or COLLIDE_HALT_10 or COLLIDE_HALT_11):123 halt_msg.data = True124 pub.publish(halt_msg)125 print "The robot will be halted!"126 COLLIDE_HALT_0 = False127 COLLIDE_HALT_1 = False128 COLLIDE_HALT_2 = False129 COLLIDE_HALT_3 = False130 COLLIDE_HALT_4 = False131 COLLIDE_HALT_5 = False132 COLLIDE_HALT_6 = False133 COLLIDE_HALT_7 = False134 COLLIDE_HALT_8 = False135 COLLIDE_HALT_9 = False136 COLLIDE_HALT_10 = False137 COLLIDE_HALT_11 = False 138 else:139 halt_msg.data = False140 pub.publish(halt_msg)141 print "The robot won't be halted!" 142 rate.sleep()143 rospy.spin()144if __name__ == '__main__':145 try:146 collide()147 except rospy.ROSInterruptException:...

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