def __init__(self, conn, maintable, reltable, pkey, fields): self.menu = make_menu(['insert', 'update', 'done'], self.pkey_command) ListNoteBook.__init__(self) self.conn = conn self.main = StatementCursor(self.conn) self.main.set_table(maintable) self.rel = StatementCursor(self.conn) self.rel.set_table(reltable) self.pkey = pkey self._fields = fields self.fields = [self.pkey] + self._fields self.reset_rows() self.dialogs = {}.fromkeys(['insert', 'update', 'delete']) self.relmenu = make_menu(['insert', 'update', 'delete'], self.relmenu_command)
def initlistView(self): self.cursor = StatementCursor(self.app.conn) table = 'machines' rows = self.cursor.select(table='machine_types') self.listView.addColumn('machine_type') for row in rows: KListViewItem(self.listView, row.machine_type)
def __init__(self, name='Manager'): CommandBoxWindow.__init__(self) self.cfg = PaellaConfig('database') self.dialogs = {}.fromkeys(['dbname', 'suitemanager']) apps = [ 'profiles', 'families', 'suitemanager', 'traitmanager', 'machines', 'traits', 'tdiff', 'sdiff', 'fdiff', 'default_environment', 'clients', 'browser' ] self.workspace = {}.fromkeys(apps) self.add_menu(dbcommands, 'database', self.database_command) self.add_menu(self.workspace.keys(), 'edit', self.edit_command) self.set_size_request(150, 200) self.conn = None self.dbname = None self.dblist = ScrollCList() self.vbox.add(self.dblist) conn = PaellaConnection(self.cfg) cursor = StatementCursor(conn, 'quicky') self.dblist.set_rows(cursor.select(table='pg_database')) cursor.close() conn.close() self.tbar.add_button('profiles', 'profile manager', self.run_tbar) self.tbar.add_button('families', 'family manager', self.run_tbar) self.tbar.add_button('machines', 'machine manager', self.run_tbar) self.tbar.add_button('traits', 'trait manager', self.run_tbar) self.tbar.add_button('tdiff', 'template differ', self.run_tbar) self.tbar.add_button('sdiff', 'script differ', self.run_tbar) self.tbar.add_button('fdiff', 'family differ', self.run_tbar)
def initlistView(self): self.cursor = StatementCursor(self.app.conn) table = 'filesystems' rows = self.cursor.select(table=table) self.listView.addColumn('filesystem') for row in rows: KListViewItem(self.listView, row.filesystem)
def add_mount_to_filesystem(conn, mnt_name, filesystem, ord, partition): cursor = StatementCursor(conn) data = dict(mnt_name=mnt_name, filesystem=filesystem, ord=str(ord), partition=partition) cursor.insert(table='filesystem_mounts', data=data)
def make_a_machine(conn, machine, mtype, profile, fs): cursor = StatementCursor(conn) data = dict(machine=machine, machine_type=mtype, profile=profile, filesystem=fs) cursor.insert(table='machines', data=data)
def __init__(self, conn, table, section, mainfield=None, mainvalue=None, option='name', value='value'): self.conn = conn self.cursor = StatementCursor(self.conn) self.cursor.set_table(table) self._secfield = section bothnone = mainfield is None and mainvalue is None bothset = mainfield and mainvalue if not bothnone and not bothset: raise Error, 'both mainfield and mainvalue need to be set/unset' self._mainclause = None if bothset: self._mainclause = Eq(mainfield, mainvalue) self._fields = [self._secfield, option, value] RawConfigParser.__init__(self) for row in self.cursor.select(fields=self._fields, clause=self._mainclause): if row[0] not in self.sections(): self.add_section(row[0]) self.set(*row)
def __init__(self, conn): object.__init__(self) self.conn = conn self.cursor = StatementCursor(self.conn) self.current = None self.parent = SimpleRelation(self.conn, 'family_parent', 'family') self.env = FamilyEnvironment(self.conn)
def __set_suite_cursors__(self, suite): self.traits = StatementCursor(self.conn, 'traits') self.traits.set_table(ujoin(suite, 'traits')) self.traitparent = TraitParent(self.conn, suite) self.traitpackage = TraitPackage(self.conn, suite) self.traittemplate = TraitTemplate(self.conn, suite) self.family = Family(self.conn)
def dbconnect(self, dbname): self.cfg.change('database') dsn = self.cfg.get_dsn() dsn['dbname'] = dbname self.conn = PaellaConnection(dsn) self.main = StatementCursor(self.conn, 'mainManager') self.dbname = dbname dialogs.Message('connected to database %s' % dbname)
def __init__(self, conn, name='_EnvironmentEditor'): ListNoteBook.__init__(self, name=name) self.conn = conn self.main = StatementCursor(self.conn, name=name) self.append_page(RecordBox({}), 'Environment') self.menu = SimpleMenu() self.delimiters = DELIMITERS['out-arrows'] self.dialogs = {}.fromkeys(['create', 'remove'])
def __init__(self, conn, cfg): self.conn = conn self.cfg = cfg self.cursor = StatementCursor(self.conn) self.http_mirror = 'http://%s' % self.cfg.get('debrepos', 'repos_host') self.local_mirror = 'file:/tmp/paellamirror' self.suite = None self.sources_rows = []
def __init__(self, parent, name='ScriptNameComboBox'): KComboBox.__init__(self, parent, name) self.app = get_application_pointer() self.cursor = StatementCursor(self.app.conn) self.scriptnames = [ row.script for row in self.cursor.select(table='scriptnames') ] self.insertStrList(self.scriptnames)
def __init__(self, conn, maintable, pkey): self.menu = make_menu(['insert', 'update', 'done'], self.pkey_command) ListNoteBook.__init__(self) self.conn = conn self.main = StatementCursor(self.conn) self.main.set_table(maintable) self.pkey = pkey self.dialogs = {}.fromkeys(['insert', 'update', 'delete']) self.relations = {}
def add_new_mount(conn, name, mtpt, fstype, opts, dump='0', pass_='0'): cursor = StatementCursor(conn) data = dict(mnt_name=name, mnt_point=mtpt, fstype=fstype, mnt_opts=opts, dump=dump) data['pass'] = pass_ cursor.insert(table='mounts', data=data)
def __init__(self, parent, type, name='ScriptNameComboBox'): KComboBox.__init__(self, parent, name) self.app = get_application_pointer() self.cursor = StatementCursor(self.app.conn) clause = In('type', ['both', type]) rows = self.cursor.select(table='scriptnames', clause=clause) #self.scriptnames = [row.script for row in self.cursor.select(table='scriptnames')] self.scriptnames = [row.script for row in rows] self.insertStrList(self.scriptnames)
def __init__(self, conn): object.__init__(self) self.conn = conn #self.suites = Suites(conn).list() self.cursor = StatementCursor(self.conn) self.suites = [r.suite for r in self.cursor.select(table='suites')] self.current = None self.parent = SimpleRelation(self.conn, 'family_parent', 'family') self.env = FamilyEnvironment(self.conn)
def __init__(self, conn): StatementCursor.__init__(self, conn) self.conn = conn self.set_table('profiles') self._traits = ProfileTrait(conn) self._env = ProfileEnvironment(conn) self._pfam = StatementCursor(conn) self._pfam.set_table('profile_family') self._fam = Family(conn)
def remove_client(self, client): profiles, families, traits = self._client_schema(client) machines = self._client_mdata(client) cursor = StatementCursor(self.conn) for machine in machines: cursor.execute("select * from delete_machine('%s')" % machine) for profile in profiles: cursor.execute("select * from delete_profile('%s')" % profile) for family in families: cursor.execute("select * from delete_family('%s')" % family)
def __init__(self, conn): Element.__init__(self, 'mounts') self.conn = conn self.cursor = StatementCursor(self.conn) self.cursor.set_table('mounts') self.mounts = [] rows = self.cursor.select(order='mnt_name') for r in rows: self.append_mount(r.mnt_name, r.mnt_point, r.fstype, r.mnt_opts, r.dump, r['pass'])
def __init__(self, conn): CommandBoxWindow.__init__(self) self.conn = conn self.defenv = DefaultEnvironment(self.conn) self.add_menu(['load', 'edit', 'save'], 'main', self.main_menu_selected) self.cursor = StatementCursor(self.conn) self.cursor.set_table('default_environment') self.view = ScrollCList() self.vbox.add(self.view) self.reset_rows()
def __init__(self, conn): Element.__init__(self, 'kernels') self.conn = conn self.cursor = StatementCursor(self.conn) self.kernels = [] kernels = [r.kernel for r in self.cursor.select(table='kernels', order='kernel')] for k in kernels: k_element = KernelElement(k) self.kernels.append(k_element) self.appendChild(k_element)
def __init__(self, conn, cfg): object.__init__(self) self.conn = conn self.cfg = cfg self.cursor = StatementCursor(self.conn) self.target = None self.installer = None self._mounted = None self._bootstrapped = None self.debmirror = self.cfg.get('debrepos', 'http_mirror')
def __init__(self, app, parent, etype='default', name='EnvironmentList'): KListView.__init__(self, parent, name) dbwidget(self, app) self.etype = etype self.environ = ETYPE[self.etype](self.conn) self.cursor = StatementCursor(self.conn) self.cursor.set_table('%s_environment' % self.etype) self.setRootIsDecorated(True) for field in ['section', 'option', 'value']: self.addColumn(field)
def __init__(self, conn): Element.__init__(self, 'profiles') self.conn = conn self.stmt = StatementCursor(self.conn) self.env = ProfileEnvironment(self.conn) self.profiletraits = ProfileTrait(self.conn) self._profiles = {} self._profile = Profile(self.conn) for row in self.stmt.select(table='profiles', order='profile'): self._append_profile(row.profile, row.suite)
def __init__(self, conn): Element.__init__(self, 'filesystems') self.conn = conn self.cursor = StatementCursor(self.conn) filesystems = [r.filesystem for r in self.cursor.select(table='filesystems', order='filesystem')] self.filesystems = [] for filesystem in filesystems: fs_element = FilesystemElement(self.conn, filesystem) self.filesystems.append(fs_element) self.appendChild(fs_element)
def create_database(cfg, default_traits): dsn = cfg.get_dsn() dsn['dbname'] = 'mishmash' conn = QuickConn(dsn) cmd = StatementCursor(conn, 'create_database') for table in cmd.tables(): cmd.execute('drop table %s' % table) start_schema(conn, default_traits) make_suites(conn) cmd.execute(grant_public(cmd.tables())) cmd.execute(grant_public(['current_environment'], 'ALL'))
def __init__(self, conn, logfile=None): BaseChrootInstaller.__init__(self, conn) self.conn = conn self.cursor = StatementCursor(self.conn) self._mounted = None self._installer_ready = False self._base_ready = False if logfile is None: self.set_logfile(logfile) if logfile is False: pass
def __init__(self, conn, filesystem): Element.__init__(self, 'filesystem') self.conn = conn self.cursor = StatementCursor(self.conn) self.cursor.set_table('filesystem_mounts') self.setAttribute('name', filesystem) self.mounts = [] self.filesystem = filesystem clause = Eq('filesystem', filesystem) rows = self.cursor.select(clause=clause, order='mnt_name') for r in rows: self.append_fs_mount(r.mnt_name, r.ord, r.partition, r.size)
def __init__(self, conn, name='ProfileGenWin'): actions = ['create', 'copy', 'export', 'import'] CommandBoxWindow.__init__(self, name=name) self.set_title(name) self.cfg = PaellaConfig() self.conn = conn self.cmd = StatementCursor(conn, name) self.suites = [x.suite for x in self.cmd.select(table='suites')] self.profiles = StatementCursor(conn, 'profiles') self.profiles.set_table('profiles') self.menu_bar = SimpleMenuBar() self.vbox.pack_start(self.menu_bar, 0, 0, 0) self.dialogs = {}.fromkeys(actions) self.add_menu(actions, 'main', self.ask_dialog) self.add_menu(self.suites, 'traits', self.show_traits) self.tbar.add_button('families', 'show all families', self.families_window) self.add_menu(self.suites, 'traitgen', self.show_traitgen) self.browser = ProfileBrowser(self.conn, self.suites) self.vbox.add(self.browser) self.set_size_request(400, 300)