Ejemplo n.º 1
0
class PaellaDatabase(Element):
    def __init__(self, conn, path='/'):
        Element.__init__(self, 'paelladatabase')
        self.conn = conn
        self.stmt = StatementCursor(self.conn)
        self._profile_traits_ = ProfileTrait(self.conn)
        self.path = path
        self.suites = SuitesElement()
        self.appendChild(self.suites)
        for row in self._suite_rows():
            args = map(
                str,
                [row.suite, row.nonus, row.updates, row.local, row.common])
            element = SuiteElement(*args)
            self.suites.appendChild(element)
        self.profiles = PaellaProfiles(self.conn)
        self.family = Family(self.conn)
        suites = [x.suite for x in self._suite_rows()]
        for suite in suites:
            self.appendChild(TraitsElement(self.conn, suite))

    def _suite_rows(self):
        return self.stmt.select(table='suites', order='suite')

    def write(self, filename):
        path = join(self.path, filename)
        xmlfile = file(path, 'w')
        self.writexml(xmlfile, indent='\t', newl='\n', addindent='\t')

    def backup(self, path=None):
        if path is None:
            path = self.path
        if not isdir(path):
            raise Error, '%s not a directory' % path
        dbfile = file(join(path, 'database.xml'), 'w')
        self.writexml(dbfile, indent='\t', newl='\n', addindent='\t')
        dbfile.close()
        self.backup_profiles(path)
        self.backup_families(path)
        suites = [x.suite for x in self._suite_rows()]
        for suite in suites:
            makepaths(join(path, suite))
            trait = Trait(self.conn, suite)
            for t in trait.get_trait_list():
                trait.set_trait(t)
                trait.backup_trait(join(path, suite))

    def backup_profiles(self, path=None):
        profiles_dir = join(path, 'profiles')
        makepaths(profiles_dir)
        self.profiles.export_profiles(profiles_dir)

    def backup_families(self, path=None):
        fpath = join(path, 'families')
        makepaths(fpath)
        self.family.export_families(fpath)
Ejemplo n.º 2
0
class PaellaDatabase(Element):
    def __init__(self, conn, path='/'):
        Element.__init__(self, 'paelladatabase')
        self.conn = conn
        self.stmt = StatementCursor(self.conn)
        self._profile_traits_ = ProfileTrait(self.conn)
        self.path = path
        self.suites = SuitesElement()
        self.appendChild(self.suites)
        for row in self._suite_rows():
            args = map(str, [row.suite, row.nonus, row.updates, row.local, row.common])
            element = SuiteElement(*args)
            self.suites.appendChild(element)
        self.profiles = PaellaProfiles(self.conn)
        self.family = Family(self.conn)
        suites = [x.suite for x in self._suite_rows()]
        for suite in suites:
            self.appendChild(TraitsElement(self.conn, suite))

    def _suite_rows(self):
        return self.stmt.select(table='suites', order='suite')

    def write(self, filename):
        path = join(self.path, filename)
        xmlfile = file(path, 'w')
        self.writexml(xmlfile, indent='\t', newl='\n', addindent='\t')

    def backup(self, path=None):
        if path is None:
            path = self.path
        if not isdir(path):
            raise Error, '%s not a directory' % path
        dbfile = file(join(path, 'database.xml'), 'w')
        self.writexml(dbfile, indent='\t', newl='\n', addindent='\t')
        dbfile.close()
        self.backup_profiles(path)
        self.backup_families(path)
        suites = [x.suite for x in self._suite_rows()]
        for suite in suites:
            makepaths(join(path, suite))
            trait = Trait(self.conn, suite)
            for t in trait.get_trait_list():
                trait.set_trait(t)
                trait.backup_trait(join(path, suite))

    def backup_profiles(self, path=None):
        profiles_dir = join(path, 'profiles')
        makepaths(profiles_dir)
        self.profiles.export_profiles(profiles_dir)

    def backup_families(self, path=None):
        fpath = join(path, 'families')
        makepaths(fpath)
        self.family.export_families(fpath)
Ejemplo n.º 3
0
 def insert_profiles(self):
     path = join(self.main_path, 'profiles')
     print 'path is in insert_profiles', path
     xmlfiles = [join(path, x) for x in os.listdir(path) if x[-4:] == '.xml']
     profiles = PaellaProfiles(self.conn)
     for xmlfile in xmlfiles:
         xml = parse_file(xmlfile)
         elements = xml.getElementsByTagName('profile')
         if len(elements) != 1:
             raise Error, 'bad profile number %s' % len(elements)
         element = elements[0]
         parsed = ProfileParser(element)
         profiles.insert_profile(parsed)
Ejemplo n.º 4
0
 def insert_profiles(self):
     path = os.path.join(self.main_path, "profiles")
     print "path is in insert_profiles", path
     xmlfiles = [os.path.join(path, x) for x in os.listdir(path) if x[-4:] == ".xml"]
     profiles = PaellaProfiles(self.conn)
     for xmlfile in xmlfiles:
         xml = parse_file(xmlfile)
         elements = xml.getElementsByTagName("profile")
         if len(elements) != 1:
             raise Error, "bad profile number %s" % len(elements)
         element = elements[0]
         parsed = ProfileParser(element)
         profiles.insert_profile(parsed)
Ejemplo n.º 5
0
 def insert_profiles(self):
     path = os.path.join(self.main_path, 'profiles')
     print 'path is in insert_profiles', path
     xmlfiles = [os.path.join(path, x) for x in os.listdir(path) if x[-4:] == '.xml']
     profiles = PaellaProfiles(self.conn)
     for xmlfile in xmlfiles:
         xml = parse_file(xmlfile)
         elements = xml.getElementsByTagName('profile')
         if len(elements) != 1:
             raise Error, 'bad profile number %s' % len(elements)
         element = elements[0]
         parsed = ProfileParser(element)
         profiles.insert_profile(parsed)
Ejemplo n.º 6
0
 def __init__(self, conn, path='/'):
     Element.__init__(self, 'paelladatabase')
     self.conn = conn
     self.stmt = StatementCursor(self.conn)
     self._profile_traits_ = ProfileTrait(self.conn)
     self.path = path
     self.aptsources = AptSourceListElement()
     self.appendChild(self.aptsources)
     if 'apt_sources' in self.stmt.tables():
         for row in self.stmt.select(table='apt_sources', order=['apt_id']):
             element = AptSourceElement(row.apt_id, row.uri, row.dist, row.sections,
                                        row.local_path)
             self.aptsources.appendChild(element)
         self.suites = SuitesElement()
         self.appendChild(self.suites)
         for row in self._suite_rows():
             args = map(str, [row.suite, row.nonus, row.updates, row.local, row.common])
             element = SuiteElement(*args)
             for suiteapt in self.stmt.select(table='suite_apt_sources', order=['ord'],
                                              clause=Eq('suite', row.suite)):
                 element.appendChild(SuiteAptElement(row.suite,
                                                     suiteapt.apt_id, str(suiteapt.ord)))
             self.suites.appendChild(element)
     else:
         print 'WARNING, apt_sources table does not exist, backing up anyway'
     self.profiles = PaellaProfiles(self.conn)
     self.family = Family(self.conn)
     suites = [x.suite for x in self._suite_rows()]
     for suite in suites:
         self.appendChild(TraitsElement(self.conn, suite))
Ejemplo n.º 7
0
 def __init__(self, conn, path='/'):
     Element.__init__(self, 'paelladatabase')
     self.conn = conn
     self.stmt = StatementCursor(self.conn)
     self._profile_traits_ = ProfileTrait(self.conn)
     self.path = path
     self.suites = SuitesElement()
     self.appendChild(self.suites)
     for row in self._suite_rows():
         args = map(
             str,
             [row.suite, row.nonus, row.updates, row.local, row.common])
         element = SuiteElement(*args)
         self.suites.appendChild(element)
     self.profiles = PaellaProfiles(self.conn)
     self.family = Family(self.conn)
     suites = [x.suite for x in self._suite_rows()]
     for suite in suites:
         self.appendChild(TraitsElement(self.conn, suite))
Ejemplo n.º 8
0
 def __init__(self, conn, path='/'):
     Element.__init__(self, 'paelladatabase')
     self.conn = conn
     self.stmt = StatementCursor(self.conn)
     self._profile_traits_ = ProfileTrait(self.conn)
     self.path = path
     self.suites = SuitesElement()
     self.appendChild(self.suites)
     for row in self._suite_rows():
         args = map(str, [row.suite, row.nonus, row.updates, row.local, row.common])
         element = SuiteElement(*args)
         self.suites.appendChild(element)
     self.profiles = PaellaProfiles(self.conn)
     self.family = Family(self.conn)
     suites = [x.suite for x in self._suite_rows()]
     for suite in suites:
         self.appendChild(TraitsElement(self.conn, suite))
Ejemplo n.º 9
0
class PaellaDatabase(Element):
    def __init__(self, conn, path='/'):
        Element.__init__(self, 'paelladatabase')
        self.conn = conn
        self.stmt = StatementCursor(self.conn)
        self._profile_traits_ = ProfileTrait(self.conn)
        self.path = path
        self.aptsources = AptSourceListElement()
        self.appendChild(self.aptsources)
        if 'apt_sources' in self.stmt.tables():
            for row in self.stmt.select(table='apt_sources', order=['apt_id']):
                element = AptSourceElement(row.apt_id, row.uri, row.dist, row.sections,
                                           row.local_path)
                self.aptsources.appendChild(element)
            self.suites = SuitesElement()
            self.appendChild(self.suites)
            for row in self._suite_rows():
                args = map(str, [row.suite, row.nonus, row.updates, row.local, row.common])
                element = SuiteElement(*args)
                for suiteapt in self.stmt.select(table='suite_apt_sources', order=['ord'],
                                                 clause=Eq('suite', row.suite)):
                    element.appendChild(SuiteAptElement(row.suite,
                                                        suiteapt.apt_id, str(suiteapt.ord)))
                self.suites.appendChild(element)
        else:
            print 'WARNING, apt_sources table does not exist, backing up anyway'
        self.profiles = PaellaProfiles(self.conn)
        self.family = Family(self.conn)
        suites = [x.suite for x in self._suite_rows()]
        for suite in suites:
            self.appendChild(TraitsElement(self.conn, suite))

    def _suite_rows(self):
        return self.stmt.select(table='suites', order='suite')

    def write(self, filename):
        path = join(self.path, filename)
        xmlfile = file(path, 'w')
        self.writexml(xmlfile, indent='\t', newl='\n', addindent='\t')

    def backup(self, path=None):
        if path is None:
            path = self.path
        if not isdir(path):
            raise Error, '%s not a directory' % path
        dbfile = file(join(path, 'database.xml'), 'w')
        self.writexml(dbfile, indent='\t', newl='\n', addindent='\t')
        dbfile.close()
        self.backup_profiles(path)
        self.backup_families(path)
        suites = [x.suite for x in self._suite_rows()]
        for suite in suites:
            makepaths(join(path, suite))
            trait = Trait(self.conn, suite)
            for t in trait.get_trait_list():
                trait.set_trait(t)
                trait.export_trait(join(path, suite))

    def backup_profiles(self, path=None):
        profiles_dir = join(path, 'profiles')
        makepaths(profiles_dir)
        self.profiles.export_profiles(profiles_dir)

    def backup_families(self, path=None):
        fpath = join(path, 'families')
        makepaths(fpath)
        self.family.export_families(fpath)