class ProfileDoc(BaseDocument): def __init__(self, app, **atts): BaseDocument.__init__(self, app, **atts) self.profile = Profile(self.conn) def set_profile(self, profile): self.clear_body() self.profile.set_profile(profile) title = SimpleTitleElement('Profile: %s' % profile, bgcolor='IndianRed', width='100%') self.body.appendChild(title) rows = self.profile.get_trait_rows() ptitle = Anchor('edit.traits.%s' % self.profile.current.profile, 'Traits') self.body.appendChild(SectionTitle(ptitle)) #self.body.appendChild(SectionTitle('Traits')) if len(rows): self.body.appendChild(TraitTable(rows, bgcolor='IndianRed1')) vtitle = Anchor('edit.variables.%s' % self.profile.current.profile, 'Variables') self.body.appendChild(SectionTitle(vtitle)) erows = self.profile._env.get_rows() if len(erows): self.body.appendChild(PVarTable(erows, bgcolor='MistyRose2')) etitle = Anchor('edit.families.%s' % self.profile.current.profile, 'Families') self.body.appendChild(SectionTitle(etitle)) families = self.profile.get_families() flist = UnorderedList() for f in families: flist.appendChild(ListItem(f)) self.body.appendChild(flist)
class ProfileDoc(BaseDocument): def __init__(self, app, **atts): BaseDocument.__init__(self, app, **atts) self.profile = Profile(self.conn) def set_profile(self, profile): self.clear_body() self.profile.set_profile(profile) title = SimpleTitleElement('Profile: %s' % profile, bgcolor='IndianRed', width='100%') self.body.appendChild(title) rows = self.profile.get_trait_rows() ptitle = Anchor('edit.traits.%s' % self.profile.current.profile, 'Traits') self.body.appendChild(SectionTitle(ptitle)) #self.body.appendChild(SectionTitle('Traits')) if len(rows): self.body.appendChild(TraitTable(rows, bgcolor='IndianRed1')) vtitle = Anchor('edit.variables.%s' % self.profile.current.profile, 'Variables') self.body.appendChild(SectionTitle(vtitle)) erows = self.profile._env.get_rows() if len(erows): self.body.appendChild(PVarTable(erows, bgcolor='MistyRose2')) etitle = Anchor('edit.families.%s' % self.profile.current.profile, 'Families') self.body.appendChild(SectionTitle(etitle)) families = self.profile.get_families() flist = UnorderedList() for f in families: flist.appendChild(ListItem(f)) self.body.appendChild(flist)
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)
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)