def __init__(self, conn): self.conn = conn self.main = StatementCursor(self.conn, 'RepositoryMain') self.repos = StatementCursor(self.conn, 'Repository') self.repos.set_table('repository') self.sources = StatementCursor(self.conn, 'Sources') self.sources.set_table('sources') self.release = ReleaseCursor(self.conn) self.repsections = StatementCursor(self.conn, 'repos_section') self.repsections.set_table('repos_section') self.__init_db__()
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 __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 = Environment(self.conn, 'family_environment', 'family')
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, 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' ] 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 __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.traitdebconf = TraitDebconf(self.conn, suite)
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 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 __init__(self, conn, name, type): self.conn = conn self.manager = RepositoryManager(self.conn) self.sources = StatementCursor(self.conn, 'Sources') self.sources.set_table('sources') self.release = ReleaseCursor(self.conn) self._section_ = PackageListCursor(self.conn) self.set_source(name, type)
def __init__(self, conn, suite, name='TraitsWindow'): self.cmd = StatementCursor(conn, name=name) self.cmd.set_table(ujoin(suite, 'traits')) rows = self.cmd.select() packer = lambda x : rowpacker('trait', x) DragListWindow.__init__(self, '%s traits' % suite, packer, rows, TARGETS.get('trait', suite), name=name) self.set_size_request(400, 300)
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 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 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, conn, name='ProfileGenWin'): actions = ['create', 'copy', 'export', 'import'] CommandBoxWindow.__init__(self, name=name) self.set_title(name) 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.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)
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 = {} for row in self.stmt.select(table='profiles', order='profile'): self._append_profile(row.profile, row.suite)
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 __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 __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, '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 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): Element.__init__(self, 'machines') self.conn = conn self.cursor = StatementCursor(self.conn) self.machines = [] machines = self.cursor.select(table='machines', order='machine') for m in machines: machine_element = MachineElement(m.machine, m.machine_type, m.kernel, m.profile, m.filesystem) self.machines.append(machine_element) self.appendChild(machine_element)
def __init__(self, conn, suite): Element.__init__(self, 'traits') self.conn = conn self.suite = suite self.setAttribute('suite', self.suite) self._traits_ = StatementCursor(self.conn, 'Traits') self._traits_.set_table(ujoin(self.suite, 'traits')) self.traitnames = [row.trait for row in self._traits_.select(order='trait')] for t in self.traitnames: t_element = Element('trait') t_element.setAttribute('name', t) self.appendChild(t_element)
def start_schema(conn): cursor = StatementCursor(conn, 'start_schema') tables, mapping = primary_tables() map(cursor.create_table, tables) priorities_table = mapping['priorities'] insert_list(cursor, priorities_table.name, 'priority', PRIORITIES) insert_list(cursor, 'scriptnames', 'script', SCRIPTS) cursor.execute(grant_public([x.name for x in tables])) cursor.execute(grant_public(['current_environment'], 'ALL')) cursor.execute(grant_public(['partition_workspace'], 'ALL')) cursor.execute(plpgsql_delete_profile) cursor.execute(plpgsql_delete_trait)
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)
def __init__(self, rgb, conn, name='ColorThingyWindow'): CommandBoxWindow.__init__(self, name=name) self.browser = ColorThingy(rgb) self.rgb = rgb self.cmd = StatementCursor(conn, 'themer') self.theme = None self.vbox.add(self.browser) self.tbar.add_button('import', 'import', self.__ask_import__) self.tbar.add_button('insert', 'insert', self.__ask_insert__) self.tbar.add_button('update', 'update', self.__update_theme__) self.tbar.add_button('save', 'save', self.__save_files__) self._insert_box = None self._import_box = None
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, table, pkey=None, fields=[], command_data=dict(new='new entry', edit='edit entry')): ListWin.__init__(self) self.conn = conn self.cursor = StatementCursor(self.conn) self.cursor.set_table(table) self._cdata = command_data self.tbar.add_button('new', self._cdata['new'], self.toolbar_button_pressed) self.tbar.add_button('edit', self._cdata['edit'], self.toolbar_button_pressed) if pkey is None: print get_pkey_info(StatementCursor(conn), table) self._pkey = pkey self.reset_rows() self._fields = fields self.fields = [pkey] + self._fields self.dialogs = {}.fromkeys(self._cdata.keys())
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)