當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。