handle the case where there is no data in db yet.
Stephen Soltesz [Wed, 3 Dec 2008 19:06:59 +0000 (19:06 +0000)]
monitor/database/info/findbad.py
monitor/wrapper/plc.py

index da7775a..13132d1 100644 (file)
@@ -22,7 +22,10 @@ class FindbadNodeRecord(Entity):
        @classmethod
        def get_all_latest(cls):
                fbsync = FindbadNodeRecordSync.get_by(hostname="global")
-               return cls.query.filter_by(round=fbsync.round)
+               if fbsync:
+                       return cls.query.filter_by(round=fbsync.round)
+               else:
+                       return []
 
        @classmethod
        def get_latest_by(cls, **kwargs):
@@ -80,8 +83,10 @@ class FindbadPCURecord(Entity):
        @classmethod
        def get_all_latest(cls):
                fbsync = FindbadPCURecordSync.get_by(plc_pcuid=0)
-               print "round: ", fbsync.round
-               return cls.query.filter_by(round=fbsync.round)
+               if fbsync:
+                       return cls.query.filter_by(round=fbsync.round)
+               else:
+                       return []
 
        @classmethod
        def get_latest_by(cls, **kwargs):
index 2ddb061..255e3c1 100644 (file)
@@ -15,7 +15,7 @@ import traceback
 from monitor import database
 
 try:
-       import config
+       from monitor import config
        debug = config.debug
 except:
        debug = False