if (flag_dstnc_range and flag_budget_range):
                        range_methods.calclate_with_both_range(d,'distance','budget')
                elif(flag_dstnc_range):
                        range_methods.calclate_with_one_range(d,'distance')
                elif(flag_budget_range):
                        range_methods.calclate_with_one_range(d,'budget')
                elif(flag_dstnc_range==2):
                    range_car.calclate_with_one_range(d,'distance')
                elif(flag_dstnc_range==3):
                    range_flight.calclate_with_one_range(d,'distance')
                elif(flag_dstnc_range==4):
                    range_car.calclate_with_no_range(d)
                elif(flag_dstnc_range==5):
                    range_flight.calclate_with_no_range(d)
                else:
                        range_methods.calclate_with_no_range(d)
                        
                        #k=range_car.calclate_with_one_range(a[0],'distance')
                        #k=range_car.calclate_with_no_range(a[0])
                        #k=range_flight.calclate_with_no_range(a[0])
                        #k=range_flight.calclate_with_one_range(a[0],'distance')
                        
                b = datetime.datetime.now()
                print "Time of execution=",(b-a)
except IOError:
        print "USAGE:------------------------------------------\n"
        print "-P  <space> <Name of the place>"
        print "-TP <space> <Type of the place>"
        print "-TH <space> <Type of the hotel>"
예제 #2
0
            flag_dstnc_range = 3

        if (flag_dstnc_range and flag_budget_range):
            range_methods.calclate_with_both_range(d, 'distance', 'budget')
        elif (flag_dstnc_range):
            range_methods.calclate_with_one_range(d, 'distance')
        elif (flag_budget_range):
            range_methods.calclate_with_one_range(d, 'budget')
        elif (flag_dstnc_range == 2):
            range_car.calclate_with_one_range(d, 'distance')
        elif (flag_dstnc_range == 3):
            range_flight.calclate_with_one_range(d, 'distance')
        elif (flag_dstnc_range == 4):
            range_car.calclate_with_no_range(d)
        elif (flag_dstnc_range == 5):
            range_flight.calclate_with_no_range(d)
        else:
            range_methods.calclate_with_no_range(d)

            #k=range_car.calclate_with_one_range(a[0],'distance')
            #k=range_car.calclate_with_no_range(a[0])
            #k=range_flight.calclate_with_no_range(a[0])
            #k=range_flight.calclate_with_one_range(a[0],'distance')

        b = datetime.datetime.now()
        print "Time of execution=", (b - a)
except IOError:
    print "USAGE:------------------------------------------\n"
    print "-P  <space> <Name of the place>"
    print "-TP <space> <Type of the place>"
    print "-TH <space> <Type of the hotel>"
		def handle_child(childSocket, childAddr):
			start_time = time.time()
			while True:
				message = childSocket.recv(2048)
				a= pickle.loads(message)
				print a
				break
			data=''
			f = open('log.txt','a')
			f.write('\nData Received:'+str(a[0])+"\n")
			if (a[3]==0):
				if (a[1] and a[2]):
					k=range_methods1.calclate_with_both_range(a[0],'distance','budget')
					#childSocket.send(pickle.dumps(k))
					k=pickle.dumps(k)
				elif(a[1]):
					k=range_methods1.calclate_with_one_range(a[0],'distance')
					#childSocket.send(pickle.dumps(k))
					k=pickle.dumps(k)
				elif(a[2]):
					k=range_methods1.calclate_with_one_range(a[0],'budget')
					#childSocket.send(pickle.dumps(k))
					k=pickle.dumps(k)
				else:
					k=range_methods1.calclate_with_no_range(a[0])
					#childSocket.send(pickle.dumps(k))
					k=pickle.dumps(k)
			elif(a[3]==1):
				if(a[1]):
					k=range_flight.calclate_with_one_range(a[0],'distance')
					#childSocket.send(pickle.dumps(k))
					k=pickle.dumps(k)
				else:
					k=range_flight.calclate_with_no_range(a[0])
					#childSocket.send(pickle.dumps(k))
					k=pickle.dumps(k)
			else:
				if(a[1]):
					k=range_car.calclate_with_one_range(a[0],'distance')
					#childSocket.send(pickle.dumps(k))
					k=pickle.dumps(k)
				else:
					k=range_car.calclate_with_no_range(a[0])
					#childSocket.send(pickle.dumps(k))	
					k=pickle.dumps(k)
			i=0
			j=1024
			s=0
			while(s>0):
				data=k[i:j]
				childSocket.send(data)
				i=j
				j=j+1024
				s=len(k)-j
				
			else:
				data=k[i:len(k)]
				childSocket.send(data)
			#for s in range(0,1024):
			#	data=data+k[s]
			#childSocket.send(data)
			childSocket.send('EOF')
			childSocket.close()
			f.write("Child thread completed\n")
			f.write("Time of Execution of child thread="+str(time.time() - start_time)+" Seconds\n")
			f.close()