PRO check_corres_year_directory,update = update
ligne =''
openr,lun,'corres_year_directory',/get_lun
while not EOF(lun) do begin
readf,lun,ligne
if (strmid(ligne,0,1) eq 's') then num_flight = strmid(ligne,1,2)
endwhile
free_lun,lun
i=num_flight+1
str_i = strcompress(string(i),/remove_all)
adresse = 'http://cassini.physics.uiowa.edu/~wsk/cas/daspage/cas_data/s'+str_i+'flight/'
command = "wget --http-user=casrpws --http-passwd=uiowa "+adresse
spawn,command
structure = file_info('index.html')
if structure.exists ne 0 then begin
num_flight_new = i
date_premier_k = ''
date_dernier_k = ''
print,'//////////NOUVEAU REPERTOIRE///////'
openr,lun,'index.html',/get_lun
while not EOF(lun) do begin
readf,lun,ligne
if strmid(ligne,0,20) eq '<IMG SRC="/icons/unk' and date_premier_k eq '' then date_premier_k = strmid(ligne,53,10)
if strmid(ligne,0,20) eq '<IMG SRC="/icons/unk' then date_dernier_k = strmid(ligne,53,10)
if strmid(ligne,0,6) eq '</PRE>' then break
endwhile
spawn,"rm -rf index.html"
free_lun,lun
endif
first_K = strarr(num_flight)
first_corres = strarr(num_flight)
for i=1,num_flight do begin
if i lt 10 then str_i ='0'+strcompress(string(i),/remove_all) else str_i = strcompress(string(i),/remove_all)
adresse = 'http://cassini.physics.uiowa.edu/~wsk/cas/daspage/cas_data/s'+str_i+'flight/'
command = "wget --http-user=casrpws --http-passwd=uiowa "+adresse
spawn,command
openr,lun,'index.html',/get_lun
ligne=''
test =0
while not EOF(lun) do begin
readf,lun,ligne
if (strmid(ligne,0,28) eq '<IMG SRC="/icons/unknown.gif') then begin
first = strmid(ligne,53,10)
test = 1
endif
if test eq 1 then break
endwhile
free_lun,lun
spawn, "rm -rf index.html"
first_K[i-1] = first
endfor
ind = 0
openr,lun,'corres_year_directory',/get_lun
while not EOF(lun) and ind lt num_flight do begin
readf,lun,ligne
if (strmid(ligne,0,1) eq 's') then begin
first_corres[ind] = strmid(ligne,11,10)
ind = ind+1
endif
endwhile
free_lun,lun
liste=''
compteur=0
for i=0,num_flight-1 do begin
if first_K[i] ne first_corres[i] then begin
print,'-----------------------------------------------------'
print,'Attention changement du repertoire ',strcompress('s'+string(i+1)+'flight',/remove_all)
print,'Date debut dans le fichier corres_year_directory: ',first_corres[i]
print,'Date debut sur le site iowa : ',first_K[i]
if liste ne '' then liste = liste+'/'+string(i+1) else liste = string(i+1)
compteur = compteur + 1
endif
endfor
if compteur eq 0 then print,'Pas de difference entre corres_year_directory et iowa'
if keyword_set(update) then update = 1 else update = 0
if update eq 1 then begin
if compteur ne 0 then begin
j=0
tab_indices=intarr(compteur)
for i=0,num_flight-1 do begin
if first_K[i] ne first_corres[i] then begin
tab_indices[j]=i
j=j+1
endif
endfor
liste = strcompress(liste,/remove_all)
tab_date=strarr(compteur,2)
tab_date[*,0] = str_sep(liste,'/')
for i=0,compteur-1 do tab_date[i,1] = first_K[tab_indices[i]]
ligne=''
nb_lignes = 0
openr,lun,'corres_year_directory',/get_lun
while not EOF(lun) do begin
readf,lun,ligne
nb_lignes = nb_lignes + 1
endwhile
free_lun,lun
tab_lignes = strarr(nb_lignes)
ligne=''
date_fin = ''
i = 0
j = 0
openr,lun,'corres_year_directory',/get_lun
while not EOF(lun) do begin
readf,lun,ligne
if strmid(ligne,0,3) eq strcompress('s'+tab_date(j,0),/remove_all) then begin
ligne = strmid(ligne,0,11)+tab_date(j,1)+strmid(ligne,21,11)
if strmid(ligne,1,2) ne '01' then begin
yyyy = strmid(ligne,11,4)
ddd = strmid(ligne,15,3)
hh = strmid(ligne,19,2)
if hh ne '00' then begin
hh = fix(hh)
if hh lt 11 then hh = '0'+string(hh -1) else hh = string(hh-1)
date_fin = strcompress(yyyy+ddd+'.'+hh,/remove_all)
endif else begin
if ddd ne 001 then begin
ddd = string(ddd-1)
ddd = strcompress(ddd,/remove_all)
if strlen(ddd) eq 2 then ddd = '0'+ddd
if strlen(ddd) eq 1 then ddd = '00'+ddd
date_fin = strcompress(yyyy+ddd+'.23',/remove_all)
endif else begin
yyyy = string(yyyy -1)
if((yyyy mod 4 eq 0 && yyyy mod 100 ne 0) or (yyyy mod 400 eq 0)) then ddd=366 else ddd=365
date_fin = strcompress(string(yyyy)+string(ddd)+'.23',/remove_all)
endelse
endelse
endif
tab_lignes[i-1] = strmid(tab_lignes[i-1],0,22)+date_fin
tab_lignes[i] = ligne
if j ne compteur-1 then j=j+1
endif else tab_lignes[i] = ligne
i = i+1
endwhile
free_lun,lun
openw,lun,'corres_year_directory',/get_lun
for i=0,nb_lignes-2 do printf,lun,tab_lignes[i]
if date_premier_k ne '' then begin
yyyy = strmid(date_premier_k,0,4)
ddd = strmid(date_premier_k,4,3)
hh = strmid(date_premier_k,8,2)
if hh ne '00' then begin
hh = fix(hh)
if hh lt 11 then hh = '0'+string(hh -1) else hh = string(hh-1)
date_fin = strcompress(yyyy+ddd+'.'+hh,/remove_all)
endif else begin
if ddd ne 001 then begin
ddd = string(ddd-1)
ddd = strcompress(ddd,/remove_all)
if strlen(ddd) eq 2 then ddd = '0'+ddd
if strlen(ddd) eq 1 then ddd = '00'+ddd
date_fin = strcompress(yyyy+ddd+'.23',/remove_all)
endif else begin
yyyy = string(yyyy -1)
if((yyyy mod 4 eq 0 && yyyy mod 100 ne 0) or (yyyy mod 400 eq 0)) then ddd=366 else ddd=365
date_fin = strcompress(string(yyyy)+string(ddd)+'.23',/remove_all)
endelse
endelse
line_before_new_line=''
line_before_new_line = strmid(tab_lignes[nb_lignes-1],0,22)+date_fin
printf,lun, line_before_new_line
new_line = strcompress('s'+string(num_flight_new),/remove_all)+'flight/ '+date_premier_k+' '+date_dernier_k
printf,lun,new_line
endif else printf,lun,tab_lignes[nb_lignes-1]
free_lun,lun
str = ''
nom_rep = strarr(compteur)
for i=0,compteur-1 do begin
if fix(tab_indices[i]+1) ge 10 then nom_rep[i] = strcompress('s'+string(tab_indices[i]+1)+'flight',/remove_all) else begin
nom_rep[i] = strcompress('s0'+string(tab_indices[i+1])+'flight',/remove_all)
endelse
endfor
for i=0,compteur-1 do str = str + '/// Periode : '+first_K[tab_indices[i]]+' a '+first_corres[tab_indices[i]]+' dans le repertoire '+nom_rep[i]+' . /////////////////// '
str = ' Calculs a faire sur les periodes : ////////////////////////////////////////////////////// '+ str
if date_premier_k ne '' then begin
str_rep = strcompress(string(num_flight_new),/remove_all)
str_rep = strcompress('s'+str_rep+'flight',/remove_all)
str = str + 'ATTENTION nouveau repertoire '+str_rep
print,'///////////// ATTENTION nouveau repertoire '+str_rep+' //////////////////////'
endif
spawn,'echo '+str+' | mail -s "Calculs kronosdp a faire" eleonore.holle@obspm.fr'
endif else spawn, 'echo Pas de modifications a faire | mail -s "Pas de nouveaux calculs a faire" eleonore.holle@obspm.fr'
endif else begin
print,'////////////////////////////////////////////////////////////////////////////////////////////'
print,'Si vous desirez faire la mise a jour du fichier corres_year_directory relancez la procedure '
print,'avec le mot cle update check_corres_year_directory,update=1'
endelse
END