Exemple #1
0
    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
Exemple #2
0
 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
Exemple #3
0
 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
Exemple #4
0
    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
Exemple #5
0
 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
Exemple #6
0
    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
Exemple #7
0
 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
Exemple #8
0
    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