当前位置: 首页>>代码示例>>Python>>正文


Python DBConn.rollback方法代码示例

本文整理汇总了Python中daklib.dbconn.DBConn.rollback方法的典型用法代码示例。如果您正苦于以下问题:Python DBConn.rollback方法的具体用法?Python DBConn.rollback怎么用?Python DBConn.rollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在daklib.dbconn.DBConn的用法示例。


在下文中一共展示了DBConn.rollback方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: acl_export_per_source

# 需要导入模块: from daklib.dbconn import DBConn [as 别名]
# 或者: from daklib.dbconn.DBConn import rollback [as 别名]
def acl_export_per_source(acl_name):
    session = DBConn().session()
    acl = session.query(ACL).filter_by(name=acl_name).one()

    query = r"""
      SELECT
        f.fingerprint,
        (SELECT COALESCE(u.name, '') || ' <' || u.uid || '>'
           FROM uid u
           JOIN fingerprint f2 ON u.id = f2.uid
          WHERE f2.id = f.id) AS name,
        STRING_AGG(
          a.source
          || COALESCE(' (' || (SELECT fingerprint FROM fingerprint WHERE id = a.created_by_id) || ')', ''),
          E',\n ' ORDER BY a.source)
      FROM acl_per_source a
      JOIN fingerprint f ON a.fingerprint_id = f.id
      LEFT JOIN uid u ON f.uid = u.id
      WHERE a.acl_id = :acl_id
      GROUP BY f.id, f.fingerprint
      ORDER BY name
      """

    for row in session.execute(query, {'acl_id': acl.id}):
        print("Fingerprint:", row[0])
        print("Uid:", row[1])
        print("Allow:", row[2])
        print()

    session.rollback()
    session.close()
开发者ID:Debian,项目名称:dak,代码行数:33,代码来源:acl.py

示例2: generate_translations

# 需要导入模块: from daklib.dbconn import DBConn [as 别名]
# 或者: from daklib.dbconn.DBConn import rollback [as 别名]
def generate_translations(suite_id, component_id):
    global _translations_query
    from daklib.filewriter import TranslationFileWriter
    from daklib.dbconn import DBConn, Suite, Component
    from daklib.dakmultiprocessing import PROC_STATUS_SUCCESS

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

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

    r = session.execute(_translations_query, {"suite": suite_id, "component": component_id})
    for (stanza,) in r:
        print >>output, stanza

    writer.close()

    message = ["generate-translations", suite.suite_name, component.component_name]
    session.rollback()
    return (PROC_STATUS_SUCCESS, message)
开发者ID:abhi11,项目名称:dak,代码行数:32,代码来源:generate_packages_sources2.py

示例3: generate_sources

# 需要导入模块: from daklib.dbconn import DBConn [as 别名]
# 或者: from daklib.dbconn.DBConn import rollback [as 别名]
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)
开发者ID:abhi11,项目名称:dak,代码行数:37,代码来源:generate_packages_sources2.py

示例4: generate_packages

# 需要导入模块: from daklib.dbconn import DBConn [as 别名]
# 或者: from daklib.dbconn.DBConn import rollback [as 别名]
def generate_packages(suite_id, component_id, architecture_id, type_name):
    global _packages_query
    from daklib.filewriter import PackagesFileWriter
    from daklib.dbconn import Architecture, Component, DBConn, OverrideType, Suite
    from daklib.dakmultiprocessing import PROC_STATUS_SUCCESS

    session = DBConn().session()
    arch_all_id = session.query(Architecture).filter_by(arch_string='all').one().arch_id
    type_id = session.query(OverrideType).filter_by(overridetype=type_name).one().overridetype_id

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

    overridesuite_id = suite.get_overridesuite().suite_id
    include_long_description = suite.include_long_description

    # We currently filter out the "Tag" line. They are set by external
    # overrides and NOT by the maintainer. And actually having it set by
    # maintainer means we output it twice at the moment -> which breaks
    # dselect.
    metadata_skip = ["Section", "Priority", "Tag"]
    if include_long_description:
        metadata_skip.append("Description-md5")

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

    r = session.execute(_packages_query, {"archive_id": suite.archive.archive_id,
        "suite": suite_id, "component": component_id, 'component_name': component.component_name,
        "arch": architecture_id, "type_id": type_id, "type_name": type_name, "arch_all": arch_all_id,
        "overridesuite": overridesuite_id, "metadata_skip": metadata_skip,
        "include_long_description": 'true' if include_long_description else 'false'})
    for (stanza,) in r:
        print >>output, stanza
        print >>output, ""

    writer.close()

    message = ["generate-packages", suite.suite_name, component.component_name, architecture.arch_string]
    session.rollback()
    return (PROC_STATUS_SUCCESS, message)
开发者ID:abhi11,项目名称:dak,代码行数:53,代码来源:generate_packages_sources2.py


注:本文中的daklib.dbconn.DBConn.rollback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。