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

Source Code for Module commands.create_chroot

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