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 
 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 mock_chroot = coprs_logic.MockChrootsLogic.edit_by_name( 19 chroot_name, activate) 20 21 if action != "eol": 22 continue 23 24 for copr_chroot in mock_chroot.copr_chroots: 25 delete_after_days = app.config["DELETE_EOL_CHROOTS_AFTER"] + 1 26 delete_after_timestamp = datetime.datetime.now() + datetime.timedelta(delete_after_days) 27 # Workarounding an auth here 28 coprs_logic.CoprChrootsLogic.update_chroot(copr_chroot.copr.user, copr_chroot, 29 delete_after=delete_after_timestamp) 30 db.session.commit() 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