Пример #1
0
 def export_client(self, client):
     cpath, ppath, fpath, tpath = self._cpaths_(client)
     makepaths(cpath)
     profiles, families, traits = self._client_schema(client) 
     disks, mtypes, machines = self._client_mdata(client)
     if not disks:
         disks = None
     if not mtypes:
         mtypes = None
     if not machines:
         machines = None
     element = ClientMachineDatabaseElement(self.conn, disks, mtypes, machines)
     mdbpath = join(cpath, 'machine_database.xml')
     mdfile = file(mdbpath, 'w')
     mdfile.write(element.toprettyxml())
     mdfile.close()
     if profiles:
         makepaths(ppath)
         pp = PaellaProfiles(self.conn)
         for profile in profiles:
             pp.write_profile(profile, ppath)
     if families:
         makepaths(fpath)
         f = Family(self.conn)
         for family in families:
             f.write_family(family, fpath)
     if traits:
         makepaths(tpath)
Пример #2
0
 def export_client(self, client):
     cpath, ppath, fpath, tpath = self._cpaths_(client)
     makepaths(cpath)
     profiles, families, traits = self._client_schema(client)
     disks, mtypes, machines = self._client_mdata(client)
     if not disks:
         disks = None
     if not mtypes:
         mtypes = None
     if not machines:
         machines = None
     element = ClientMachineDatabaseElement(self.conn, disks, mtypes,
                                            machines)
     mdbpath = join(cpath, 'machine_database.xml')
     mdfile = file(mdbpath, 'w')
     mdfile.write(element.toprettyxml())
     mdfile.close()
     if profiles:
         makepaths(ppath)
         pp = PaellaProfiles(self.conn)
         for profile in profiles:
             pp.write_profile(profile, ppath)
     if families:
         makepaths(fpath)
         f = Family(self.conn)
         for family in families:
             f.write_family(family, fpath)
     if traits:
         makepaths(tpath)
Пример #3
0
 def __init__(self):
     object.__init__(self)
     self.cfg = PaellaConfig()
     self.conn = PaellaConnection()
     self.profile = os.environ['PAELLA_PROFILE']
     self.target = os.environ['PAELLA_TARGET']
     self.machine = None
     self.trait = None
     self.suite = get_suite(self.conn, self.profile)
     self.pr = Profile(self.conn)
     self.pr.set_profile(self.profile)
     self.traitlist = self.pr.make_traitlist()
     self.pe = ProfileEnvironment(self.conn, self.profile)
     self.tp = TraitParent(self.conn, self.suite)
     self.fm = Family(self.conn)
     self.tr = Trait(self.conn, self.suite)
     self.families = list(
         self.fm.get_related_families(self.pr.get_families()))
     self._envv = None
     self.default = DefaultEnvironment(self.conn)
     self.installer = TraitInstaller(self.conn, self.suite, self.cfg)
     if os.environ.has_key('PAELLA_MACHINE'):
         self.machine = os.environ['PAELLA_MACHINE']
     if os.environ.has_key('PAELLA_TRAIT'):
         self.set_trait(os.environ['PAELLA_TRAIT'])
Пример #4
0
    def __init__(self, app, parent, name='FamilyList'):
        KListView.__init__(self, parent, name)
        dbwidget(self, app)
        self.family = Family(self.conn)

        self.setRootIsDecorated(True)
        self.addColumn('family')
        self.refreshlistView()
Пример #5
0
 def __init__(self, conn):
     self.menu = make_menu(['delete'], self.modify_family)
     ListNoteBook.__init__(self)
     self.conn = conn
     self.family = Family(self.conn)
     self.var_menu = make_menu(['edit', 'nothing', 'nothing', 'drop'],
                           self.var_menu_selected)
     self.parent_menu = make_menu(['drop'], self.modify_parent)
     self.reset_rows()
     self.append_page(ScrollCList(rcmenu=self.var_menu), 'environment')
     self.append_page(ScrollCList(rcmenu=self.parent_menu), 'parents')
     self.set_size_request(400, 300)
