本文整理汇总了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()
示例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)
示例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)
示例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)