def autoSend(self): tasks = db.query(Task).filter_by(taf_id=None).order_by( Task.planning).all() now = datetime.datetime.utcnow() sendStatus = False for task in tasks: if task.planning <= now: message = '\n'.join([task.head, task.rpt]) aftn = AFTNMessage(message, time=task.planning) item = Taf(tt=task.tt, sign=task.head, rpt=task.rpt, raw=aftn.toJson()) db.add(item) db.flush() task.taf_id = item.id db.merge(task) db.commit() sendStatus = True logger.debug('Tasks ' + ' '.join(task.rpt for task in tasks)) if sendStatus: logger.debug('Task complete')
def save(self): item = Sigmet(tt=self.message['sign'][0:2], sign=self.message['sign'], rpt=self.message['rpt'], raw=self.aftn.toJson()) db.add(item) db.commit() logger.debug('Save ' + item.rpt) self.remind(item) self.sendSignal.emit()
def save(self): """储存远程报文数据""" last = db.query(Metar).filter_by(tt=self.tt).order_by( Metar.created.desc()).first() if last is None or last.rpt != self.message: item = Metar(tt=self.tt, rpt=self.message) db.add(item) db.commit() logger.info('Save {} {}'.format(self.tt, self.message))
def addPerson(self): """添加联系人""" name = self.personName.text() number = self.personMobile.text() if name and number: person = User(name, number) db.add(person) db.commit() self.updateContract()
def save(self): item = Task(tt=self.message['sign'][0:2], sign=self.message['sign'], rpt=self.message['rpt'], planning=self.message['planning']) db.add(item) db.commit() logger.debug('Save Task {}'.format( item.planning.strftime('%b %d %Y %H:%M:%S'))) self.sendSignal.emit()
def save(self, callback=None): """储存远程报文数据 :param callback: 储存完成后的回掉函数 """ isExist = self.isExist() if isExist is None: # 没有报文入库 # 本地正常报已发,远程数据和本地数据不一样的情况不作入库处理 # 修订报报文如果字符出了错误无法识别是否和本地是同一份,则会直接入库 local = self.local() remote = TafParser(self.message) if local and not remote.isAmended( ) and remote.primary.tokens['period']['text'] in local.rpt: return item = Taf(tt=self.tt, rpt=self.message, confirmed=self.time) db.add(item) db.commit() logger.info('Save {} {}'.format(self.tt, self.message)) if callback: callback()
def save(self): item = self.message['item'] item.raw = self.aftn.toJson() db.add(item) db.commit()