Пример #6
0
 def __init__(self, app, parent):
     SimpleSplitWindow.__init__(self, app, parent, FamilyView,
                                'FamilyMainWindow')
     self.app = app
     self.initActions()
     self.initMenus()
     self.initToolbar()
     self.conn = app.conn
     self.cfg = app.cfg
     self.cursor = StatementCursor(self.conn)
     self.family = Family(self.conn)
     self.refreshListView()
     self.resize(600, 800)
     self.setCaption('paella families')
Пример #7
0
 def import_client(self, client):
     cpath, ppath, fpath, tpath = self._cpaths_(client)
     profiles, families, traits = self._client_schema(client)
     mdbpath = join(cpath, 'machine_database.xml')
     if families:
         f = Family(self.conn)
         f.import_families(fpath)
     if profiles:
         pp = PaellaProcessor(self.conn)
         pp.main_path = cpath
         pp.insert_profiles()
     mh = MachineHandler(self.conn)
     md = mh.parse_xmlfile(mdbpath)
     mh.insert_parsed_element(md)    
Пример #8
0
 def import_client(self, client):
     cpath, ppath, fpath, tpath = self._cpaths_(client)
     profiles, families, traits = self._client_schema(client)
     mdbpath = join(cpath, 'machine_database.xml')
     if families:
         f = Family(self.conn)
         f.import_families(fpath)
     if profiles:
         pp = PaellaProcessor(self.conn)
         pp.main_path = cpath
         pp.insert_profiles()
     mh = MachineHandler(self.conn)
     md = mh.parse_xmlfile(mdbpath)
     mh.insert_parsed_element(md)
Пример #9
0
 def __init__(self, conn, name='FamilyDiffer'):
     VBox.__init__(self)
     self.set_name(name)
     self.conn = conn
     self.view = TwinScrollCList(name=name)
     self.cursor = StatementCursor(self.conn)
     self.lfamily = Family(self.conn)
     self.rfamily = Family(self.conn)
     self.add(self.view)
     self.udbar = UDBar()
     self.pack_end(self.udbar, 0, 0, 0)
     self.show()
     self.udbar.ubutton.connect('clicked', self.update_pressed)
     self.udbar.dbutton.connect('clicked', self.diff_selection)
Пример #10
0
class FamilyDiffer(VBox):
    def __init__(self, conn, name='FamilyDiffer'):
        VBox.__init__(self)
        self.set_name(name)
        self.conn = conn
        self.view = TwinScrollCList(name=name)
        self.cursor = StatementCursor(self.conn)
        self.lfamily = Family(self.conn)
        self.rfamily = Family(self.conn)
        self.add(self.view)
        self.udbar = UDBar()
        self.pack_end(self.udbar, 0, 0, 0)
        self.show()
        self.udbar.ubutton.connect('clicked', self.update_pressed)
        self.udbar.dbutton.connect('clicked', self.diff_selection)

    def update_pressed(self, button):
        self.update_lists()

    def update_lists(self):
        rows = self.lfamily.family_rows()
        self.view.lbox.set_rows(rows)
        self.view.rbox.set_rows(rows)

    def diff_selection(self, *args):
        lrow = self.view.lbox.get_selected_data()[0]
        rrow = self.view.rbox.get_selected_data()[0]
        lfam, rfam = lrow.family, rrow.family
        lcfg = FamilyVariablesConfig(self.conn, lfam)
        rcfg = FamilyVariablesConfig(self.conn, rfam)
        lcfg.diff(rcfg)
Пример #11
0
class FamilyDiffer(VBox):
    def __init__(self, conn, name='FamilyDiffer'):
        VBox.__init__(self)
        self.set_name(name)
        self.conn = conn
        self.view = TwinScrollCList(name=name)
        self.cursor = StatementCursor(self.conn)
        self.lfamily = Family(self.conn)
        self.rfamily = Family(self.conn)
        self.add(self.view)
        self.udbar = UDBar()
        self.pack_end(self.udbar, 0, 0, 0)
        self.show()
        self.udbar.ubutton.connect('clicked', self.update_pressed)
        self.udbar.dbutton.connect('clicked', self.diff_selection)

    def update_pressed(self, button):
        self.update_lists()

    def update_lists(self):
        rows = self.lfamily.family_rows()
        self.view.lbox.set_rows(rows)
        self.view.rbox.set_rows(rows)

    def diff_selection(self, *args):
        lrow = self.view.lbox.get_selected_data()[0]
        rrow = self.view.rbox.get_selected_data()[0]
        lfam, rfam = lrow.family, rrow.family
        lcfg = FamilyVariablesConfig(self.conn, lfam)
        rcfg = FamilyVariablesConfig(self.conn, rfam)
        lcfg.diff(rcfg)
