Skip to content
Snippets Groups Projects
Commit 824fc4e6 authored by Alê Borba's avatar Alê Borba
Browse files

Merge pull request #36 from CodingForChange/erro_503

Tratando queda dos correios
parents f050a708 33b8b0a3
No related branches found
No related tags found
No related merge requests found
from bottle import route, run, response
from CepTracker import CepTracker
from requests import ConnectionError
from database import MongoDb as Database
......@@ -34,8 +35,12 @@ def verifica_cep(cep):
result = db.get_one(cep, fields={ '_id': False })
if not result or not result.has_key('v_date') or expired(result):
for item in _get_info_from_correios(cep):
db.insert_or_update(item)
try:
for item in _get_info_from_correios(cep):
db.insert_or_update(item)
except ConnectionError:
response.status = '503 Servico Temporariamente Indisponivel'
result = db.get_one(cep, fields={ '_id': False, 'v_date': False })
......
This file is placed here by pip to indicate the source was put
here by pip.
Once this package is successfully installed this source code will be
deleted (unless you remove this file).
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment