Example #1
0
 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'])
Example #2
0
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)
Example #3
0
 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()
Example #4
0
 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'
Example #5
0
 def insert_trait(self, path, suite=None):
     #tar = TraitTarFile(path)
     #trait = tar.get_trait()
     trait = self.parse_trait_xml(path, 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 for trait %s, %s" % (trait.name, 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)
     description_path = os.path.join(path, 'description.txt')
     if os.path.isfile(description_path):
         idata['description'] = file(description_path).read()            
     if trait.name not in suite_traits:
         self._traits.insert(data=idata)
     else:
         raise RuntimeError, '%s already there' % trait.name
     lasttrait = self.current_trait
     self._parents.set_trait(trait.name)
     self._packages.set_trait(trait.name)
     self._templates.set_trait(trait.name)
     self._scripts.set_trait(trait.name)
     self._parents.insert_parents(trait.parents)
     for package, action in trait.packages:
         self._packages.insert_package(package, action)
     n = 0
     for template, data in trait.templates:
         #print template, data
         #templatefile = tar.get_template(data['package'], template)
         template_id = template.replace('/', '-slash-')
         template_filename = os.path.join(path, 'template-%s' % template_id)
         if not os.path.exists(template_filename):
             print "in suite %s trait %s" % (suite, trait.name)
             print "exported template %s not converted yet" % template
             template_filename = os.path.join(path, 'template-%d' % n)
         templatefile = file(template_filename)
         idata = {'template' : template}
         #print idata
         idata.update(data)
         #print idata
         self._templates.insert_template(idata, templatefile)
         n += 1
     for script in trait.scripts:
         #scriptfile = tar.get_script(script)
         scriptfile = file(os.path.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)
Example #6
0
 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 RuntimeError, "bad source type"
Example #7
0
 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.destroy_dialog(self.dialogs['create'])
         self.browser.reset_rows()
Example #8
0
 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'
Example #9
0
 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.destroy_dialog(self.dialogs['create'])
         self.browser.reset_rows()
Example #10
0
 def insert_trait(self, path, suite=None):
     #tar = TraitTarFile(path)
     #trait = tar.get_trait()
     trait = self.parse_trait_xml(path, 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 for trait %s, %s" % (trait.name, 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)
     description_path = os.path.join(path, 'description.txt')
     if os.path.isfile(description_path):
         idata['description'] = file(description_path).read()
     if trait.name not in suite_traits:
         self._traits.insert(data=idata)
     else:
         raise RuntimeError, '%s already there' % trait.name
     lasttrait = self.current_trait
     self._parents.set_trait(trait.name)
     self._packages.set_trait(trait.name)
     self._templates.set_trait(trait.name)
     self._scripts.set_trait(trait.name)
     self._parents.insert_parents(trait.parents)
     for package, action in trait.packages:
         self._packages.insert_package(package, action)
     n = 0
     for template, data in trait.templates:
         #print template, data
         #templatefile = tar.get_template(data['package'], template)
         template_id = template.replace('/', '-slash-')
         template_filename = os.path.join(path, 'template-%s' % template_id)
         if not os.path.exists(template_filename):
             print "in suite %s trait %s" % (suite, trait.name)
             print "exported template %s not converted yet" % template
             template_filename = os.path.join(path, 'template-%d' % n)
         templatefile = file(template_filename)
         idata = {'template': template}
         #print idata
         idata.update(data)
         #print idata
         self._templates.insert_template(idata, templatefile)
         n += 1
     for script in trait.scripts:
         #scriptfile = tar.get_script(script)
         scriptfile = file(os.path.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)
Example #11
0
 def _get_packages_file(self, repos):
     if repos.source.has_release():
         repos.update()
     else:
         rpath = os.path.join(repos.source.uri, repos.source.suite, 'Packages.gz')
         # the [5:] slice is to remove file: from local uri
         lpath = os.path.join(repos.local.source.uri, repos.source.suite, 'Packages.gz')[5:]
         if not os.path.isfile(lpath):
             debug('lpath is --->', lpath)
             makepaths(os.path.dirname(lpath))
             debug(rpath, lpath, 'getting now')
             wget(rpath, lpath)
Example #12
0
    def execute(self, query, *args):
        """execute a query.

        This member will return the query in
        the error it raises making it easier to
        debug problems with either the database
        or the code.
        """
        try:
            self.__real_cursor__.execute(query, *args)
        except IntegrityError, error:
            debug('Caught IntegrityError on query', query)
            error.query = query
            raise error
Example #13
0
 def _perform_delete_action(self, context, ident):
     if context == 'package':
         debug(context, ident)
         #package, action = ident.split('|')
         package = ident
         # right now we delete all actions with the package
         action = None
         debug('delete package', package, action)
         self.doc.trait.delete_package(package, action)
         self.resetView()
     elif context == 'template':
         debug(context, ident)
         ans = KMessageBox.questionYesNo(self,
                                         "%s: really delete this template?" % ident)
         if ans == KMessageBox.Yes:
             template = ident
             self.doc.trait.delete_template(template)
             self.resetView()
     elif context == 'script':
         debug(context, ident)
         ans = KMessageBox.questionYesNo(self,
                                         "Really delete the %s script?" % ident)
         if ans == KMessageBox.Yes:
             self.doc.trait.delete_script(ident)
             self.resetView()
     else:
         raise RuntimeError , '%s context not implemented' % context
Example #14
0
 def _perform_delete_action(self, context, ident):
     if context == 'package':
         debug(context, ident)
         #package, action = ident.split('|')
         package = ident
         # right now we delete all actions with the package
         action = None
         debug('delete package', package, action)
         self.doc.trait.delete_package(package, action)
         self.resetView()
     elif context == 'template':
         debug(context, ident)
         ans = KMessageBox.questionYesNo(self,
                                         "%s: really delete this template?" % ident)
         if ans == KMessageBox.Yes:
             template = self._convert_template_id(ident)
             self.doc.trait.delete_template(template)
             self.resetView()
     elif context == 'script':
         debug(context, ident)
         ans = KMessageBox.questionYesNo(self,
                                         "Really delete the %s script?" % ident)
         if ans == KMessageBox.Yes:
             self.doc.trait.delete_script(ident)
             self.resetView()
     else:
         raise RuntimeError , '%s context not implemented' % context
Example #15
0
 def _get_packages_file(self, repos):
     if repos.source.has_release():
         repos.update()
     else:
         rpath = os.path.join(repos.source.uri, repos.source.suite,
                              'Packages.gz')
         # the [5:] slice is to remove file: from local uri
         lpath = os.path.join(repos.local.source.uri, repos.source.suite,
                              'Packages.gz')[5:]
         if not os.path.isfile(lpath):
             debug('lpath is --->', lpath)
             makepaths(os.path.dirname(lpath))
             debug(rpath, lpath, 'getting now')
             wget(rpath, lpath)
Example #16
0
 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)
Example #17
0
 def _perform_edit_action(self, context, ident):
     if context == 'templates':
         if self._current_tarball is None:
             self.selectSystemTarballDialog()
         else:
             msg = 'use %s as the current tarball?' % self._current_tarball
             yesno = KMessageBox.questionYesNo(self, msg)
             if yesno == KMessageBox.Yes:
                 self.selectWithinSystemTarballDialog(self._current_tarball)
             else:
                 self._current_tarball = None
                 self.selectSystemTarballDialog()
     elif context == 'packages':
         raise RuntimeError, 'packages not implemented yet'
     elif context == 'script':
         self.doc.trait.edit_script(ident)
     elif context == 'parents':
         win = ParentAssigner(self, ident, self.doc.suite)
         win.connect(win, SIGNAL('okClicked()'), self.resetView)
         win.show()
     elif context == 'variables':
         #KMessageBox.information(self, 'edit variables')
         debug('edit variables', ident)
         win = TraitVariablesWindow(self, self.doc.suite, ident)
         win.show()
     elif context == 'template':
         template = ident
         self.doc.trait.edit_template(template)
     elif context == 'templatedata':
         template = ident
         row = self.doc.trait.get_template_row(template)
         data = {}
         fields = ['template', 'owner', 'grp_owner', 'mode']
         for f in fields:
             data[f] = row[f]
         win = BaseRecordDialog(self, fields, record=data)
         win.template = template
         win.connect(win, SIGNAL('okClicked()'),
                     self.slotUpdateTemplateData)
         win.show()
         self._dialog = win
     elif context == 'description':
         #KMessageBox.information(self, 'edit description for %s' % ident)
         win = TraitDescriptionWindow(self, ident, self.doc.suite)
         win.show()
     else:
         raise MethodNotImplementedError(self,
                                         'TraitView._perform_edit_action')
Example #18
0
 def _perform_edit_action(self, context, ident):
     if context == 'templates':
         if self._current_tarball is None:
             self.selectSystemTarballDialog()
         else:
             msg = 'use %s as the current tarball?' % self._current_tarball
             yesno = KMessageBox.questionYesNo(self, msg)
             if yesno == KMessageBox.Yes:
                 self.selectWithinSystemTarballDialog(self._current_tarball)
             else:
                 self._current_tarball = None
                 self.selectSystemTarballDialog()
     elif context == 'packages':
         raise RuntimeError , 'packages not implemented yet'
     elif context == 'script':
         self.doc.trait.edit_script(ident)
     elif context == 'parents':
         win = ParentAssigner(self, ident, self.doc.suite)
         win.connect(win, SIGNAL('okClicked()'), self.resetView)
         win.show()
     elif context == 'variables':
         #KMessageBox.information(self, 'edit variables')
         debug('edit variables', ident)
         win = TraitVariablesWindow(self, self.doc.suite, ident)
         win.show()
     elif context == 'template':
         template = ident
         self.doc.trait.edit_template(template)
     elif context == 'templatedata':
         template = ident
         row = self.doc.trait.get_template_row(template)
         data = {}
         fields = ['template', 'owner', 'grp_owner', 'mode']
         for f in fields:
             data[f] = row[f]
         win = BaseRecordDialog(self, fields, record=data)
         win.template = template
         win.connect(win, SIGNAL('okClicked()'), self.slotUpdateTemplateData)
         win.show()
         self._dialog = win
     elif context == 'description':
         #KMessageBox.information(self, 'edit description for %s' % ident)
         win = TraitDescriptionWindow(self, ident, self.doc.suite)
         win.show()
     else:
         raise MethodNotImplementedError(self, 'TraitView._perform_edit_action')
Example #19
0
def check_file(path, md5_, quick=False):
    """This function will check a file with a
    given md5sum.  It can also be used to
    just check existence.
    """
    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'
Example #20
0
def check_file(filename, md5_, quick=False):
    """This function will check a file with a
    given md5sum.  It can also be used to
    just check existence.
    """
    filename = path(filename)
    package = filename.basename()
    if filename.isfile():
        if not quick:
            debug('checking ', package)
            if md5sum(filename) == md5_:
                return 'ok'
            else:
                print package, md5_, md5sum(filename)
                return 'corrupt'
        else:
            return 'ok'
    else:
        return 'gone'
Example #21
0
 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')
Example #22
0
 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')
Example #23
0
 def _perform_delete_action(self, context, ident):
     if context == 'package':
         debug(context, ident)
         #package, action = ident.split('|')
         package = ident
         # right now we delete all actions with the package
         action = None
         debug('delete package', package, action)
         self.doc.trait.delete_package(package, action)
         self.resetView()
     elif context == 'template':
         debug(context, ident)
         template = self._convert_template_id(ident)
         self.doc.trait.delete_template(template)
         self.resetView()
     else:
         raise RuntimeError, '%s context not implemented' % context
 def _perform_delete_action(self, context, ident):
     if context == 'package':
         debug(context, ident)
         #package, action = ident.split('|')
         package = ident
         # right now we delete all actions with the package
         action = None
         debug('delete package', package, action)
         self.doc.trait.delete_package(package, action)
         self.resetView()
     elif context == 'template':
         debug(context, ident)
         template = self._convert_template_id(ident)
         self.doc.trait.delete_template(template)
         self.resetView()
     else:
         raise RuntimeError, '%s context not implemented' % context
Example #25
0
 def newTemplateSelected(self):
     win = self._dialog
     kurl = win.selectedURL()
     debug('url', str(kurl.url()))
     debug('path in tar is', str(kurl.path()))
     fullpath = str(kurl.path())
     tarball = win.tarball_filename
     if fullpath.startswith(tarball):
         debug('fullpath', fullpath, 'tarball', tarball)
         tpath = fullpath.split(tarball)[1]
         while tpath.startswith('/'):
             tpath = tpath[1:]
         tarfileobj = tarfile.open(tarball)
         self.doc.trait.insert_template_from_tarfile(tpath, tarfileobj)
         self.resetView()
     else:
         raise RuntimeError , '%s does not contain %s' % (fullpath, tarball)
Example #26
0
 def newTemplateSelected(self):
     win = self._dialog
     kurl = win.selectedURL()
     debug('url', str(kurl.url()))
     debug('path in tar is', str(kurl.path()))
     fullpath = str(kurl.path())
     tarball = win.tarball_filename
     if fullpath.startswith(tarball):
         debug('fullpath', fullpath, 'tarball', tarball)
         tpath = fullpath.split(tarball)[1]
         while tpath.startswith('/'):
             tpath = tpath[1:]
         tarfileobj = tarfile.open(tarball)
         self.doc.trait.insert_template_from_tarfile(tpath, tarfileobj)
         self.resetView()
     else:
         raise RuntimeError , '%s does not contain %s' % (fullpath, tarball)
Example #27
0
 def report_package_inserted(self, package):
     debug('package %s inserted' % package)
Example #28
0
 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)
Example #29
0
 def report_package_inserted(self, package):
     debug("package %s inserted" % package)
Example #30
0
 def report_package_inserted(self, package):
     debug('package %s inserted' % package)
Example #31
0
def right_click_menu(widget, event, menu):
    debug('menu popper')
    if right_click_pressed(event):
        menu.popup(None, None, None, event.button, event.time)
Example #32
0
 def destroy_dialog(self, dying):
     name = dying.get_name()
     debug(name, 'dying')
     self.dialogs[name].destroy()
     self.dialogs[name] = None
Example #33
0
 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)