def on_connect(self, event=None): log.debug('User clicked the authentication button. Validating ' 'creditentials...') userid = self._userid.text() password = self._password.text() valid = self._callback(userid, password) conf.set(['accounts', 'default', 'userid'], str(userid)) conf.set(['accounts', 'default', 'pass'], str(password)) if valid: log.info('Valid userid and password. Connected.') self._save_geometry() self.hide() else: log.info('Invalid userid or password. Asking authentication again.') dialog = QtGui.QMessageBox.critical(self, # 'Login failed' dialog title. _('Connot connect.'), # 'Login failed' dialog content. _('Invalid userid or password. Try again.'))
def on_connect(self, event=None): log.debug("User clicked the authentication button. Validating " "creditentials...") userid = self._userid.text() password = self._password.text() valid = self._callback(userid, password) conf.set(["accounts", "default", "userid"], str(userid)) conf.set(["accounts", "default", "pass"], str(password)) if valid: log.info("Valid userid and password. Connected.") self._save_geometry() self.hide() else: log.info("Invalid userid or password. Asking authentication again.") dialog = QtGui.QMessageBox.critical( self, # 'Login failed' dialog title. _("Connot connect."), # 'Login failed' dialog content. _("Invalid userid or password. Try again."), )
from wididitclient.utils import log def get_fd(mode='w+'): global _path open(_path, 'a') # Create the file return open(_path, mode) def save(): global _conf conf = json.dumps(_conf, sort_keys=True, indent=4) with get_fd() as file: file.write(conf) _path = os.path.expanduser('~/.config/wididit-client.json') if not os.path.isfile(_path): log.info('Creating new configuration file.') with get_fd() as file: file.write('{}') try: with get_fd('r') as file: _conf = json.load(file) except Exception as e: log.error('Configuration could not be parsed. Creating backup and ' 'creating new file.') os.rename(_path, _path + '.bak') with get_fd() as file: file.write('{}') _conf = {} _lock = Lock()
def get_fd(mode='w+'): global _path open(_path, 'a') # Create the file return open(_path, mode) def save(): global _conf conf = json.dumps(_conf, sort_keys=True, indent=4) with get_fd() as file: file.write(conf) _path = os.path.expanduser('~/.config/wididit-client.json') if not os.path.isfile(_path): log.info('Creating new configuration file.') with get_fd() as file: file.write('{}') try: with get_fd('r') as file: _conf = json.load(file) except Exception as e: log.error('Configuration could not be parsed. Creating backup and ' 'creating new file.') os.rename(_path, _path + '.bak') with get_fd() as file: file.write('{}') _conf = {} _lock = Lock()