mirror of https://gitlab.com/m3f_usm/proto
agrego nombre de archivo proto para omitir escritura si es la misma informacion
parent
98dee26134
commit
a6c86a4753
17
main.py
17
main.py
|
@ -15,11 +15,18 @@ def main():
|
|||
print(datetime.now(tz))
|
||||
# print("hola")
|
||||
|
||||
content = download_file_proto()
|
||||
if content == None:
|
||||
fileproto = download_file_proto()
|
||||
if fileproto == None:
|
||||
return False
|
||||
|
||||
data = read_file_proto_x_stop(content)
|
||||
namefile = r.get('fileproto')
|
||||
if namefile == fileproto['name']:
|
||||
print(namefile)
|
||||
return
|
||||
|
||||
r.set('fileproto', fileproto['name'])
|
||||
print(fileproto['name'])
|
||||
data = read_file_proto_x_stop(fileproto['content'])
|
||||
|
||||
# save data to redis db
|
||||
for key in data:
|
||||
|
@ -31,7 +38,9 @@ def main():
|
|||
def download_file_proto():
|
||||
response = requests.get('https://app.ilab.cl/gtfs-rt/api/concepcion')
|
||||
if response.status_code == 200:
|
||||
return response.content
|
||||
content_disposition = response.headers['Content-Disposition']
|
||||
nombre_archivo = content_disposition.split('filename=')[1]
|
||||
return { 'name': nombre_archivo, 'content': response.content }
|
||||
return None
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue