def query_users(self): r = [] for l in self.query('USE mysql; SELECT * FROM user;'): u = User() u.host, u.name = l.split('\t')[:2] r.append(u) return r
def query_users(self): r = [] for l in self.query("USE mysql; SELECT * FROM user;"): u = User() u.host, u.name = l.split("\t")[:2] r.append(u) return r
def query_users(self): r = [] for l in self.query('\\du'): u = User() u.host, u.name = '', l.split('|')[0] r.append(u) return r
def on_grant(self): for db_cfg in self.config['databases']: db = Database() db.name = db_cfg['name'] for user_cfg in self.config['users']: user = User() user.name = user_cfg['name'] user.password = user_cfg['password'] user.host = '%' self.db.query_grant(user, db) self.context.notify('info', _('Permissions granted.'))
def on_delete_user(self, user_cfg): user = User() user.name = user_cfg['name'] user.host = '%' try: self.db.query_drop_user(user) except Exception, e: if not 'ERROR 1008' in e: self.context.notify('error', str(e)) return
def on_delete_user(self, user_cfg): user = User() user.name = user_cfg["name"] user.host = "%" try: self.db.query_drop_user(user) except Exception, e: if not "ERROR 1008" in e: self.context.notify("error", str(e)) return
def on_grant(self): for db_cfg in self.config["databases"]: db = Database() db.name = db_cfg["name"] for user_cfg in self.config["users"]: user = User() user.name = user_cfg["name"] user.password = user_cfg["password"] user.host = "%" self.db.query_grant(user, db) self.context.notify("info", _("Permissions granted."))
self.config['name'] = dbname self.config['username'] = username self.config['password'] = str(uuid.uuid4()) try: self.db.query_create(self.config['name']) except Exception, e: self.context.notify('error', str(e)) return self.config['created'] = True db = Database() db.name = self.config['name'] user = User() user.name = self.config['username'] user.password = self.config['password'] user.host = 'localhost' try: self.db.query_create_user(user) except Exception, e: self.db.query_drop(db) self.context.notify('error', str(e)) return self.db.query_grant(user, db) self.refresh() @on('delete', 'click') def on_delete(self):
user = User() user.name = self.config['username'] user.password = self.config['password'] user.host = 'localhost' self.db.query_create_user(user) self.db.query_grant(user, db) self.refresh() @on('delete', 'click') def on_delete(self): db = Database() db.name = self.config['name'] try: self.db.query_drop(db) except Exception, e: # I'm gonna burn in hell for this... if not 'ERROR 1008' in e: raise e user = User() user.name = self.config['username'] user.host = 'localhost' try: self.db.query_drop_user(user) except Exception, e: if not 'ERROR 1008' in e: raise e self.config['created'] = False self.refresh()
username = self.find('db-username').value password = self.find('db-password').value for user in self.db.query_users(): if user.name == username: self.context.notify('error', _('This username is already used')) return user_cfg = { 'name': username, 'password': password, } user = User() user.name = user_cfg['name'] user.password = user_cfg['password'] user.host = '%' try: self.db.query_create_user(user) except Exception, e: self.context.notify('error', str(e)) return self.config['users'].append(user_cfg) self.on_grant() self.refresh() self.try_save()
self.context.notify('error', str(e)) self.context.launch('configure-plugin', plugin=self.db) return username = self.find('db-username').value for user in self.db.query_users(): if user.name == username: self.context.notify('error', _('This username is already used')) return user_cfg = { 'name': username, 'password': str(uuid.uuid4()), } user = User() user.name = user_cfg['name'] user.password = user_cfg['password'] user.host = '%' try: self.db.query_create_user(user) except Exception, e: self.context.notify('error', str(e)) return self.config['users'].append(user_cfg) self.on_grant() self.refresh() self.try_save()
except Exception, e: self.context.notify("error", str(e)) self.context.launch("configure-plugin", plugin=self.db) return username = self.find("db-username").value password = self.find("db-password").value for user in self.db.query_users(): if user.name == username: self.context.notify("error", _("This username is already used")) return user_cfg = {"name": username, "password": password} user = User() user.name = user_cfg["name"] user.password = user_cfg["password"] user.host = "%" try: self.db.query_create_user(user) except Exception, e: self.context.notify("error", str(e)) return self.config["users"].append(user_cfg) self.on_grant() self.refresh() self.try_save()