def putAirportInfo(self, flight_info_list): try: for one in flight_info_list: ret = AirportInfo.find( airport_short=one['takeoff_airport_short']) if len(ret) == 0: airport_info = AirportInfo() airport_info.airport_short = one['takeoff_airport_short'] airport_info.airport_zh = one['takeoff_airport'] airport_info.add() ret = AirportInfo.find( airport_short=one['arrival_airport_short']) if len(ret) == 0: airport_info = AirportInfo() airport_info.airport_short = one['arrival_airport_short'] airport_info.airport_zh = one['arrival_airport'] airport_info.add() except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def putAirportInfo(self, flight_info_list): try: for one in flight_info_list: ret = AirportInfo.find(airport_short = one['takeoff_airport_short']) if len(ret) == 0: airport_info = AirportInfo() airport_info.airport_short = one['takeoff_airport_short'] airport_info.airport_zh = one['takeoff_airport'] airport_info.add() ret = AirportInfo.find(airport_short = one['arrival_airport_short']) if len(ret) == 0: airport_info = AirportInfo() airport_info.airport_short = one['arrival_airport_short'] airport_info.airport_zh = one['arrival_airport'] airport_info.add() except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getAirportCity(self, short): try: ret = AirportInfo.find(airport_short = short) if len(ret) == 1: return ret[0].city else: return None except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getAirportCity(self, short): try: ret = AirportInfo.find(airport_short=short) if len(ret) == 1: return ret[0].city else: return None except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getAirportName(self, short, lang): try: ret = AirportInfo.find(airport_short = short) if len(ret) == 1: if lang == 'zh': return ret[0].airport_zh else: return "" except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getAirportName(self, short, lang): try: ret = AirportInfo.find(airport_short=short) if len(ret) == 1: if lang == 'zh': return ret[0].airport_zh else: return "" except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getAirportList(self, lang): try: ret = AirportInfo.find() airport_info_list = [] for one in ret: one_hash = {} one_hash['short'] = one.airport_short if lang == 'zh': one_hash['full'] = one.airport_zh one_hash['city'] = self.getCityName(one.city, lang) airport_info_list.append(one_hash) return airport_info_list except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None