当前位置: 首页>>代码示例>>Python>>正文


Python StorageTools.getStorageForPhone方法代码示例

本文整理汇总了Python中yowsup.common.tools.StorageTools.getStorageForPhone方法的典型用法代码示例。如果您正苦于以下问题:Python StorageTools.getStorageForPhone方法的具体用法?Python StorageTools.getStorageForPhone怎么用?Python StorageTools.getStorageForPhone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yowsup.common.tools.StorageTools的用法示例。


在下文中一共展示了StorageTools.getStorageForPhone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load

# 需要导入模块: from yowsup.common.tools import StorageTools [as 别名]
# 或者: from yowsup.common.tools.StorageTools import getStorageForPhone [as 别名]
    def load(self, username):
        """
        :param username:
        :type username:
        :return:
        :rtype:
        """
        config_dir = StorageTools.getStorageForPhone(username)
        logger.debug("Detecting config for username=%s, dir=%s" % (username, config_dir))
        exhausted = []
        for ftype in self.MAP_EXT:
            if len(ftype):
                fname = (self.NAME_FILE_CONFIG + "." + ftype)
            else:
                fname = self.NAME_FILE_CONFIG

            fpath = os.path.join(config_dir, fname)
            logger.debug("Trying %s" % fpath)
            if os.path.isfile(fpath):
                return self.load_path(fpath)

            exhausted.append(fpath)

        logger.error("Could not find a config for username=%s, paths checked: %s" % (username, ":".join(exhausted)))
开发者ID:tgalal,项目名称:yowsup,代码行数:26,代码来源:manager.py

示例2: len

# 需要导入模块: from yowsup.common.tools import StorageTools [as 别名]
# 或者: from yowsup.common.tools.StorageTools import getStorageForPhone [as 别名]
from yowsup_ext.layers.cleverbot.layer import YowCleverBotLayer
from yowsup_ext.layers.store import YowStorageLayer

import sys
import logging

logging.basicConfig(level = logging.DEBUG)
logger = logging.getLogger(__name__)

if __name__ == "__main__":
    if len(sys.argv) < 3:
        print("Usage: run.py username password")
        sys.exit(1)
    credentials = (sys.argv[1], sys.argv[2])
    stackBuilder = YowStackBuilder()
    phoneStorage =  StorageTools.getStorageForPhone(credentials[0])
    stackBuilder.setProp(YowStorageLayer.PROP_DB_PATH, StorageTools.constructPath(phoneStorage, "yowstore.db"))
    stack = stackBuilder\
        .pushDefaultLayers(True)\
        .push(YowStorageLayer)\
        .push(YowCleverBotLayer)\
        .build()

    stack.setCredentials(credentials)
    logger.info("Starting")
    stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))

    try:
        stack.loop(timeout = 0.5, discrete = 0.5)
    except AuthError as e:
        print("Auth Error, reason %s" % e)
开发者ID:jorgehortelano,项目名称:yowlayer-cleverbot,代码行数:33,代码来源:run.py


注:本文中的yowsup.common.tools.StorageTools.getStorageForPhone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。