Changeset 6033

Show
Ignore:
Timestamp:
11/13/12 09:47:24 (7 years ago)
Author:
leonwlaw
Message:

Fix for crashes due to failed geoip lookups

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • seattle/trunk/repy/apps/allpairspingmap/allpairspingmap.mix

    r6032 r6033  
    198198    # Print node list element 
    199199    nodelist_str += ('<li id="node' + str(nodeiplist.index(nodeip)) + '"><span class="nodeip">' + 
    200                       str(nodeip) + '</span><span class="longitude">' + str(nodelocdict['longitude']) + 
    201                       '</span><span class="latitude">' + str(nodelocdict['latitude']) + 
    202                       '</span><span class="locationname">' + geoip_location_str(nodelocdict) + '</span></li>') 
    203  
     200                      str(nodeip) + '</span>') 
     201     
     202    if nodelocdict is not None: 
     203      nodelist_str += ('<span class="longitude">' + str(nodelocdict['longitude']) + 
     204                        '</span><span class="latitude">' + str(nodelocdict['latitude']) + 
     205                        '</span><span class="locationname">' + geoip_location_str(nodelocdict) + '</span>') 
     206    else: 
     207      nodelist_str += "No location data available" 
     208    nodelist_str += '</li>' 
    204209  nodelist_str += '</ul>' 
    205210  return nodelist_str 
     
    421426    try: 
    422427      locationdict = geoip_record_by_addr(neighbor) 
    423       # Sometimes we don't get a city name. 
    424       if 'city' not in locationdict: 
    425         locationdict['city'] = "Unknown" 
    426       mycontext['locationdata'][neighbor] = locationdict 
     428      if locationdict is not None: 
     429        # Sometimes we don't get a city name. 
     430        if 'city' not in locationdict: 
     431          locationdict['city'] = "Unknown" 
     432        mycontext['locationdata'][neighbor] = locationdict 
     433       
     434      # The lookup failed 
     435      else: 
     436        mycontext['locationdata'][neighbor] = None 
    427437 
    428438    except Exception, e: