def loadOrNewLink(self, url, documento): link = ls.findByUrl(url) if link is None: link = Link() link.url = url host = hs.findByUrl(url) link.host = host link.host_id = host.id link.ultimaColeta = datetime.datetime.now() link = ls.save(link) else: link.ultimaColeta = datetime.datetime.now() link = ls.update(link) return link
def atualizaUltimaColetaSementes(): if request.get_json() is None: abort(http.HTTPStatus.PRECONDITION_REQUIRED) try: body = request.get_json() objn = Link() obj = Link() objn.dictToLink(body) obj = service.findById(objn.id) if (obj is None): raise ModuleNotFoundError('não encontrado.') obj.ultimaColeta = objn.ultimaColeta obj = service.update(obj) return jsonify(obj.linkToJson()) except ModuleNotFoundError: abort(http.HTTPStatus.NO_CONTENT) except Exception: abort(http.HTTPStatus.INTERNAL_SERVER_ERROR)