def on_left_doubleclicked(self, it, idx): self.select = it self.current_obj = self.make_path(it) if len(self.current_obj.split('.')) == 1: db = self.current_obj self.cbo_sql.setCurrentText('SHOW TABLES FROM `%s`' % db) tbls = chk_data(self.dbm.tables(self.conf, db), self.mw.statusbar) self.add_tables(tbls.split('\t')) elif len(self.current_obj.split('.')) == 2: db, tbl = self.current_obj.split('.') self.cbo_sql.setCurrentText('SELECT * FROM %s ORDER BY 1 DESC LIMIT 0,20' % tbl) cols = chk_data(self.dbm.columns(self.conf, tbl, db), self.mw.statusbar) self.add_columns(cols.split('\t'))
def get_database(self): # clean tree view self.leftView.clear() self.reset_right_view() # TODO: multi db host config # conf_list = self.conf.split('\n\n') dbs = chk_data(self.dbm.database(self.conf), self.mw.statusbar) if dbs: for db in dbs.split('\t'): if db: self.add_item_left(db, 'database')
def get_script_path(self): self.mw.statusbar.showMessage('Get server info...') info = chk_data(self.shell.getinfo(), self.mw.statusbar) if info: self.mw.statusbar.showMessage('Get server info OK :)') self.webRoot, disk, _ = info.split('\t') self.os = 'lnx' if self.webRoot.startswith('/') else 'win' self.sep = '/' if self.os is 'lnx' else '\\' inf = ' '.join(('[ ', disk, _, ' ]')) self.banner = '\n'.join((self.banner, inf)) if self.banner else inf if not self.cmd_path: self.cmd_path = 'sh' if self.os is 'lnx' else 'cmd'
def on_execute_clicked(self): print(self.current_obj) sql = self.cbo_sql.currentText() data = chk_data(self.dbm.execute(self.conf, sql, self.current_obj.split('.')[0]), self.mw.statusbar) self.add_item_right(data)
def execute(self, cmd): ret = chk_data(self.shell.execute(self.cmd_path, cmd), self.mw.statusbar) self.appendPlainText(ret) return