当前位置: 首页>>代码示例>>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;未经允许,请勿转载。