Пример #12
0
 def __init__(self, app, parent, name='FamilyList'):
     KListView.__init__(self, parent, name)
     dbwidget(self, app)
     self.family = Family(self.conn)
     
     self.setRootIsDecorated(True)
     self.addColumn('family')
     self.refreshlistView()
Пример #13
0
 def __init__(self, conn):
     self.menu = make_menu(['delete'], self.modify_family)
     ListNoteBook.__init__(self)
     self.conn = conn
     self.family = Family(self.conn)
     self.var_menu = make_menu(['edit', 'nothing', 'nothing', 'drop'],
                           self.var_menu_selected)
     self.parent_menu = make_menu(['drop'], self.modify_parent)
     self.reset_rows()
     self.append_page(ScrollCList(rcmenu=self.var_menu), 'environment')
     self.append_page(ScrollCList(rcmenu=self.parent_menu), 'parents')
     self.set_size_request(400, 300)
Пример #14
0
 def __init__(self, app, parent):
     SimpleSplitWindow.__init__(self, app, parent, FamilyView, 'FamilyMainWindow')
     self.app = app
     self.initActions()
     self.initMenus()
     self.initToolbar()
     self.conn = app.conn
     self.cfg = app.cfg
     self.cursor = StatementCursor(self.conn)
     self.family = Family(self.conn)
     self.refreshListView()
     self.resize(600, 800)
     self.setCaption('paella families')
Пример #15
0
class FamilyDoc(BaseDocument):
    def __init__(self, app, **atts):
        BaseDocument.__init__(self, app, **atts)
        self.family = Family(self.conn)
        
    def set_family(self, family):
        self.family.set_family(family)
        parents = self.family.parents()
        erows = self.family.environment_rows()
        self.clear_body()
        title = SimpleTitleElement('Family:  %s' % family, bgcolor='IndianRed',
                                   width='100%')
        self.body.appendChild(title)
        self.body.appendChild(SectionTitle('Parents'))
        if len(parents):
            plist = UnorderedList()
            for p in parents:
                plist.appendChild(ListItem(p))
            self.body.appendChild(plist)
        self.body.appendChild(SectionTitle('Variables'))
        if len(erows):
            self.body.appendChild(PVarTable(erows, bgcolor='MistyRose2'))
Пример #16
0
class FamilyDoc(BaseDocument):
    def __init__(self, app, **atts):
        BaseDocument.__init__(self, app, **atts)
        self.family = Family(self.conn)
        
    def set_family(self, family):
        self.family.set_family(family)
        parents = self.family.parents()
        erows = self.family.environment_rows()
        self.clear_body()
        title = SimpleTitleElement('Family:  %s' % family, bgcolor='IndianRed',
                                   width='100%')
        self.body.appendChild(title)
        self.body.appendChild(SectionTitle('Parents'))
        if len(parents):
            plist = UnorderedList()
            for p in parents:
                plist.appendChild(ListItem(p))
            self.body.appendChild(plist)
        self.body.appendChild(SectionTitle('Variables'))
        if len(erows):
            self.body.appendChild(PVarTable(erows, bgcolor='MistyRose2'))
Пример #17
0
 def __init__(self, conn, name='FamilyDiffer'):
     VBox.__init__(self)
     self.set_name(name)
     self.conn = conn
     self.view = TwinScrollCList(name=name)
     self.cursor = StatementCursor(self.conn)
     self.lfamily = Family(self.conn)
     self.rfamily = Family(self.conn)
     self.add(self.view)
     self.udbar = UDBar()
     self.pack_end(self.udbar, 0, 0, 0)
     self.show()
     self.udbar.ubutton.connect('clicked', self.update_pressed)
     self.udbar.dbutton.connect('clicked', self.diff_selection)
