Commit d90c792f authored by Renzo Marini's avatar Renzo Marini

cleaner arreglado, script de telemac chequea si esta comparando archivos con nombre de fecha

parent c8cbf99b
......@@ -15,7 +15,7 @@ def clean(root):
delete.append(path)
today = datetime.today()
for file in filenames:
if file.split(".")[-1] not in ["log", "m", "pickle", "csv"] or (today - date).days < 7:
if (today - date).days < 14:
delete = delete[:-1]
break
except ValueError:
......
import subprocess
import datetime
from datetime import datetime
import os
import mail
......@@ -13,15 +13,18 @@ def run_model(source):
for filename in os.listdir(metadata.hycom["output_path"]):
try:
date = filename[:8]
if not [dir for dir in os.listdir(metadata.telemac_dir + "/RESULTS") if dir[7:15] == date and "HYCOM_" in dir]:
# This line is meant to check whether the filename is a date
datetime.strptime(date, '%Y%m%d')
if not [dir for dir in os.listdir(metadata.telemac_dir + "/RUNS") if dir[7:15] == date and "HYCOM_" in dir]:
log_dir = metadata.logs_path + "/" + date + "/models"
if not os.path.exists(log_dir):
os.makedirs(log_dir)
with open(log_dir + "/telemac.log", "a+") as log_file:
subprocess.check_call(metadata.telemac_script + " 'HYCOM' " + date + " " + date + " 1 8", shell=True, stderr=log_file, stdout=log_file)
except ValueError:
pass # filename is not valid
except Exception as e:
mail.send("telemac")
pass # file is not valid
if __name__ == "__main__":
run_model("hycom")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment