Exemplo n.º 1
0
        tmonth = tnow.month
        strmonth = [
            'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
            'Oct', 'Nov', 'Dec'
        ]
        for year in range(ryear, tyear + 1):
            try:
                monthlist = getMonthList(year, rmonth)
            except Exception, msg:
                print 'Could not find a URL (starting with %s) for year %i.  Stopping.' % (
                    MONTHLY_GCMT_URL, year)
                sys.exit(0)
            for month in monthlist:
                try:
                    print 'Attempting to download data from %s, %i...' % (
                        strmonth[month - 1], year)
                    histfile = getMonthlyGCMT(year, month)
                    appendDataFile(histfile,
                                   outfile,
                                   'ndk',
                                   'gcmt',
                                   hasHeader=False)
                    os.remove(histfile)
                except Exception, msg:
                    fmt = 'Could not download GCMT data for %s, %i.  (It may not be posted yet)'
                    print fmt % (strmonth[month - 1], year)
                    continue
        mostrecent = getMostRecent(outfile)
        print 'GCMT database contains events through %s.' % str(mostrecent)
        sys.exit(0)
Exemplo n.º 2
0
            ryear += 1
            rmonth = 1
        tnow = datetime.datetime.now()
        tyear = tnow.year
        tmonth = tnow.month
        strmonth = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
        for year in range(ryear,tyear+1):
            try:
                monthlist = getMonthList(year,rmonth)
            except Exception,msg:
                print 'Could not find a URL (starting with %s) for year %i.  Stopping.' % (MONTHLY_GCMT_URL,year)
                sys.exit(0)
            for month in monthlist:
                try:
                    print 'Attempting to download data from %s, %i...' % (strmonth[month-1],year)
                    histfile = getMonthlyGCMT(year,month)
                    appendDataFile(histfile,outfile,'ndk','gcmt',hasHeader=False)
                    os.remove(histfile)
                except Exception,msg:
                    fmt = 'Could not download GCMT data for %s, %i.  (It may not be posted yet)'
                    print fmt % (strmonth[month-1],year)
                    continue
        mostrecent = getMostRecent(outfile)
        print 'GCMT database contains events through %s.' % str(mostrecent)
        sys.exit(0)
    
        


        
Exemplo n.º 3
0
    sys.exit(0)

infile = args.infile
outfile = args.outfile

if args.fmtype is None:
    args.fmtype = 'User'

if args.usendk:
    filetype = 'ndk'
if args.usecsv:
    filetype = 'csv'
if args.usexml:
    filetype = 'xml'

if os.path.isfile(outfile):
    print '%s already exists - appending new data.' % outfile
    try:
        appendDataFile(infile, outfile, filetype,
                       args.fmtype, hasHeader=args.hasheader)
    except Exception, msg:
        print 'Error reading input file %s.\n%s' % (infile, msg)
        sys.exit(1)
else:
    try:
        createDataFile(infile, outfile, filetype,
                       args.fmtype, hasHeader=args.hasheader)
    except Exception, msg:
        print 'Error reading input file %s.\n"%s"' % (infile, msg)
        sys.exit(1)