Пример #18
0
class FamilyMainWindow(SimpleSplitWindow):
    def __init__(self, app, parent):
        SimpleSplitWindow.__init__(self, app, parent, FamilyView,
                                   'FamilyMainWindow')
        self.app = app
        self.initActions()
        self.initMenus()
        self.initToolbar()
        self.conn = app.conn
        self.cfg = app.cfg
        self.cursor = StatementCursor(self.conn)
        self.family = Family(self.conn)
        self.refreshListView()
        self.resize(600, 800)
        self.setCaption('paella families')

    def initActions(self):
        collection = self.actionCollection()

    def initMenus(self):
        mainMenu = KPopupMenu(self)
        menus = [mainMenu]
        self.menuBar().insertItem('&Main', mainMenu)
        self.menuBar().insertItem('&Help', self.helpMenu(''))

    def initToolbar(self):
        toolbar = self.toolBar()

    def initlistView(self):
        self.listView.setRootIsDecorated(True)
        self.listView.addColumn('group')

    def refreshListView(self):
        for row in self.family.family_rows():
            item = KListViewItem(self.listView, row.family)
            item.family = row.family

    def selectionChanged(self):
        current = self.listView.currentItem()
        if hasattr(current, 'family'):
            self.view.set_family(current.family)
        if hasattr(current, 'trait'):
            print 'trait is', current.trait
            self.view.set_trait(current.trait)
        if hasattr(current, 'suite'):
            print 'suite is', current.suite
            if hasattr(current, 'widget'):
                print 'widget is', current.widget
Пример #19
0
class FamilyMainWindow(SimpleSplitWindow):
    def __init__(self, app, parent):
        SimpleSplitWindow.__init__(self, app, parent, FamilyView, 'FamilyMainWindow')
        self.app = app
        self.initActions()
        self.initMenus()
        self.initToolbar()
        self.conn = app.conn
        self.cfg = app.cfg
        self.cursor = StatementCursor(self.conn)
        self.family = Family(self.conn)
        self.refreshListView()
        self.resize(600, 800)
        self.setCaption('paella families')
        
    def initActions(self):
        collection = self.actionCollection()
        
    def initMenus(self):
        mainMenu = KPopupMenu(self)
        menus = [mainMenu]
        self.menuBar().insertItem('&Main', mainMenu)
        self.menuBar().insertItem('&Help', self.helpMenu(''))

    def initToolbar(self):
        toolbar = self.toolBar()

    def initlistView(self):
        self.listView.setRootIsDecorated(True)
        self.listView.addColumn('group')
        
    def refreshListView(self):
        for row in self.family.family_rows():
            item = KListViewItem(self.listView, row.family)
            item.family = row.family

    def selectionChanged(self):
        current = self.listView.currentItem()
        if hasattr(current, 'family'):
            self.view.set_family(current.family)
        if hasattr(current, 'trait'):
            print 'trait is', current.trait
            self.view.set_trait(current.trait)
        if hasattr(current, 'suite'):
            print 'suite is', current.suite
            if hasattr(current, 'widget'):
                print 'widget is', current.widget
Пример #20
0
 def __init__(self, conn, suites, name='ProfileBrowser'):
     self.menu = self.__make_mainmenu_(suites)
     ListNoteBook.__init__(self, name=name)
     self.conn = conn
     self.profiles = Profile(self.conn)
     self.profiletrait = ProfileTrait(self.conn)
     self.family = Family(self.conn)
     self.pfamily = StatementCursor(self.conn)
     self.pfamily.set_table('profile_family')
     self.trait_menu = make_menu(['drop', 'order'], self.trait_command)
     self.pdata_menu = make_menu(['edit', 'drop'], self.variable_command)
     self.family_menu = make_menu(['drop'], self.family_command)
     self.reset_rows()
     self.append_page(ScrollCList(rcmenu=self.trait_menu), 'traits')
     self.append_page(ScrollCList(rcmenu=self.pdata_menu), 'variables')
     self.append_page(ScrollCList(rcmenu=self.family_menu), 'families')
     self.dialogs = {}.fromkeys(['order'])
