本文整理汇总了Python中config.Configuration.set_login_info方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.set_login_info方法的具体用法?Python Configuration.set_login_info怎么用?Python Configuration.set_login_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config.Configuration
的用法示例。
在下文中一共展示了Configuration.set_login_info方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GeoFoncierAPILogin
# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import set_login_info [as 别名]
class GeoFoncierAPILogin(QDialog, gui_dlg_login):
closed = pyqtSignal()
opened = pyqtSignal()
def __init__(self, parent=None):
super(GeoFoncierAPILogin, self).__init__(parent)
self.setupUi(self)
self.config = Configuration()
self.conn = None
if self.config.user and self.config.pw:
self.userLineEdit.setText(self.config.user)
self.passwordLineEdit.setText(self.config.pw)
self.rememberMeCheckBox.setChecked(True)
self.signInPushButton.clicked.connect(self.sign_in)
def closeEvent(self, event):
self.closed.emit()
def sign_in(self):
self.user = self.userLineEdit.text()
self.pw = self.passwordLineEdit.text()
self.conn = APIClient(user=self.user, pw=self.pw)
if self.rememberMeCheckBox.isChecked():
self.config.set_login_info(self.user, self.pw)
else:
self.config.erase_login_info()
resp = self.conn.get_my_capabilities()
if resp.code != 200:
# Catch the error specified by the API..
tree = ElementTree.fromstring(resp.read())
elt_err = tree.find(r"./erreur")
if elt_err.text:
msg = elt_err.text
else:
# Error returned by the server (all other cases)..
msg = str(resp)
# Then display the error in a message box..
return QMessageBox.warning(self, r"Warning", msg)
tree = ElementTree.fromstring(resp.read())
# On connection success, get user's capability informations..
elt_extract = tree.find(r"./cle_api_rfu/extraction_rfu")
if elt_extract.text == r"oui":
self.conn.extract = True
elt_extract_lim = tree.find(r"./cle_api_rfu/extraction_rfu_limite")
if elt_extract_lim.text is not None:
self.conn.extract_lim = int(elt_extract_lim.text)
elt_update = tree.find(r"./cle_api_rfu/mise_a_jour_rfu")
if elt_update.text == r"oui":
self.conn.update = True
# Then..
self.accept()
self.opened.emit()