forked from karpathy/arxiv-sanity-preserver
-
Notifications
You must be signed in to change notification settings - Fork 1
/
all_in_one.py
39 lines (30 loc) · 1.18 KB
/
all_in_one.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
import subprocess
import time
import fetch_papers, analyze, buildsvm, make_cache
from utils import to_struct_time, Config
def sync_execs():
fetch_papers.run()
analyze.run()
buildsvm.run()
make_cache.run()
def download_pdfs(pre_proc):
if pre_proc is not None:
print("preparing to restart downloading...")
pre_proc.stdin.write('restart\n'.encode())
pre_proc.stdin.flush()
return pre_proc
else:
return subprocess.Popen("python download_pdfs.py", stdin=subprocess.PIPE)
if __name__ == '__main__':
download_proc, next_day_float, first_start = None, time.time() + 24 * 3600, True
if not os.path.exists(Config.db_path):
sync_execs()
download_proc = download_pdfs(None)
while True:
cur_hour = to_struct_time(time.localtime()).tm_hour
if cur_hour == 12 and time.time() > next_day_float: # update data and restart download at 12:00
sync_execs()
download_proc = download_pdfs(download_proc)
subprocess.Popen("python thumb_pdf.py", creationflags=subprocess.CREATE_NEW_CONSOLE)
time.sleep(60 * 60) # sync every 1 hour