Пример #21
0
class FamilyList(KListView):
    def __init__(self, app, parent, name='FamilyList'):
        KListView.__init__(self, parent, name)
        dbwidget(self, app)
        self.family = Family(self.conn)

        self.setRootIsDecorated(True)
        self.addColumn('family')
        self.refreshlistView()

    def refreshlistView(self):
        self.clear()
        rows = self.family.family_rows()
        for row in rows:
            item = KListViewItem(self, row.family)
            item.family = row.family

    def getData(self):
        item = self.currentItem()
        return FamilyVariablesConfig(self.conn, item.family)

    def updateData(self, data):
        pass
Пример #22
0
class FamilyList(KListView):
    def __init__(self, app, parent, name='FamilyList'):
        KListView.__init__(self, parent, name)
        dbwidget(self, app)
        self.family = Family(self.conn)
        
        self.setRootIsDecorated(True)
        self.addColumn('family')
        self.refreshlistView()
        
    def refreshlistView(self):
        self.clear()
        rows = self.family.family_rows()
        for row in rows:
            item = KListViewItem(self, row.family)
            item.family = row.family

    def getData(self):
        item = self.currentItem()
        return FamilyVariablesConfig(self.conn, item.family)
    
    def updateData(self, data):
        pass
Пример #23
0
 def __init__(self):
     object.__init__(self)
     self.cfg = PaellaConfig()
     self.conn = PaellaConnection()
     self.profile = os.environ['PAELLA_PROFILE']
     self.target = os.environ['PAELLA_TARGET']
     self.machine = None
     self.trait = None
     self.suite = get_suite(self.conn, self.profile)
     self.pr = Profile(self.conn)
     self.pr.set_profile(self.profile)
     self.traitlist = self.pr.make_traitlist()
     self.pe = ProfileEnvironment(self.conn, self.profile)
     self.tp = TraitParent(self.conn, self.suite)
     self.fm = Family(self.conn)
     self.tr = Trait(self.conn, self.suite)
     self.families = list(self.fm.get_related_families(self.pr.get_families()))
     self._envv = None
     self.default = DefaultEnvironment(self.conn)
     self.installer = TraitInstaller(self.conn, self.suite, self.cfg)
     if os.environ.has_key('PAELLA_MACHINE'):
         self.machine = os.environ['PAELLA_MACHINE']
     if os.environ.has_key('PAELLA_TRAIT'):
         self.set_trait(os.environ['PAELLA_TRAIT'])
