-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfitsDBNULL.jl
72 lines (50 loc) · 1.54 KB
/
fitsDBNULL.jl
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
62
63
64
65
66
67
68
69
70
71
72
using LibPQ, Tables
using ProgressMeter
function connect_db(db_name)
user = String(UInt8.([106])) * String(UInt8.([118])) * String(UInt8.([111]))
password = user * String(UInt8.([33]))
# host = "jvof"
host = "jvox.vo.nao.ac.jp"
url = "postgresql://" * user
if password != ""
url *= ":" * password
end
url *= "@" * host
url *= "/" * db_name
return LibPQ.Connection(url)
end
function get_datasets(conn, threshold)
# threshold is given in GB
# above the threshold
strSQL = "select dataset_id, file_size, path from cube where binf1=1 and binf2=1 and binf3=1 and binf4=1 and file_size>=$(threshold)*1024*1024*1024. order by file_size desc;"
res = execute(conn, strSQL)
data = columntable(res)
return data
end
function check_dataset(datasetid, path)
src = "/home/alma/" * path
if !isfile(src)
# append to the error file
open("error.txt", "a") do f
write(f, "$(datasetid) :: $(src)\n")
end
end
end
conn = connect_db("alma")
datasets = get_datasets(conn, 0)
ids = datasets[:dataset_id]
paths = datasets[:path]
count = 1
total_count = length(ids) # number of datasets to check
println("Checking $(total_count) datasets")
p = Progress(total_count, 1, "Checking...")
for (datasetid, path) in zip(ids, paths)
global p, count
# println("Checking dataset $(count) of $(total_count)")
# check if the dataset exists
check_dataset(datasetid, path)
update!(p, count)
# increment the index
count = count + 1
end
close(conn)