def getPushInfoList(self, device_token, push_switch): try: ret = [] if device_token != "" and push_switch != "": ret = FollowedInfo.findAll(device_token = device_token, push_switch = push_switch) elif device_token == "" and push_switch == "": ret = FollowedInfo.findAll() elif device_token != "" and push_switch == "": ret = FollowedInfo.findAll(device_token = device_token) elif device_token == "" and push_switch != "": ret = FollowedInfo.findAll(push_switch = push_switch) push_list = [] for one in ret: one_hash = {} one_hash['device_token'] = one.device_token one_hash['flight'] = "[%s][%s][%s][%s]" % (one.flight_no, one.takeoff_airport, one.arrival_airport, one.schedule_takeoff_date) one_hash['push_switch'] = one.push_switch one_hash['push_info'] = json.loads(one.push_info) push_list.append(one_hash) return push_list except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def putFollowedInfo(self, device_token, followed_list): try: for one in followed_list: ret = FollowedInfo.findOne( device_token=''.join(device_token.strip("<>").split(" ")), flight_no=one['flight_no'], takeoff_airport=one['takeoff_airport'], arrival_airport=one['arrival_airport'], schedule_takeoff_date=one['schedule_takeoff_date']) if ret is None: info = FollowedInfo() info.device_token = ''.join( device_token.strip("<>").split(" ")) info.flight_no = one['flight_no'] info.takeoff_airport = one['takeoff_airport'] info.arrival_airport = one['arrival_airport'] info.schedule_takeoff_date = one['schedule_takeoff_date'] info.add() except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getPushInfoList(self, device_token, push_switch): try: ret = [] if device_token != "" and push_switch != "": ret = FollowedInfo.findAll(device_token=device_token, push_switch=push_switch) elif device_token == "" and push_switch == "": ret = FollowedInfo.findAll() elif device_token != "" and push_switch == "": ret = FollowedInfo.findAll(device_token=device_token) elif device_token == "" and push_switch != "": ret = FollowedInfo.findAll(push_switch=push_switch) push_list = [] for one in ret: one_hash = {} one_hash['device_token'] = one.device_token one_hash['flight'] = "[%s][%s][%s][%s]" % ( one.flight_no, one.takeoff_airport, one.arrival_airport, one.schedule_takeoff_date) one_hash['push_switch'] = one.push_switch one_hash['push_info'] = json.loads(one.push_info) push_list.append(one_hash) return push_list except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def putFollowedInfo(self, device_token, followed_list): try: for one in followed_list: ret = FollowedInfo.findOne(device_token = ''.join(device_token.strip("<>").split(" ")), flight_no = one['flight_no'], takeoff_airport = one['takeoff_airport'], arrival_airport = one['arrival_airport'], schedule_takeoff_date = one['schedule_takeoff_date']) if ret is None: info = FollowedInfo() info.device_token = ''.join(device_token.strip("<>").split(" ")) info.flight_no = one['flight_no'] info.takeoff_airport = one['takeoff_airport'] info.arrival_airport = one['arrival_airport'] info.schedule_takeoff_date = one['schedule_takeoff_date'] info.add() except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getPushCandidate(self, flight): try: ret = FollowedInfo.findAll(push_switch = 'on', flight_no = flight['flight_no'], takeoff_airport = flight['takeoff_airport'], arrival_airport = flight['arrival_airport'], schedule_takeoff_date = flight['schedule_takeoff_date']) push_list = [] for one in ret: one_hash = {} one_hash['device_token'] = one.device_token one_hash['push_switch'] = one.push_switch one_hash['push_info'] = json.loads(one.push_info) push_list.append(one_hash) return push_list except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def getPushCandidate(self, flight): try: ret = FollowedInfo.findAll( push_switch='on', flight_no=flight['flight_no'], takeoff_airport=flight['takeoff_airport'], arrival_airport=flight['arrival_airport'], schedule_takeoff_date=flight['schedule_takeoff_date']) push_list = [] for one in ret: one_hash = {} one_hash['device_token'] = one.device_token one_hash['push_switch'] = one.push_switch one_hash['push_info'] = json.loads(one.push_info) push_list.append(one_hash) return push_list except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def putPushInfo(self, push_candidate, flight): try: ret = FollowedInfo.findOne(device_token = push_candidate['device_token'], flight_no = flight['flight_no'], takeoff_airport = flight['takeoff_airport'], arrival_airport = flight['arrival_airport'], schedule_takeoff_date = flight['schedule_takeoff_date']) if ret is not None: ret.push_switch = push_candidate['push_switch'] ret.push_info = json.dumps(push_candidate['push_info']) ret.add() except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None
def putPushInfo(self, push_candidate, flight): try: ret = FollowedInfo.findOne( device_token=push_candidate['device_token'], flight_no=flight['flight_no'], takeoff_airport=flight['takeoff_airport'], arrival_airport=flight['arrival_airport'], schedule_takeoff_date=flight['schedule_takeoff_date']) if ret is not None: ret.push_switch = push_candidate['push_switch'] ret.push_info = json.dumps(push_candidate['push_info']) ret.add() except: msg = traceback.format_exc() self.logger.error(msg) DBBase.Session.rollback() DBBase.Engine.dispose() return None