fix error if lat and long do not exist for site
[plstackapi.git] / planetstack / core / dashboard / views / view_common.py
index 4b0c338..db842cb 100644 (file)
@@ -23,7 +23,6 @@ if os.path.exists("/home/smbaker/projects/vicci/cdn/bigquery"):
     sys.path.append("/home/smbaker/projects/vicci/cdn/bigquery")
 else:
     sys.path.append("/opt/planetstack/hpc_wizard")
-import hpc_wizard
 from planetstack_analytics import DoPlanetStackAnalytics, PlanetStackAnalytics, RED_LOAD, BLUE_LOAD
 
 def getDashboardContext(user, context={}, tableFormat = False):
@@ -142,10 +141,16 @@ def getCDNOperatorData(randomizeData = False, wait=True):
         cpu=float(max_cpu)/100.0
         hotness = max(0.0, ((cpu*RED_LOAD) - BLUE_LOAD)/(RED_LOAD-BLUE_LOAD))
 
+        try:
+           lat=float(site.location.longitude)
+           long=float(site.location.longitude)
+        except:
+           lat=0
+           long=0
+
         # format it to what that CDN Operations View is expecting
-        new_row = {"lat": float(site.location.longitude),
-               "long": float(site.location.longitude),
-               "lat": float(site.location.latitude),
+        new_row = {"lat": lat,
+               "long": long,
                "health": 0,
                "numNodes": int(site.nodes.count()),
                "activeHPCSlivers": int(stats_row.get("count_hostname", 0)),     # measured number of slivers, from bigquery statistics