Package commands :: Module create_chroot
[hide private]
[frames] | no frames]

Source Code for Module commands.create_chroot

 1  import click 
 2   
 3  from coprs import exceptions 
 4  from coprs import db 
 5  from coprs.helpers import chroot_to_branch 
 6  from coprs.logic import coprs_logic 
13   
17   
21   
22 23 -def create_chroot_function(chroot_names, branch=None, activated=True):
24 """Creates a mock chroot in DB""" 25 for chroot_name in chroot_names: 26 if not branch: 27 branch = chroot_to_branch(chroot_name) 28 branch_object = coprs_logic.BranchesLogic.get_or_create(branch) 29 try: 30 chroot = coprs_logic.MockChrootsLogic.add(chroot_name) 31 chroot.distgit_branch = branch_object 32 chroot.is_active = activated 33 db.session.commit() 34 except exceptions.MalformedArgumentException: 35 print_invalid_format(chroot_name) 36 except exceptions.DuplicateException: 37 print_already_exists(chroot_name)
38 39 40 @click.command() 41 @click.argument( 42 "chroot_names", 43 nargs=-1, 44 required=True 45 ) 46 @click.option( 47 "--dist-git-branch", "-b", "branch", 48 help="Branch name for this set of new chroots" 49 ) 50 @click.option( 51 "--activated/--deactivated", 52 help="Activate the chroot later, manually by `alter-chroot`", 53 default=True 54 )
55 -def create_chroot(chroot_names, branch=None, activated=True):
56 """Creates a mock chroot in DB""" 57 return create_chroot_function(chroot_names, branch, activated)
58