def adjustFlightFixInfo(self): try: city_code_file = open("../../test/citycode", "r") hash = {} #@ReservedAssignment for line in city_code_file: line = line.strip() item = line.split('=') if len(item) == 2: hash[item[1].decode("utf-8")] = item[0] ret = CityInfo.find() for one in ret: if one.city_zh in hash: one.city_code = hash[one.city_zh] one.add() ''' count = 0 for one in ret: count += 1 print count index = one.takeoff_airport.find('A') if index != -1: one.takeoff_airport = one.takeoff_airport[:index] one.takeoff_airport_building = 'A' index = one.takeoff_airport.find('B') if index != -1: one.takeoff_airport = one.takeoff_airport[:index] one.takeoff_airport_building = 'B' index = one.arrival_airport.find('A') if index != -1: one.arrival_airport = one.arrival_airport[:index] one.arrival_airport_building = 'A' index = one.arrival_airport.find('B') if index != -1: one.arrival_airport = one.arrival_airport[:index] one.arrival_airport_building = 'B' one.add() ''' except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getCityCode(self, short): try: ret = CityInfo.find(city_short = short) if len(ret) == 1: return ret[0].city_code else: return None except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getCityCode(self, short): try: ret = CityInfo.find(city_short=short) if len(ret) == 1: return ret[0].city_code else: return None except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getCityName(self, short, lang): try: ret = CityInfo.find(city_short = short) if len(ret) == 1: if lang == 'zh': return ret[0].city_zh else: return "" except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getCityList(self, lang): try: ret = CityInfo.find() city_list = [] for one in ret: city_list.append(one.city_zh) return city_list except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getCityName(self, short, lang): try: ret = CityInfo.find(city_short=short) if len(ret) == 1: if lang == 'zh': return ret[0].city_zh else: return "" except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None