本文整理汇总了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)))
示例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)