當前位置: 首頁>>代碼示例>>Python>>正文


Python DbHelper.close_session方法代碼示例

本文整理匯總了Python中domogik.common.database.DbHelper.close_session方法的典型用法代碼示例。如果您正苦於以下問題:Python DbHelper.close_session方法的具體用法?Python DbHelper.close_session怎麽用?Python DbHelper.close_session使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在domogik.common.database.DbHelper的用法示例。


在下文中一共展示了DbHelper.close_session方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: XplManager

# 需要導入模塊: from domogik.common.database import DbHelper [as 別名]
# 或者: from domogik.common.database.DbHelper import close_session [as 別名]

#.........這裏部分代碼省略.........
            self.log.error(failed)
            reply_msg = MQMessage()
            reply_msg.set_action('cmd.send.result')
            reply_msg.add_data('status', False)
            reply_msg.add_data('reason', failed)
            self.log.debug(u"mq reply".format(reply_msg.get()))
            self.reply(reply_msg.get())

    def load(self):
        """ (re)load all xml files to (re)create _Stats objects
        """
        self.log.info(u"Rest Stat Manager loading.... ")
        self._db.open_session()
        try:
            # not the first load : clean
            if self.stats != None:
                self.log.info(u"reloading")
                for stat in self.stats:
                    self.myxpl.del_listener(stat.get_listener())

            ### Load stats
            # key1, key2 = device_type_id, schema
            self.stats = []
            created_stats = []
            for stat in self._db.get_all_xpl_stat():
                # xpl-trig
                self.stats.append(self._Stat(self.myxpl, stat, "xpl-trig", \
                                self.log, self.pub, self.client_conversion_map))
                # xpl-stat
                self.stats.append(self._Stat(self.myxpl, stat, "xpl-stat", \
                                self.log, self.pub, self.client_conversion_map))
        except:
            self.log.error(u"%s" % traceback.format_exc())
        self._db.close_session()
        self.log.info(u"Loading finished")

    class _Stat:
        """ This class define a statistic parser and logger instance
        Each instance create a Listener and the associated callbacks
        """

        def __init__(self, xpl, stat, xpl_type, log, pub, conversions):
            """ Initialize a stat instance
            @param xpl : A xpl manager instance
            @param stat : A XplStat reference
            @param xpl-type: what xpl-type to listen for
            """
            ### Rest data
            self._log_stats = log
            self._stat = stat
            self._pub = pub
            self._conv = conversions

            ### build the filter
            params = {'schema': stat.schema, 'xpltype': xpl_type}
            for param in stat.params:
                if param.static:
                    params[param.key] = param.value

            ### start the listener
            self._log_stats.info("creating listener for %s" % (params))
            self._listener = Listener(self._callback, xpl, params)

        def get_listener(self):
            """ getter for lsitener object
            """
開發者ID:anuraagkapoor,項目名稱:domogik,代碼行數:70,代碼來源:xplgw.py

示例2: print

# 需要導入模塊: from domogik.common.database import DbHelper [as 別名]
# 或者: from domogik.common.database.DbHelper import close_session [as 別名]
                print("")
                print("WARNING:")
                print("By typing YES below this will start the upgrade process, after the process")
                print("the upgraded stats keys will be DELETED from the core_device_stats sql tabel.")
                print("This process can not be reversed, it is advised to make a backup of your")
                print("datatabse before starting this process")
                print("")
                conf = ""
                while conf not in ["YES I AM SURE", "no"]:
                    conf = raw_input("Type 'YES I AM SURE' to confirm, 'no' to cancel: ")
                if conf == "YES I AM SURE":
                    print("Starting the upgrade")
                    print ""
                else:
                    print("Upgrade CANCELED")

        else:
            do = False
        # close all
        db.close_session()
        if do:
            db.open_session()
            old_devs = corellateOld(db.upgrade_list_old())

    # - print done
    print("")
    print("Hooray, all old devices have been uprgaded")

    # - Disconnect the db
    del(db)
開發者ID:altenide,項目名稱:domogik,代碼行數:32,代碼來源:statsUpgrade.py


注:本文中的domogik.common.database.DbHelper.close_session方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。