本文整理汇总了Python中preferences.Preferences.setApiKey方法的典型用法代码示例。如果您正苦于以下问题:Python Preferences.setApiKey方法的具体用法?Python Preferences.setApiKey怎么用?Python Preferences.setApiKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类preferences.Preferences
的用法示例。
在下文中一共展示了Preferences.setApiKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: signInIfNecessary
# 需要导入模块: from preferences import Preferences [as 别名]
# 或者: from preferences.Preferences import setApiKey [as 别名]
def signInIfNecessary(parent=None):
"""Sign into SRS Collector, and return the API key."""
apiKey = Preferences.apiKey()
if not apiKey:
dialog = SignInDialog()
dialog.exec_()
apiKey = dialog.apiKey
if apiKey:
Preferences.setApiKey(apiKey)
return apiKey
示例2: importCards
# 需要导入模块: from preferences import Preferences [as 别名]
# 或者: from preferences.Preferences import setApiKey [as 别名]
def importCards():
"""Import cards from the server."""
apiKey = SignInDialog.signInIfNecessary()
if apiKey:
try:
Importer().run(apiKey)
except UpgradeRequiredException:
showInfo("Please upgrade your copy of the SRS Collector addon.")
except urllib2.HTTPError as e:
if e.code == 401:
Preferences.setApiKey(None)
showInfo("Sign in expired. Please try again.")
else:
showInfo("Unknown network error.")
except urllib2.URLError:
# Generally a DNS error.
showInfo("Network error. Are you online?")