Commit 6bd19bbe authored by Mijian Xu's avatar Mijian Xu 😷
Browse files

Update the kml function

parent 5fd24a9b
......@@ -30,6 +30,7 @@ import datetime
import os, re
import sys, getopt
from smtplib import SMTP
import time
try:
import configparser
config = configparser.ConfigParser()
......@@ -176,5 +177,6 @@ smtp.set_debuglevel(0)
smtp.login(EMAIL, passwd)
smtp.sendmail(EMAIL, recipient, msg)
smtp.quit()
time.sleep(5)
print("Successful sending the mail of "+network+"."+station+" to IRIS DMC!!!")
......@@ -23,6 +23,7 @@ import datetime
import os, re
import sys, getopt
from smtplib import SMTP
import time
try:
import configparser
config = configparser.ConfigParser()
......@@ -137,6 +138,7 @@ while 1:
for sta_row in sta:
msg += sta_row[1]+' '+sta_row[0]+' '+nowtime.strftime('%Y')+' '+nowtime.strftime('%m')+' '+nowtime.strftime('%d')+' '+nowtime.strftime('%H')+' '+nowtime.strftime('%M')+' 00.0 '+endtime.strftime('%Y')+' '+endtime.strftime('%m')+' '+endtime.strftime('%d')+' '+endtime.strftime('%H')+' '+endtime.strftime('%M')+' 00.0 1 '+chan+' '+sta_row[2]+'\n'
smtp.sendmail(EMAIL, recipient, msg)
time.sleep(5)
print("Successful sending the mail between "+nowtime.strftime('%Y')+'.'+nowtime.strftime('%m')+'.'+nowtime.strftime('%d')+'.'+nowtime.strftime('%H')+" and "+endtime.strftime('%Y')+'.'+endtime.strftime('%m')+'.'+endtime.strftime('%d')+'.'+endtime.strftime('%H')+"!!!")
nowtime = nowtime + datetime.timedelta(hours=timeval)
smtp.quit()
......@@ -132,25 +132,34 @@ for info in find_re.findall(html):
print(netname+' '+staname+' '+stlat+' '+stlon+' '+yrange1+' '+yrange2)
if iskml:
if network != '':
Knetwork = network+'amp;'
netname = re.split('[=|&]', network)[1]
else:
Knetwork = network
if station != '':
Kstation = station+'amp;'
else:
Kstation = station
if yrange != '':
Kyrange = yrange+'amp;'
else:
Kyrange = yrange
if chan != '':
Kchan = chan+'amp;'
else:
Kchan = chan
if islalo:
if network != '':
Knetwork = network+'amp;'
else:
Knetwork = network
if station != '':
Kstation = network+'amp;'
else:
Kstation = station
if yrange != '':
Kyrange = yrange+'amp;'
else:
Kyrange = yrange
if chan != '':
Kchan = chan+'amp;'
else:
Kchan = chan
href = 'http://www.iris.edu/cgi-bin/kmlstationinfo?minlat='+lat1+'&maxlat='+lat2+'&minlon='+lon1+'&maxlon='+lon2+'&'+Knetwork+Kstation+Kyrange+Kchan+'kmz=1'
google = open('Station_'+lalo+'.kml','w+')
google.write('<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.google.com/earth/kml/2.0"><NetworkLink><name>Selected stations</name><description>Station List</description><Link><href>'+href+'</href><refreshMode>onInterval</refreshMode><refreshInterval>86400</refreshInterval></Link></NetworkLink></kml>')
with open('Station_'+lalo+'.kml','w+') as google:
google.write('<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.google.com/earth/kml/2.0"><NetworkLink><name>Selected stations</name><description>Station List</description><Link><href>'+href+'</href><refreshMode>onInterval</refreshMode><refreshInterval>86400</refreshInterval></Link></NetworkLink></kml>')
print('Seccessfully create the Google Earth file: Station_'+lalo+'.kml')
else:
print('Cannot creat the .kml file, "-R" is required.')
try:
href = 'http://www.iris.edu/cgi-bin/kmlstationinfo?'+Knetwork+Kstation+Kyrange+Kchan+'kmz=1'
with open('Station_'+netname+'.kml','w+') as google:
google.write('<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.google.com/earth/kml/2.0"><NetworkLink><name>Selected stations</name><description>Station List</description><Link><href>'+href+'</href><refreshMode>onInterval</refreshMode><refreshInterval>86400</refreshInterval></Link></NetworkLink></kml>')
print('Seccessfully create the Google Earth file: Station_'+netname+'.kml')
except:
print('Cannot creat the .kml file, "-R" or "-N" is required.')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment