-
Notifications
You must be signed in to change notification settings - Fork 3
/
get_index.py
45 lines (38 loc) · 1.52 KB
/
get_index.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
def get_index(server):
import os
import config
# check if local Argo index file is up to date
if not os.path.exists(config.fidx): # download Argo index file
cmd = 'wget '+server+config.fidx+'.gz'
#cmd = 'gftp -V '+server+config.fidx+'.gz'
print(cmd)
print('Downloading Argo index file. This may take some time... ')
os.system(cmd) # get updated argo index file
cmd = 'gunzip -f '+config.fidx+'.gz'
os.system(cmd)
else: # check the one you have is up-to-date
cmd = 'curl -r 0-500 '+server+'ar_index_global_prof.txt > tmp_header.txt'
print('Checking timestamp of Argo index file on server... ')
print(cmd)
os.system(cmd)
f = open('tmp_header.txt','r')
for line in f:
if 'Date of update' in line: dlineServer=line
f.close()
f = open(config.fidx,'r')
for line in f:
if 'Date of update' in line: dlineLocal=line
f.close()
uptodate = dlineServer == dlineLocal
cmd = 'rm tmp_header.txt'
os.system(cmd)
if not uptodate:
cmd = 'wget '+server+config.fidx+'.gz'
#cmd = 'gftp -V '+server+config.fidx+'.gz'
print('Updating local Argo index file. This may take some time... ')
print(cmd)
os.system(cmd) # get updated argo index file
cmd = 'gunzip -f '+config.fidx+'.gz'
os.system(cmd)
else:
print('The local Argo index file is up-to-date.')