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

Source Code for Module commands.alter_chroot

 1  import datetime 
 2  from flask_script import Option 
 3  from coprs import db_session_scope 
 4  from coprs import app 
 5  from coprs import exceptions 
 6  from coprs.logic import coprs_logic 
 7  from commands.create_chroot import ChrootCommand 
 8   
 9   
10 -class AlterChrootCommand(ChrootCommand):
11 12 "Activates or deactivates a chroot" 13
14 - def run(self, chroot_names, action):
15 activate = (action == "activate") 16 for chroot_name in chroot_names: 17 try: 18 with db_session_scope(): 19 mock_chroot = coprs_logic.MockChrootsLogic.edit_by_name( 20 chroot_name, activate) 21 22 if action != "eol": 23 continue 24 25 for copr_chroot in mock_chroot.copr_chroots: 26 delete_after_days = app.config["DELETE_EOL_CHROOTS_AFTER"] + 1 27 delete_after_timestamp = datetime.datetime.now() + datetime.timedelta(delete_after_days) 28 # Workarounding an auth here 29 coprs_logic.CoprChrootsLogic.update_chroot(copr_chroot.copr.user, copr_chroot, 30 delete_after=delete_after_timestamp) 31 except exceptions.MalformedArgumentException: 32 self.print_invalid_format(chroot_name) 33 except exceptions.NotFoundException: 34 self.print_doesnt_exist(chroot_name)
35 36 option_list = ChrootCommand.option_list + ( 37 Option("--action", 38 "-a", 39 dest="action", 40 help="Action to take - currently activate or deactivate", 41 choices=["activate", "deactivate", "eol"], 42 required=True), 43 )
44