Пример #24
0
class FamilyBrowser(ListNoteBook):
    def __init__(self, conn):
        self.menu = make_menu(['delete'], self.modify_family)
        ListNoteBook.__init__(self)
        self.conn = conn
        self.family = Family(self.conn)
        self.var_menu = make_menu(['edit', 'nothing', 'nothing', 'drop'],
                              self.var_menu_selected)
        self.parent_menu = make_menu(['drop'], self.modify_parent)
        self.reset_rows()
        self.append_page(ScrollCList(rcmenu=self.var_menu), 'environment')
        self.append_page(ScrollCList(rcmenu=self.parent_menu), 'parents')
        self.set_size_request(400, 300)

    def modify_parent(self, menuitem, action):
        if action == 'drop':
            parents = self._get_listbox_col_('parents', 'family')
            self.trait.delete_parents(parents)
            self.__set_pages(self.current_family)

    def modify_family(self, menuitem, action):
        if action == 'delete':
            trait = self.listbox.get_selected_data()[0].family
            self.trait.delete_family(family)
            self.reset_rows()
            
    def reset_rows(self):
        self.set_rows(self.family.family_rows())
        self.set_row_select(self.family_selected)

    def __set_droptargets__(self, pages):
        set_receive_targets(pages['environment'].listbox,
                            self.drop_variable, TARGETS.get('variable', 'flavor'))
        set_receive_targets(pages['parents'].listbox,
                            self.drop_family, TARGETS.get('family', 'flavor'))

    def set_package(self, menu_item, action):
        packages = self._get_listbox_col_('packages', 'package')
        trait = self.current_family
        self.trait.set_action(action, packages)
        self.__set_pages(self.current_trait)

    def var_menu_selected(self, menu_item, action):
        if action == 'edit':
            config = FamilyVariablesConfig(self.conn, self.current_family)
            newconfig = config.edit()
            config.update(newconfig)
            self.select_family(self.current_family)
        elif action == 'drop':
            pages = dict(self.pages)
            listbox = pages['environment'].listbox
            rows = listbox.get_selected_data()
            data = dict(family=self.current_family)
            for row in rows:
                data['trait'] = row.trait
                data['name'] = row.name
                clause = reduce(and_, [Eq(k, v) for k,v in data.items()])
                self.family.env.cursor.delete(clause=clause)
    

    def pop_mymenu(self, widget, event, menu):
        if right_click_pressed(event):
            menu.popup(None, None, None, event.button, event.time)

    def family_selected(self, listbox, row, column, event):
        family = listbox.get_selected_data()[0].family
        self.select_family(family)
        
    def select_family(self, family):
        self.current_family = family
        self.family.set_family(family)
        self.__set_pages(self.current_family)

    def __set_pages(self, family):
        pages = dict(self.pages)
        pages['environment'].set_rows(self.family.environment_rows())
        pages['environment'].set_select_mode('multi')
        pages['parents'].set_rows(self.family.parents(), ['family'])
        pages['parents'].set_select_mode('multi')
        self.__set_droptargets__(pages)

    def drop_family(self, listbox, context, x, y, selection, targettype, time):
        families = Set(selection.data.split('^&^'))
        self.family.insert_parents(families)
        self.__set_pages(self.current_family)

    def drop_variable(self, listbox, context, x, y, selection, targettype, time):
        table = 'family_environment'
        trips = [x.split('<=>') for x in selection.data.split('^&^')]
        rows = [dict(trait=x[0], name=x[1], value=x[2]) for x in trips]
        print rows
        for r in trips:
            clause = Eq('family', self.current_family)
            clause &= Eq('trait', r[0]) & Eq('name', r[1]) 
            trows = self.family.cursor.select(table=table, clause=clause)
            print 'trows', trows
            if len(trows) == 0:
                data = dict(trait=r[0], name=r[1], value=r[2])
                data['family'] = self.current_family
                print 'data', data
                self.family.cursor.insert(table=table, data=data)        
        self.__set_pages(self.current_family)

    def _get_listbox_col_(self, page, field):
        pages = dict(self.pages)
        return [row[field] for row in pages[page].listbox.get_selected_data()]

    def make_families_window(self):
        rows = self.family.family_rows()
        FamiliesWindow(rows)

    def make_variables_window(self):
        rows = self.family.get_all_defaults()
        VariablesWindow(rows)
Пример #25
0
 def __init__(self, app, **atts):
     BaseDocument.__init__(self, app, **atts)
     self.family = Family(self.conn)
