本文整理汇总了Python中coprs.logic.builds_logic.BuildsLogic.get方法的典型用法代码示例。如果您正苦于以下问题:Python BuildsLogic.get方法的具体用法?Python BuildsLogic.get怎么用?Python BuildsLogic.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coprs.logic.builds_logic.BuildsLogic
的用法示例。
在下文中一共展示了BuildsLogic.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete_build_basic
# 需要导入模块: from coprs.logic.builds_logic import BuildsLogic [as 别名]
# 或者: from coprs.logic.builds_logic.BuildsLogic import get [as 别名]
def test_delete_build_basic(
self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
self.b1.pkgs = "http://example.com/copr-keygen-1.58-1.fc20.src.rpm"
expected_dir = self.b1.result_dir_name
self.db.session.add(self.b1)
self.db.session.commit()
expected_chroots_to_delete = set()
for bchroot in self.b1_bc:
expected_chroots_to_delete.add(bchroot.name)
assert len(ActionsLogic.get_many().all()) == 0
BuildsLogic.delete_build(self.u1, self.b1)
self.db.session.commit()
assert len(ActionsLogic.get_many().all()) == 1
action = ActionsLogic.get_many().one()
delete_data = json.loads(action.data)
assert "chroots" in delete_data
assert delete_data["result_dir_name"] == expected_dir
assert expected_chroots_to_delete == set(delete_data["chroots"])
with pytest.raises(NoResultFound):
BuildsLogic.get(self.b1.id).one()
示例2: test_delete_build_as_admin
# 需要导入模块: from coprs.logic.builds_logic import BuildsLogic [as 别名]
# 或者: from coprs.logic.builds_logic.BuildsLogic import get [as 别名]
def test_delete_build_as_admin(
self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
self.b4.pkgs = "http://example.com/copr-keygen-1.58-1.fc20.src.rpm"
expected_dir = self.b4.result_dir_name
for bc in self.b4_bc:
bc.status = StatusEnum("succeeded")
bc.ended_on = time.time()
self.u1.admin = True
self.db.session.add_all(self.b4_bc)
self.db.session.add(self.b4)
self.db.session.add(self.u1)
self.db.session.commit()
expected_chroots_to_delete = set()
for bchroot in self.b4_bc:
expected_chroots_to_delete.add(bchroot.name)
assert len(ActionsLogic.get_many().all()) == 0
BuildsLogic.delete_build(self.u1, self.b4)
self.db.session.commit()
assert len(ActionsLogic.get_many().all()) == 1
action = ActionsLogic.get_many().one()
delete_data = json.loads(action.data)
assert "chroots" in delete_data
assert delete_data["result_dir_name"] == expected_dir
assert expected_chroots_to_delete == set(delete_data["chroots"])
with pytest.raises(NoResultFound):
BuildsLogic.get(self.b4.id).one()
示例3: test_delete_build_basic
# 需要导入模块: from coprs.logic.builds_logic import BuildsLogic [as 别名]
# 或者: from coprs.logic.builds_logic.BuildsLogic import get [as 别名]
def test_delete_build_basic(
self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
self.db.session.commit()
expected_chroots_to_delete = set()
for bchroot in self.b1_bc:
expected_chroots_to_delete.add(bchroot.name)
assert len(ActionsLogic.get_many().all()) == 0
BuildsLogic.delete_build(self.u1, self.b1)
self.db.session.commit()
assert len(ActionsLogic.get_many().all()) == 1
action = ActionsLogic.get_many().one()
delete_data = json.loads(action.data)
assert "chroots" in delete_data
assert expected_chroots_to_delete == set(delete_data["chroots"])
with pytest.raises(NoResultFound):
BuildsLogic.get(self.b1.id).one()
示例4: test_delete_build_bad_src_pkg
# 需要导入模块: from coprs.logic.builds_logic import BuildsLogic [as 别名]
# 或者: from coprs.logic.builds_logic.BuildsLogic import get [as 别名]
def test_delete_build_bad_src_pkg(
self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
# has meaning only for the builds with old result dir naming schema
self.b1.pkgs = "http://example.com/"
self.db.session.add(self.b1)
self.db.session.commit()
expected_chroots_to_delete = set()
for bchroot in self.b1_bc:
bchroot.git_hash = None
expected_chroots_to_delete.add(bchroot.name)
assert len(ActionsLogic.get_many().all()) == 0
BuildsLogic.delete_build(self.u1, self.b1)
self.db.session.commit()
assert len(ActionsLogic.get_many().all()) == 0
with pytest.raises(NoResultFound):
BuildsLogic.get(self.b1.id).one()
示例5: test_delete_build_some_chroots
# 需要导入模块: from coprs.logic.builds_logic import BuildsLogic [as 别名]
# 或者: from coprs.logic.builds_logic.BuildsLogic import get [as 别名]
def test_delete_build_some_chroots(
self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
expected_chroots_to_delete = set([self.b1_bc[0].name,
self.b1_bc[-1].name])
for bchroot in self.b1_bc[1:-1]:
bchroot.status = helpers.StatusEnum("skipped")
self.db.session.commit()
assert len(ActionsLogic.get_many().all()) == 0
BuildsLogic.delete_build(self.u1, self.b1)
self.db.session.commit()
assert len(ActionsLogic.get_many().all()) == 1
action = ActionsLogic.get_many().one()
delete_data = json.loads(action.data)
assert "chroots" in delete_data
assert expected_chroots_to_delete == set(delete_data["chroots"])
with pytest.raises(NoResultFound):
BuildsLogic.get(self.b1.id).one()
示例6: split_one
# 需要导入模块: from coprs.logic.builds_logic import BuildsLogic [as 别名]
# 或者: from coprs.logic.builds_logic.BuildsLogic import get [as 别名]
def split_one(orig_build_id):
from coprs import db
from coprs import models
from coprs.logic.builds_logic import BuildsLogic
from coprs.models import BuildChroot
def clone_build(build):
other = models.Build(
pkgs=build.pkgs,
built_packages=build.built_packages,
pkg_version=build.pkg_version,
canceled=build.canceled,
repos=build.repos,
submitted_on=build.submitted_on,
started_on=build.started_on,
ended_on=build.ended_on,
results=build.results,
memory_reqs=build.memory_reqs,
timeout=build.timeout,
enable_net=build.enable_net,
user=build.user,
copr=build.copr,
)
return other
def set_src_pkg(build_, src_pkg_):
db.session.rollback() # some dirty state in SQLalchemy, no idea how to do correctly
build_.pkgs = src_pkg_
db.session.add(build_)
db.session.commit()
log.info("Fixed spaces for build id={}, src_pkg={}".format(build_.id, src_pkg_))
build = BuildsLogic.get(orig_build_id).one()
log.info("Start splitting build: {}, pkgs: {}".format(build.id, build.pkgs))
src_pkg_list = []
for mb_pkg in build.pkgs.strip().split(" "):
src_pkg_list.append(mb_pkg)
if len(src_pkg_list) == 0:
log.error("> Got build with empty pkgs: id={}".format(build.id))
return
if len(src_pkg_list) == 1:
log.info("> Got build with one pkg in pkgs, id={}, pkgs={}".format(build.id, build.pkgs))
set_src_pkg(build, src_pkg_list[0])
return
new_builds = []
new_build_chroots = []
for src_pkg in src_pkg_list:
log.info("> Processing {} package".format(src_pkg))
new_build = clone_build(build)
new_build.pkgs = src_pkg
for bc in build.build_chroots:
log.info("> > Copying chroot {}".format(bc.name))
new_bc = BuildChroot(
build=new_build,
mock_chroot=bc.mock_chroot,
status=bc.status
)
new_build_chroots.append(new_bc)
new_builds.append(new_build)
log.info("> Finished build split for id: {}. Doing commit".format(build.id))
db.session.rollback() # some dirty state in SQLalchemy, no idea how to do correctly
db.session.add_all(new_build_chroots)
db.session.add_all(new_builds)
for bc in build.build_chroots:
db.session.delete(bc)
db.session.delete(build)
db.session.commit()
log.info("> New build objects were created ")
log.info("> Build {} deleted ".format(build.id))