Пример #1
0
 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
Пример #2
0
    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
Пример #3
0
 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
Пример #4
0
    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
Пример #5
0
 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
Пример #6
0
 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
Пример #7
0
    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
Пример #8
0
    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