merge from improvements on the 1.0 branch:
[monitor.git] / pcubad.py
index 04118e2..181f001 100755 (executable)
--- a/pcubad.py
+++ b/pcubad.py
@@ -10,11 +10,12 @@ from monitor import database
 from pcucontrol  import reboot
 from monitor import parser as parsermodule
 from monitor import config
 from pcucontrol  import reboot
 from monitor import parser as parsermodule
 from monitor import config
-from monitor.database import HistoryPCURecord, FindbadPCURecord
+from monitor.database.info.model import HistoryPCURecord, FindbadPCURecord
+from monitor.database.dborm import mon_session as session
 from monitor.wrapper import plc,plccache
 from monitor.const import MINUP
 
 from monitor.wrapper import plc,plccache
 from monitor.const import MINUP
 
-from nodecommon import *
+from monitor.common import *
 from nodequery import verify,query_to_dict,node_select
 from monitor.model import *
 
 from nodequery import verify,query_to_dict,node_select
 from monitor.model import *
 
@@ -22,7 +23,6 @@ api = plc.getAuthAPI()
 
 def main(config):
 
 
 def main(config):
 
-       #l_plcpcus = database.if_cached_else_refresh(1, 1, "pculist", lambda : plc.GetPCUs())
        l_plcpcus = plccache.l_pcus 
 
        l_pcus = None
        l_plcpcus = plccache.l_pcus 
 
        l_pcus = None
@@ -94,6 +94,7 @@ def checkAndRecordState(l_pcus, l_plcpcus):
        # replace with another operations that also commits all pending ops, such
        # as session.commit() or flush() or something
        print HistoryPCURecord.query.count()
        # replace with another operations that also commits all pending ops, such
        # as session.commit() or flush() or something
        print HistoryPCURecord.query.count()
+       session.flush()
 
        return True
 
 
        return True