本文整理匯總了Python中models.Build.as_unique方法的典型用法代碼示例。如果您正苦於以下問題:Python Build.as_unique方法的具體用法?Python Build.as_unique怎麽用?Python Build.as_unique使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Build
的用法示例。
在下文中一共展示了Build.as_unique方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: lastclobber
# 需要導入模塊: from models import Build [as 別名]
# 或者: from models.Build import as_unique [as 別名]
def lastclobber():
"Get the max/last clobber time for a particular builddir and branch."
session = g.db.session(DB_DECLARATIVE_BASE)
now = int(time.time())
branch = request.args.get('branch')
slave = request.args.get('slave')
builddir = request.args.get('builddir')
buildername = request.args.get('buildername')
# TODO: Move the builds update to a separate endpoint (requires client changes)
build = Build.as_unique(
session,
branch=branch,
builddir=builddir,
buildername=buildername,
)
# Always force the time to update
build.last_build_time = now
session.add(build)
session.commit()
max_ct = session.query(ClobberTime).filter(
ClobberTime.builddir == builddir,
ClobberTime.branch == branch,
# a NULL slave value signifies all slaves
or_(ClobberTime.slave == slave, ClobberTime.slave == None) # noqa
).order_by(desc(ClobberTime.lastclobber)).first()
if max_ct:
# The client parses this result by colon as:
# builddir, lastclobber, who = urlib2.open.split(':')
# as such it's important for this to be plain text and have
# no extra colons within the field values themselves
return "{}:{}:{}\n".format(max_ct.builddir, max_ct.lastclobber, max_ct.who)
return ""