From b442a3ddf7f0452e5dd0d8c042a5e155effea154 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Wed, 7 Aug 2024 15:19:26 +0800 Subject: Fix error occurred while running update_network.py --- Code/update_network.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Code/update_network.py') diff --git a/Code/update_network.py b/Code/update_network.py index 82c8cb9..376b948 100755 --- a/Code/update_network.py +++ b/Code/update_network.py @@ -41,7 +41,6 @@ # Last modified: 10 Sep 2019, hui [correlation_mixtools, check the previous R session has finished before starting a new one.] import os, sys -import numpy as np import glob import time from datetime import datetime @@ -130,6 +129,11 @@ def write_sample_size_file(sample_size_file, curr_date, tpm_sample_size): f.close() +def empty_file(fname): + with open(fname) as f: + return f.read().strip() == '' + + def age_of_file_in_days(fname): ''' Return age of fname in days. ''' st = os.stat(fname) @@ -604,7 +608,7 @@ validate_parameter_for_net(PARAMETER_FOR_NET) # If the file timestamp does not exist, create one -if not os.path.exists(TIMESTAMP_FILE): +if not os.path.exists(TIMESTAMP_FILE) or empty_file(TIMESTAMP_FILE): record_file_time(FILE_LIST_TO_CHECK, TIMESTAMP_FILE) # Get update time of mandatory files -- cgit v1.2.1