File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 11from bottle import route , run , error , response
22from CepTracker import CepTracker
3+ from requests import ConnectionError
34
45import pymongo , json , re
56
@@ -35,8 +36,12 @@ def verifica_cep(cep):
3536 result = ceps .find_one ({'cep' :cep }, fields = {'_id' :False })
3637
3738 if not result or not result .has_key ('v_date' ) or expired (result ):
38- for item in _get_info_from_correios (cep ):
39- ceps .update ({'cep' : item ['cep' ]}, {'$set' : item }, upsert = True )
39+ try :
40+ for item in _get_info_from_correios (cep ):
41+ ceps .update ({'cep' : item ['cep' ]}, {'$set' : item }, upsert = True )
42+
43+ except ConnectionError :
44+ response .status = '503 Servico Temporariamente Indisponivel'
4045
4146 result = ceps .find_one ({'cep' :cep }, fields = {'_id' :False ,'v_date' :False })
4247
You can’t perform that action at this time.
0 commit comments