Esempio n. 1
0
 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
Esempio n. 2
0
 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
Esempio n. 3
0
 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
Esempio n. 4
0
 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
Esempio n. 5
0
 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.'))
Esempio n. 6
0
    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
Esempio n. 7
0
 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
Esempio n. 8
0
 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.'))
Esempio n. 9
0
    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
Esempio n. 10
0
 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."))
Esempio n. 11
0
        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):
Esempio n. 12
0
        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()
Esempio n. 13
0
        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()
Esempio n. 14
0
            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()
    
Esempio n. 15
0
        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()