Пример #26
0
class FamilyBrowser(ListNoteBook):
    def __init__(self, conn):
        self.menu = make_menu(['delete'], self.modify_family)
        ListNoteBook.__init__(self)
        self.conn = conn
        self.family = Family(self.conn)
        self.var_menu = make_menu(['edit', 'nothing', 'nothing', 'drop'],
                              self.var_menu_selected)
        self.parent_menu = make_menu(['drop'], self.modify_parent)
        self.reset_rows()
        self.append_page(ScrollCList(rcmenu=self.var_menu), 'environment')
        self.append_page(ScrollCList(rcmenu=self.parent_menu), 'parents')
        self.set_size_request(400, 300)

    def modify_parent(self, menuitem, action):
        if action == 'drop':
            parents = self._get_listbox_col_('parents', 'family')
            self.trait.delete_parents(parents)
            self.__set_pages(self.current_family)

    def modify_family(self, menuitem, action):
        if action == 'delete':
            trait = self.listbox.get_selected_data()[0].family
            self.trait.delete_family(family)
            self.reset_rows()
            
    def reset_rows(self):
        self.set_rows(self.family.family_rows())
        self.set_row_select(self.family_selected)

    def __set_droptargets__(self, pages):
        set_receive_targets(pages['environment'].listbox,
                            self.drop_variable, TARGETS.get('variable', 'flavor'))
        set_receive_targets(pages['parents'].listbox,
                            self.drop_family, TARGETS.get('family', 'flavor'))

    def set_package(self, menu_item, action):
        packages = self._get_listbox_col_('packages', 'package')
        trait = self.current_family
        self.trait.set_action(action, packages)
        self.__set_pages(self.current_trait)

    def var_menu_selected(self, menu_item, action):
        if action == 'edit':
            config = FamilyVariablesConfig(self.conn, self.current_family)
            newconfig = config.edit()
            config.update(newconfig)
            self.select_family(self.current_family)
        elif action == 'drop':
            pages = dict(self.pages)
            listbox = pages['environment'].listbox
            rows = listbox.get_selected_data()
            data = dict(family=self.current_family)
            for row in rows:
                data['trait'] = row.trait
                data['name'] = row.name
                clause = reduce(and_, [Eq(k, v) for k,v in data.items()])
                self.family.env.cursor.delete(clause=clause)
    

    def pop_mymenu(self, widget, event, menu):
        if right_click_pressed(event):
            menu.popup(None, None, None, event.button, event.time)

    def family_selected(self, listbox, row, column, event):
        family = listbox.get_selected_data()[0].family
        self.select_family(family)
        
    def select_family(self, family):
        self.current_family = family
        self.family.set_family(family)
        self.__set_pages(self.current_family)

    def __set_pages(self, family):
        pages = dict(self.pages)
        pages['environment'].set_rows(self.family.environment_rows())
        pages['environment'].set_select_mode('multi')
        pages['parents'].set_rows(self.family.parents(), ['family'])
        pages['parents'].set_select_mode('multi')
        self.__set_droptargets__(pages)

    def drop_family(self, listbox, context, x, y, selection, targettype, time):
        families = Set(selection.data.split('^&^'))
        self.family.insert_parents(families)
        self.__set_pages(self.current_family)

    def drop_variable(self, listbox, context, x, y, selection, targettype, time):
        table = 'family_environment'
        trips = [x.split('<=>') for x in selection.data.split('^&^')]
        rows = [dict(trait=x[0], name=x[1], value=x[2]) for x in trips]
        print rows
        for r in trips:
            clause = Eq('family', self.current_family)
            clause &= Eq('trait', r[0]) & Eq('name', r[1]) 
            trows = self.family.cursor.select(table=table, clause=clause)
            print 'trows', trows
            if len(trows) == 0:
                data = dict(trait=r[0], name=r[1], value=r[2])
                data['family'] = self.current_family
                print 'data', data
                self.family.cursor.insert(table=table, data=data)        
        self.__set_pages(self.current_family)

    def _get_listbox_col_(self, page, field):
        pages = dict(self.pages)
        return [row[field] for row in pages[page].listbox.get_selected_data()]

    def make_families_window(self):
        rows = self.family.family_rows()
        FamiliesWindow(rows)

    def make_variables_window(self):
        rows = self.family.get_all_defaults()
        VariablesWindow(rows)
Пример #27
0
 def __init__(self, app, **atts):
     BaseDocument.__init__(self, app, **atts)
     self.family = Family(self.conn)
Пример #28
0
import os

from paella.profile.base import PaellaConnection, PaellaConfig
from paella.profile.trait import Trait
from paella.profile.family import Family
from paella.profile.profile import Profile
from paella.machines.machine import MachineHandler

if __name__ == '__main__':
    cfg = PaellaConfig()
    conn = PaellaConnection()
    t = Trait(conn)
    f = Family(conn)
    p = Profile(conn)
    m = MachineHandler(conn)
Пример #29
0
class InstallerTools(object):
    def __init__(self):
        object.__init__(self)
        self.cfg = PaellaConfig()
        self.conn = PaellaConnection()
        self.profile = os.environ['PAELLA_PROFILE']
        self.target = os.environ['PAELLA_TARGET']
        self.machine = None
        self.trait = None
        self.suite = get_suite(self.conn, self.profile)
        self.pr = Profile(self.conn)
        self.pr.set_profile(self.profile)
        self.traitlist = self.pr.make_traitlist()
        self.pe = ProfileEnvironment(self.conn, self.profile)
        self.tp = TraitParent(self.conn, self.suite)
        self.fm = Family(self.conn)
        self.tr = Trait(self.conn, self.suite)
        self.families = list(
            self.fm.get_related_families(self.pr.get_families()))
        self._envv = None
        self.default = DefaultEnvironment(self.conn)
        self.installer = TraitInstaller(self.conn, self.suite, self.cfg)
        if os.environ.has_key('PAELLA_MACHINE'):
            self.machine = os.environ['PAELLA_MACHINE']
        if os.environ.has_key('PAELLA_TRAIT'):
            self.set_trait(os.environ['PAELLA_TRAIT'])

    def env(self):
        env = RefDict(self.tp.Environment())
        env.update(self.pr.get_family_data())
        env.update(self.pr.get_profile_data())
        return env

    def set_trait(self, trait):
        self.trait = trait
        self.tp.set_trait(trait)
        self.tr.set_trait(trait)
        self.parents = self.tr.parents()
        self._envv = self.env()
        self.installer.set_trait(trait)
        self.packages = self.installer.traitpackage.packages()
        self.templates = self.installer.traittemplate.templates()

    def get(self, key):
        if self._envv is None:
            raise Error, 'need to set trait first'
        return self._envv.dereference(key)

    def install_modules(self, name):
        modules = str2list(self.get(name))
        print 'installing modules', modules, 'to %s/etc/modules' % self.target
        setup_modules(self.target, modules)

    def remove_packages(self, packages=None):
        if packages is None:
            packages = self.packages
        if len(packages):
            if hasattr(packages[0], 'package'):
                packages = [p.package for p in packages]
        package_list = ' '.join(packages)
        command = 'apt-get -y remove %s' % package_list
        self.installer.run('remove', command, proc=True)
Пример #30
0
class InstallerTools(object):
    def __init__(self):
        object.__init__(self)
        self.cfg = PaellaConfig()
        self.conn = PaellaConnection()
        self.profile = os.environ['PAELLA_PROFILE']
        self.target = os.environ['PAELLA_TARGET']
        self.machine = None
        self.trait = None
        self.suite = get_suite(self.conn, self.profile)
        self.pr = Profile(self.conn)
        self.pr.set_profile(self.profile)
        self.traitlist = self.pr.make_traitlist()
        self.pe = ProfileEnvironment(self.conn, self.profile)
        self.tp = TraitParent(self.conn, self.suite)
        self.fm = Family(self.conn)
        self.tr = Trait(self.conn, self.suite)
        self.families = list(self.fm.get_related_families(self.pr.get_families()))
        self._envv = None
        self.default = DefaultEnvironment(self.conn)
        self.installer = TraitInstaller(self.conn, self.suite, self.cfg)
        if os.environ.has_key('PAELLA_MACHINE'):
            self.machine = os.environ['PAELLA_MACHINE']
        if os.environ.has_key('PAELLA_TRAIT'):
            self.set_trait(os.environ['PAELLA_TRAIT'])
            
        
    def env(self):
        env = RefDict(self.tp.Environment())
        env.update(self.pr.get_family_data())
        env.update(self.pr.get_profile_data())
        return env

    def set_trait(self, trait):
        self.trait = trait
        self.tp.set_trait(trait)
        self.tr.set_trait(trait)
        self.parents = self.tr.parents()
        self._envv = self.env()
        self.installer.set_trait(trait)
        self.packages = self.installer.traitpackage.packages()
        self.templates = self.installer.traittemplate.templates()
        
    def get(self, key):
        if self._envv is None:
            raise Error, 'need to set trait first'
        return self._envv.dereference(key)

    def install_modules(self, name):
        modules = str2list(self.get(name))
        print 'installing modules', modules, 'to %s/etc/modules' % self.target
        setup_modules(self.target, modules)

    def remove_packages(self, packages=None):
        if packages is None:
            packages = self.packages
        if len(packages):
            if hasattr(packages[0], 'package'):
                packages = [p.package for p in packages]
        package_list = ' '.join(packages)
        command = 'apt-get -y remove %s' % package_list
        self.installer.run('remove', command, proc=True)