Milestone #727
Milestone #726: Data recovery of magnetometers stations
Piura 2016
Description
Create a script to copy the yesterday file to the server.
The script is in the station.
#!/usr/bin/python
-- coding: utf-8 --¶
import sys
import os
import time
import ftplib
from datetime import datetime, timedelta
def main():
#os.system("cd DataMin")
#os.system('cd ..')
os.system("pwd")
for i in range(1):
yesterday=datetime.now()-timedelta(days=i+1)
print str(yesterday)
ftp_servidor = 'lisn.igp.gob.pe'
ftp_usuario = ''
ftp_clave = ''
ftp_raiz = 'isr/magnetometer/piur/2016/'
try:
s = ftplib.FTP(ftp_servidor, ftp_usuario, ftp_clave)
try:
name = yesterday.strftime("PIU%d%b.%ym")
n_file = name.lower()
f=open("DataMin/"+n_file,'rb')
s.cwd(ftp_raiz)
s.storbinary('STOR ' + n_file, f)
f.close()
s.quit()
except:
print " Se realizo envio"
except:
print " No se ha podido conectar con el servidor"
main()