summaryrefslogtreecommitdiff
path: root/Code
diff options
context:
space:
mode:
authorHui Lan <lanhui@zjnu.edu.cn>2025-04-02 15:31:58 +0800
committerHui Lan <lanhui@zjnu.edu.cn>2025-04-02 15:31:58 +0800
commit60e7b12addc3acc8b49ba6aa07b71ebcf6ddf54d (patch)
tree75e5a2f9124a9f1b9aa3fd1e31c48f8816f17744 /Code
parent0909c50606e3fe533f88436cd0486315279da2d2 (diff)
Reverse download log lines and write them to a new file download_log_reversed.txt so that the most recent log line appears on the top. Purpose: easier to check log from the web browser.
Diffstat (limited to 'Code')
-rw-r--r--Code/download_and_map.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Code/download_and_map.py b/Code/download_and_map.py
index ebc742d..a78409e 100644
--- a/Code/download_and_map.py
+++ b/Code/download_and_map.py
@@ -361,6 +361,14 @@ def kill_process(process_name):
print(f'{e}')
return False
+def reverse_lines(fname, fname2):
+ with open(fname) as f:
+ lines = f.readlines()
+
+ with open(fname2, 'w') as f2:
+ lines.reverse()
+ content = ''.join(lines)
+ f2.write(content)
## main
@@ -421,3 +429,4 @@ else:
write_download_log_file(DOWNLOADED_SRA_ID_LOG_FILE, '%s\n' % ('\n'.join(map_list)))
write_download_log_file(DOWNLOADED_SRA_ID_LOG_FILE, 'DONE at %s\n' % (curr_time))
+reverse_lines(DOWNLOADED_SRA_ID_LOG_FILE, os.path.splitext(DOWNLOADED_SRA_ID_LOG_FILE)[0] + '_reversed.txt')