コード例 #1
0
ファイル: log_lookup.py プロジェクト: rgrapenthin/GPStools
if not os.path.isfile(xmlfile):
    sys.stderr.write("\nError: Can't find record for site `"+site+"' in GPS_SITE_DOC. `"+xmlfile+"' does not exist.\n")
    sys.stderr.write("Attempting retrieval ...\n")
    os.system("get_site_log.py -s %s" % site)
    
    #still nothing ...
    if not os.path.isfile(xmlfile):
        sys.exit(2)
    

###----------------------
#+#READ XML log
###----------------------
try:
    log = XML_LogReader(xmlfile, site)
except Exception as e:
    sys.stderr.write("\nSomething went wrong ... \n\n")
    sys.stderr.write("%s\n\n" % e)
    sys.stderr.write(" ... better try again.\n")
    sys.exit(2)


###----------------------
#+#OUTPUT functions
###----------------------

#print site_pos format, if asked for
if pos:
    print "%15.4f %15.4f %15.4f" % ( log.XPos(), log.YPos(), log.ZPos() )
コード例 #2
0
#site
        elif opt in ("-s", "--site"):
            site    = arg.lower()
            xmlfile = gps_site_doc+"/"+site+".xml"
        else:
            assert False, "unhandled option: `%s'" % opt

    if not site: 
        usage(error="Need to give site id")
        sys.exit(2)
        
###----------------------
#+#READ XML log
###----------------------
    try:
        log = XML_LogReader(xmlfile, site)
    except IOError as e:
        #file not found, try FTP download from usual archives
        sys.stderr.write("Site `"+site+"' not in local database; trying remote retrieval ...\n")
        util.get_site_log(site=site)              
        log = XML_LogReader(xmlfile, site)
    except Exception as e:
        #I guess we're doomed!
        sys.stderr.write("\nSomething went wrong ... \n\n")
        sys.stderr.write("%s\n\n" % e)
        sys.stderr.write(" ... better try again.\n")
        sys.exit(2)    

    print "Updating site `"+site+"' ("+log.site_name()+")"

###----------------------