def create_entry(self, *args): var = dict(self.editor.dialogs['create'].items()) debug('var is %s' % var) self.environ[self.trait][var['name']] = var['value'] tagname = ujoin(self.trait, var['name']) self.editor.make_tag(tagname) self.editor.destroy_dialog(self.editor.dialogs['create'])
def set_source(self, line): debug(line) line = line.strip().split() debug('split', line) self.type, self.uri, self.suite = line[:3] self.sections = line[3:] self.set_path()
def check_and_get_file(rpath, lpath, md5, quick): package = os.path.basename(lpath) result = check_file(lpath, md5, quick=quick) if result != 'ok': get_file(rpath, lpath, result) else: debug(result, '\t\t', package)
def parse_section(self, name, type, section=None): listfile = self.listfile(name, type, section) debug(listfile) if not isfile(listfile): raise NoFileError, 'file not there' if type == 'deb': return full_parse(listfile) elif type == 'deb-src': return parse_sources(listfile) else: raise Error, 'bad source type'
def parse_section(self, section=None): listfile = self._listfile_(section) debug(listfile) if not isfile(listfile): raise NoFileError, 'file not there' if self.source.type == 'deb': return parse_packages(listfile) elif self.source.type == 'deb-src': return parse_sources(listfile) else: raise Error, 'bad source type'
def create_profile(self, button): name = button.get_name() debug(name) if name == 'create': profile = self.dialogs[name].get() if profile not in [p.profile for p in self.profiles.select()]: self.profiles.insert(data={'profile' : profile, 'suite' : 'woody'}) self.destroy_dialog(self.dialogs[name]) self.browser.reset_rows() else: dialogs.Dialog('there was a problem')
def create_trait(self, button): name = button.get_name() debug(name) if name == 'create': trait = self.dialogs[name].get() try: self.browser.trait.create_trait(trait) except ExistsError: dialogs.Message('trait %s already exists' % trait) self.browser.traits.insert(data=insert_data) self.destroy_dialog(self.dialogs['create']) self.browser.reset_rows()
def check_file(path, md5_, quick=False): package = os.path.basename(path) if isfile(path): if not quick: debug('checking ', package) if md5sum(path) == md5_: return 'ok' else: print package, md5_, md5sum(path) return 'corrupt' else: return 'ok' else: return 'gone'
def create_profile(self, button): name = button.get_name() debug(name) if name == 'create': profile = self.dialogs[name].get() if profile not in [p.profile for p in self.profiles.select()]: self.profiles.insert(data={ 'profile': profile, 'suite': 'woody' }) self.destroy_dialog(self.dialogs[name]) self.browser.reset_rows() else: dialogs.Dialog('there was a problem')
def insert_trait(self, path, suite=None): #tar = TraitTarFile(path) #trait = tar.get_trait() trait = TraitXml(file(join(path, 'trait.xml'))) if suite is not None: trait.suite = suite all = Set([x.trait for x in self._alltraits.select()]) suite_traits = Set([x.trait for x in self._traits.select()]) parents = Set(trait.parents) debug(parents) if not parents.issubset(suite_traits): raise UnbornError, 'Parent Unborn' if trait.name in suite_traits: raise Error, 'trait exists' idata ={'trait' : trait.name} if trait.name not in all: self._alltraits.insert(data=idata) if trait.name not in suite_traits: self._traits.insert(data=idata) lasttrait = self.current_trait self._parents.set_trait(trait.name) self._packages.set_trait(trait.name) self._templates.set_trait(trait.name) self._debconf.set_trait(trait.name) self._scripts.set_trait(trait.name) self._parents.insert_parents(trait.parents) for package, action in trait.packages.items(): self._packages.insert_package(package, action) n = 0 for package, template, data in trait.templates: #print template, data #templatefile = tar.get_template(data['package'], template) templatefile = file(join(path, 'template-%d' % n)) idata = {'template' : template} #print idata idata.update(data) #print idata self._templates.insert_template(idata, templatefile) n += 1 for debconf in trait.debconf.values(): self._debconf.insert(debconf, trait.name) for script in trait.scripts: #scriptfile = tar.get_script(script) scriptfile = file(join(path, 'script-%s' % script)) self._scripts.insert_script(script, scriptfile) environ = TraitEnvironment(self.conn, suite, trait.name) environ.update(trait.environ) self.set_trait(lasttrait)
def insert_trait(self, path, suite=None): #tar = TraitTarFile(path) #trait = tar.get_trait() trait = TraitXml(file(join(path, 'trait.xml'))) if suite is not None: trait.suite = suite all = Set([x.trait for x in self._alltraits.select()]) suite_traits = Set([x.trait for x in self._traits.select()]) parents = Set(trait.parents) debug(parents) if not parents.issubset(suite_traits): raise UnbornError, 'Parent Unborn' if trait.name in suite_traits: raise Error, 'trait exists' idata = {'trait': trait.name} if trait.name not in all: self._alltraits.insert(data=idata) if trait.name not in suite_traits: self._traits.insert(data=idata) lasttrait = self.current_trait self._parents.set_trait(trait.name) self._packages.set_trait(trait.name) self._templates.set_trait(trait.name) self._debconf.set_trait(trait.name) self._scripts.set_trait(trait.name) self._parents.insert_parents(trait.parents) for package, action in trait.packages.items(): self._packages.insert_package(package, action) n = 0 for package, template, data in trait.templates: #print template, data #templatefile = tar.get_template(data['package'], template) templatefile = file(join(path, 'template-%d' % n)) idata = {'template': template} #print idata idata.update(data) #print idata self._templates.insert_template(idata, templatefile) n += 1 for debconf in trait.debconf.values(): self._debconf.insert(debconf, trait.name) for script in trait.scripts: #scriptfile = tar.get_script(script) scriptfile = file(join(path, 'script-%s' % script)) self._scripts.insert_script(script, scriptfile) environ = TraitEnvironment(self.conn, suite, trait.name) environ.update(trait.environ) self.set_trait(lasttrait)
def create_profile(self, button): name = button.get_name() debug(name) if name == 'create': profile = self.dialogs[name].get() self.destroy_dialog(self.dialogs[name]) profiles = [p.profile for p in self.profiles.select()] if profile not in profiles: skel_profile = self.cfg.get('management_gui', 'template_profile') if skel_profile in profiles: p = Profile(self.conn) p.set_profile(skel_profile) p.copy_profile(skel_profile, profile) else: suite = self.cfg.get('management_gui', 'default_profile_suite') self.profiles.insert(data={'profile' : profile, 'suite' : suite}) self.browser.reset_rows() else: dialogs.Dialog('there was a problem')
def create_profile(self, button): name = button.get_name() debug(name) if name == 'create': profile = self.dialogs[name].get() self.destroy_dialog(self.dialogs[name]) profiles = [p.profile for p in self.profiles.select()] if profile not in profiles: skel_profile = self.cfg.get('management_gui', 'template_profile') if skel_profile in profiles: p = Profile(self.conn) p.set_profile(skel_profile) p.copy_profile(skel_profile, profile) else: suite = self.cfg.get('management_gui', 'default_profile_suite') self.profiles.insert(data={ 'profile': profile, 'suite': suite }) self.browser.reset_rows() else: dialogs.Dialog('there was a problem')
def suite_selected(self, button): name = button.get_name() row = self.dialogs[name].get_selected_data()[0] debug(row.suite) self.destroy_dialog(self.dialogs[name]) SuiteManager(self.conn, row.suite)
def destroy_dialog(self, dying): name = dying.get_name() debug(name, 'dying') self.dialogs[name].destroy() self.dialogs[name] = None
def right_click_menu(widget, event, menu): debug('menu popper') if right_click_pressed(event): menu.popup(None, None, None, event.button, event.time)