// frozen: if with a new status file that has not been updated
//
//
task_file = os.path.join(os.path.expanduser("~"), ".sos", "tasks", task + ".task")
status_file = os.path.join(os.path.expanduser("~"), ".sos", "tasks", task + ".status")
res_file = os.path.join(os.path.expanduser("~"), ".sos", "tasks", task + ".res")
if os.path.isfile(res_file):
new_res = os.path.getmtime(task_file) <= os.path.getmtime(res_file)
try:
with open(res_file, "rb") as result:
res = pickle.load(result)
if res["succ"] == 0:
if new_res:
return "completed"
else:
return "completed-old"
else:
if new_res:
return "failed"
else:
return "failed-old"
except Exception as e:
return "failed"
try:
if not os.path.isfile(status_file) or os.path.getmtime(status_file) < os.path.getmtime(res_file):
return "pending"
except:
// there is a slight chance that the old res_file is removed