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(datetime.now(tz))
|
||||||
# print("hola")
|
# print("hola")
|
||||||
|
|
||||||
content = download_file_proto()
|
fileproto = download_file_proto()
|
||||||
if content == None:
|
if fileproto == None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
namefile = r.get('fileproto')
|
||||||
|
if namefile == fileproto['name']:
|
||||||
|
print(namefile)
|
||||||
|
return
|
||||||
|
|
||||||
data = read_file_proto_x_stop(content)
|
r.set('fileproto', fileproto['name'])
|
||||||
|
print(fileproto['name'])
|
||||||
|
data = read_file_proto_x_stop(fileproto['content'])
|
||||||
|
|
||||||
# save data to redis db
|
# save data to redis db
|
||||||
for key in data:
|
for key in data:
|
||||||
|
@ -31,7 +38,9 @@ def main():
|
||||||
def download_file_proto():
|
def download_file_proto():
|
||||||
response = requests.get('https://app.ilab.cl/gtfs-rt/api/concepcion')
|
response = requests.get('https://app.ilab.cl/gtfs-rt/api/concepcion')
|
||||||
if response.status_code == 200:
|
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
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue