Example #1
0
def jpl_lookup(query):
    result = jpl.find_one({'tag_name': query}, {'_id': False})
    if not result:
        print 'JPL lookup: %s not found in cache...' % query
        # maybe it's not cached; try querying for it from horizons
        try:
            a = JPL_Asteroid(query)
            a.load()
            print 'JPL lookup: %s loaded from JPL' % query
            result = a.data
            result['tag_name'] = query
            jpl.insert(result)  # cache
            del result['_id']
        except:
            print 'JPL lookup: %s lookup failed' % query
            return None
    else:
        print 'JPL lookup: %s found in cache' % query

    del result['tag_name']
    return result
Example #2
0
def jpl_lookup(query):
    result = jpl.find_one({"tag_name": query}, {"_id": False})
    if not result:
        print "JPL lookup: %s not found in cache..." % query
        # maybe it's not cached; try querying for it from horizons
        try:
            a = JPL_Asteroid(query)
            a.load()
            print "JPL lookup: %s loaded from JPL" % query
            result = a.data
            result["tag_name"] = query
            jpl.insert(result)  # cache
            del result["_id"]
        except:
            print "JPL lookup: %s lookup failed" % query
            return None
    else:
        print "JPL lookup: %s found in cache" % query

    del result["tag_name"]
    return result
Example #3
0
def jpl_lookup(query):
  result = jpl.find_one({'tag_name': query}, {'_id': False})
  if not result:
    print 'JPL lookup: %s not found in cache...' % query
    # maybe it's not cached; try querying for it from horizons
    try:
      a = JPL_Asteroid(query)
      a.load()
      print 'JPL lookup: %s loaded from JPL' % query
      result = a.data
      result['tag_name'] = query
      jpl.insert(result)  # cache
      del result['_id']
    except:
      print 'JPL lookup: %s lookup failed' % query
      return None
  else:
    print 'JPL lookup: %s found in cache' % query

  del result['tag_name']
  return result