コード例 #1
0
def generate_sources(suite_id, component_id):
    global _sources_query
    from daklib.filewriter import SourcesFileWriter
    from daklib.dbconn import Component, DBConn, OverrideType, Suite
    from daklib.dakmultiprocessing import PROC_STATUS_SUCCESS

    session = DBConn().session()
    dsc_type = session.query(OverrideType).filter_by(overridetype='dsc').one().overridetype_id

    suite = session.query(Suite).get(suite_id)
    component = session.query(Component).get(component_id)

    overridesuite_id = suite.get_overridesuite().suite_id

    writer_args = {
            'archive': suite.archive.path,
            'suite': suite.suite_name,
            'component': component.component_name
    }
    if suite.indices_compression is not None:
        writer_args['compression'] = suite.indices_compression
    writer = SourcesFileWriter(**writer_args)
    output = writer.open()

    # run query and write Sources
    r = session.execute(_sources_query, {"suite": suite_id, "component": component_id, "component_name": component.component_name, "dsc_type": dsc_type, "overridesuite": overridesuite_id})
    for (stanza,) in r:
        print >>output, stanza
        print >>output, ""

    writer.close()

    message = ["generate sources", suite.suite_name, component.component_name]
    session.rollback()
    return (PROC_STATUS_SUCCESS, message)
コード例 #2
0
def generate_sources(suite_id, component_id):
    global _sources_query
    from daklib.filewriter import SourcesFileWriter
    from daklib.dbconn import Component, DBConn, OverrideType, Suite
    from daklib.dakmultiprocessing import PROC_STATUS_SUCCESS

    session = DBConn().session()
    dsc_type = session.query(OverrideType).filter_by(overridetype='dsc').one().overridetype_id

    suite = session.query(Suite).get(suite_id)
    component = session.query(Component).get(component_id)

    overridesuite_id = suite.get_overridesuite().suite_id

    writer_args = {
            'archive': suite.archive.path,
            'suite': suite.suite_name,
            'component': component.component_name
    }
    if suite.indices_compression is not None:
        writer_args['compression'] = suite.indices_compression
    writer = SourcesFileWriter(**writer_args)
    output = writer.open()

    # run query and write Sources
    r = session.execute(_sources_query, {"suite": suite_id, "component": component_id, "component_name": component.component_name, "dsc_type": dsc_type, "overridesuite": overridesuite_id})
    for (stanza,) in r:
        print(stanza, file=output)
        print("", file=output)

    writer.close()

    message = ["generate sources", suite.suite_name, component.component_name]
    session.rollback()
    return (PROC_STATUS_SUCCESS, message)
コード例 #3
0
 def test_writer_test(self):
     tmpdir = tempfile.mkdtemp()
     try:
         dbcfw = BinaryContentsFileWriter(archive=tmpdir,
                                          suite=SUITE,
                                          component=COMPONENT,
                                          architecture=ARCH,
                                          debtype='deb')
         ubcdw = BinaryContentsFileWriter(archive=tmpdir,
                                          suite=SUITE,
                                          component=COMPONENT,
                                          architecture=ARCH,
                                          debtype='udeb')
         scfw = SourceContentsFileWriter(archive=tmpdir,
                                         suite=SUITE,
                                         component=COMPONENT)
         sfw = SourcesFileWriter(archive=tmpdir,
                                 suite=SUITE,
                                 component=COMPONENT)
         dpfw = PackagesFileWriter(archive=tmpdir,
                                   suite=SUITE,
                                   component=COMPONENT,
                                   architecture=ARCH,
                                   debtype='deb')
         upfw = PackagesFileWriter(archive=tmpdir,
                                   suite=SUITE,
                                   component=COMPONENT,
                                   architecture=ARCH,
                                   debtype='udeb')
         tfw = TranslationFileWriter(archive=tmpdir,
                                     suite=SUITE,
                                     component=COMPONENT,
                                     language=LANG)
         file_writers = [
             dbcfw,
             ubcdw,
             scfw,
             sfw,
             dpfw,
             upfw,
             tfw,
         ]
         for writer in file_writers:
             fd = writer.open()
             fd.write('hallo world')
             writer.close()
             # TODO, verify that it created the correct files.
             # (currently we just test it does not crash).
     finally:
         shutil.rmtree(tmpdir)