def family_command(self, menuitem, action): print action families = [x[0] for x in self.pages['families'].get_selected_data()] if action == 'drop': clause = Eq('profile', self.current.profile) & In( 'family', families) self.pfamily.delete(clause=clause)
def _list_scriptnames(self): table = 'scriptnames' clause = In('type', ['both', 'machine']) rows = self.cursor.select(fields=['script'], table=table, clause=clause) return [row.script for row in rows]
def packages(self, traits=None): if traits is None: traits = [self.current_trait] #self.cmd.set_clause([('trait', trait) for trait in traits], join='or') clause = In('trait', traits) rows = self.cmd.select(clause=clause, order='package') self.reset_clause() return rows
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 delete_parents(self, parents=[], family=None): family = self._check_family(family) if not parents: parents = self.parents() if not parents: return table = 'family_parent' clause = Eq('family', family) & In('parent', parents) self.cursor.delete(table=table, clause=clause)
def set_action(self, action, packages, trait=None): if trait is None: trait = self.current_trait clause = Eq('trait', trait) & In('package', packages) if action == 'drop': self.cmd.delete(clause=clause) elif action in ['remove', 'install', 'purge']: self.cmd.set_data({'action': action}) self.cmd.update(clause=clause) else: raise Error, 'bad action in TraitPackage -%s-' % action
def trait_command(self, menuitem, action): traits = self._get_listbox('traits', 'trait') if action == 'drop': clause = In('trait', traits) & Eq('profile', self.current.profile) self.profiletrait.cmd.delete(clause=clause) self.__set_pages(self.current.profile) elif action == 'order': if not self.dialogs['order']: self.dialogs['order'] = dialogs.Entry('enter order', name='order') self.dialogs['order'].set_ok(self.set_order) self.dialogs['order'].set_cancel(self.destroy_dialog)
def remove_client(self, client): profiles, families, traits = self._client_schema(client) disks, mtypes, machines = self._client_mdata(client) cursor = StatementCursor(self.conn) if machines: cursor.delete(table='machines', clause=In('machine', machines)) for mtype in mtypes: cursor.execute("select * from delete_mtype('%s')" % mtype) for disk in disks: cursor.execute("select * from delete_disk('%s')" % disk) 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, machines=None): Element.__init__(self, 'machines') self.conn = conn self.cursor = StatementCursor(self.conn) self.machines = [] if machines is None: machines = self.cursor.select(table='machines', order='machine') else: clause = In('machine', machines) machines = self.cursor.select(table='machines', clause=clause, 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 make_suite(self, suite, apt_ids): if not len(apt_ids): raise RuntimeError, "can't make_suite without apt_ids" self.insert(table='suites', data=dict(suite=suite)) table = 'suite_apt_sources' data = dict(suite=suite) for order in range(len(apt_ids)): data.update(dict(ord=order, apt_id=apt_ids[order])) self.insert(table=table, data=data) self.make_suite_tables(suite=suite) select = self.stmt.select(table='apt_source_packages', fields=['distinct package'], clause=In('apt_id', apt_ids)) table = '%s_packages' % suite insert = 'insert into %s %s' % (table, select) self.execute(insert)
def delete(self, parents=[]): if parents: print parents, 'PARENTS' clause = In('parent', parents) & Eq('trait', self.current_trait) self.cmd.delete(clause=clause) self.reset_clause()