def checkRouteInfo(self): try: ret = FlightFixInfo.getAllRoute() route_info = [] for one in ret: route = {} route["takeoff_airport"] = one.takeoff_airport route["arrival_airport"] = one.arrival_airport count = len( FlightFixInfo.find(takeoff_airport=one.takeoff_airport, arrival_airport=one.arrival_airport)) if count == 0: route["flight_count"] = "ZERO" else: route["flight_count"] = count route_info.append(route) return route_info except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def checkRouteInfo(self): try: ret = FlightFixInfo.getAllRoute() route_info = [] for one in ret: route = {} route["takeoff_airport"] = one.takeoff_airport route["arrival_airport"] = one.arrival_airport count = len(FlightFixInfo.find(takeoff_airport = one.takeoff_airport, arrival_airport = one.arrival_airport)) if count == 0: route["flight_count"] = "ZERO" else: route["flight_count"] = count route_info.append(route) return route_info except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getFlightFixInfoByRoute(self, takeoff_airport, arrival_airport, company): try: ret = [] if company == 'all': ret = FlightFixInfo.find(takeoff_airport = takeoff_airport, arrival_airport = arrival_airport) else: ret = FlightFixInfo.find(takeoff_airport = takeoff_airport, arrival_airport = arrival_airport, company = company) return self.__convertFixInfo(ret) except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getFlightFixInfoByRoute(self, takeoff_airport, arrival_airport, company): try: ret = [] if company == 'all': ret = FlightFixInfo.find(takeoff_airport=takeoff_airport, arrival_airport=arrival_airport) else: ret = FlightFixInfo.find(takeoff_airport=takeoff_airport, arrival_airport=arrival_airport, company=company) return self.__convertFixInfo(ret) except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getFlightFixInfoByFlightNO(self, flight_no): try: ret = FlightFixInfo.findLike(flight_no) return self.__convertFixInfo(ret) except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getFlightFixInfoByUniq(self, flight_no, takeoff_airport, arrival_airport): try: ret = FlightFixInfo.find(flight_no = flight_no, takeoff_airport = takeoff_airport, arrival_airport = arrival_airport) return self.__convertFixInfo(ret) except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def deleteRoute(self, takeoff_airport, arrival_airport): try: self.logger.info("delete route %s %s" % (takeoff_airport, arrival_airport)) ret = FlightFixInfo.findDelete(takeoff_airport = takeoff_airport, arrival_airport = arrival_airport) self.logger.info("%s rows is deleted" % (str(ret))) return 0 except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getFlightFixInfoByUniq(self, flight_no, takeoff_airport, arrival_airport): try: ret = FlightFixInfo.find(flight_no=flight_no, takeoff_airport=takeoff_airport, arrival_airport=arrival_airport) return self.__convertFixInfo(ret) except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getRandomFlightList(self, cur_time): try: ret = FlightFixInfo.getNowFlightNO(cur_time) flight_list = [] for one in ret: flight_list.append(one[0]) return flight_list except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def deleteRoute(self, takeoff_airport, arrival_airport): try: self.logger.info("delete route %s %s" % (takeoff_airport, arrival_airport)) ret = FlightFixInfo.findDelete(takeoff_airport=takeoff_airport, arrival_airport=arrival_airport) self.logger.info("%s rows is deleted" % (str(ret))) return 0 except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getOverdayRoute(self, cur_date): try: ret = FlightFixInfo.getOverdayRoute(cur_date) route_list = [] for one in ret: one_hash = {} one_hash['takeoff_airport'] = one.takeoff_airport one_hash['arrival_airport'] = one.arrival_airport route_list.append(one_hash) return route_list except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getFlightList(self): try: ret = FlightFixInfo.find() flight_info_list = [] for one in ret: one_hash = {} one_hash['flight_no'] = one.flight_no one_hash['takeoff_airport'] = one.takeoff_airport one_hash['arrival_airport'] = one.arrival_airport flight_info_list.append(one_hash) return flight_info_list except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def putFlightFixInfo(self, flight_info_list): try: for one in flight_info_list: flight_info = FlightFixInfo() flight_info.flight_no = one['flight_no'] flight_info.company = one['company'] flight_info.schedule_takeoff_time = one[ 'schedule_takeoff_time'] flight_info.schedule_arrival_time = one[ 'schedule_arrival_time'] flight_info.takeoff_airport = self.getAirportShort( one['takeoff_airport'].encode("utf-8"), 'zh') flight_info.takeoff_city = self.getAirportCity( flight_info.takeoff_airport) flight_info.takeoff_airport_building = one[ 'takeoff_airport_building'] flight_info.arrival_airport = self.getAirportShort( one['arrival_airport'].encode("utf-8"), 'zh') flight_info.arrival_city = self.getAirportCity( flight_info.arrival_airport) flight_info.arrival_airport_building = one[ 'arrival_airport_building'] flight_info.plane_model = one['plane_model'].encode("utf-8") flight_info.mileage = one['mileage'] flight_info.stopover = one['stopover'] flight_info.schedule = json.dumps(one['schedule']) flight_info.valid_date_from = one['valid_date_from'] flight_info.valid_date_to = one['valid_date_to'] flight_info.add() self.logger.info("%s rows is added" % (str(len(flight_info_list)))) except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def putFlightFixInfo(self, flight_info_list): try: for one in flight_info_list: flight_info = FlightFixInfo() flight_info.flight_no = one['flight_no'] flight_info.company = one['company'] flight_info.schedule_takeoff_time = one['schedule_takeoff_time'] flight_info.schedule_arrival_time = one['schedule_arrival_time'] flight_info.takeoff_airport = self.getAirportShort(one['takeoff_airport'].encode("utf-8"), 'zh') flight_info.takeoff_city = self.getAirportCity(flight_info.takeoff_airport) flight_info.takeoff_airport_building = one['takeoff_airport_building'] flight_info.arrival_airport = self.getAirportShort(one['arrival_airport'].encode("utf-8"), 'zh') flight_info.arrival_city = self.getAirportCity(flight_info.arrival_airport) flight_info.arrival_airport_building = one['arrival_airport_building'] flight_info.plane_model = one['plane_model'].encode("utf-8") flight_info.mileage = one['mileage'] flight_info.stopover = one['stopover'] flight_info.schedule = json.dumps(one['schedule']) flight_info.valid_date_from = one['valid_date_from'] flight_info.valid_date_to = one['valid_date_to'] flight_info.add() self.logger.info("%s rows is added" % (str(len(flight_info_list)))) except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None