-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
executable file
·62 lines (46 loc) · 1.42 KB
/
main.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
import config
import create_db
import lbrynomics_meta
import measurement
import plotter
import recent
import subprocess
import time
import upload
# Measure the time
started_at = time.time()
# Create the database
create_db.create_db()
# Test for history and estimate it if it's not there
create_db.test_history()
# Enter main loop
k = 0
while True:
d = (time.time() - started_at)/86400.0
print(f"This process has been running for {d:.3f} days.", flush=True)
# Make the measurement
result = measurement.make_measurement(k)
# Count recent activity and write to JSON
recent.count_recent_all(result["time"])
# Data about LBRYnomics itself
lbrynomics_meta.lbrynomics_meta(result["time"], d)
# Make plots
if k%2 == 0:
plotter.make_plots(production=True, truncate=False)
plotter.make_plots(production=True, truncate=True)
upload.upload(include_pngs=True)
else:
upload.upload(include_pngs=False)
# upload.upload("secrets2.yaml")
# Backup db periodically
# if k % 36 == 0:
# print("Backing up DB files...", flush=True)
# upload.backup()
# print("done.\n", flush=True)
# Get the time and make another measurement in 5 minutes
print("Sleeping for {wait} seconds.".format(wait=config.interval), end=" ", flush=True)
time.sleep(config.interval)
print("done.\n", flush=True)
k += 1
databases.close()