本文整理汇总了Python中bkr.server.model.System.query方法的典型用法代码示例。如果您正苦于以下问题:Python System.query方法的具体用法?Python System.query怎么用?Python System.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bkr.server.model.System
的用法示例。
在下文中一共展示了System.query方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_reservations
# 需要导入模块: from bkr.server.model import System [as 别名]
# 或者: from bkr.server.model.System import query [as 别名]
#!/usr/bin/python
import datetime
from turbogears.database import session
from bkr.server.util import load_config
from bkr.server.model import System
def check_reservations(system):
if system.user is not None:
assert system.reservations[0].finish_time is None
if not system.reservations:
return
prev = system.reservations[0]
if prev.finish_time:
assert prev.start_time <= prev.finish_time, "%r is backwards" % prev
for r in system.reservations[1:]:
assert r.finish_time <= prev.start_time, "%r does not finish before %r" % (r, prev)
assert r.start_time <= r.finish_time, "%r is backwards" % r
prev = r
if __name__ == "__main__":
load_config()
for system_id in [s.id for s in System.query()]:
system = System.query().get(system_id)
check_reservations(system)
session.clear()