| |
@@ -1,6 +1,6 @@
|
| |
import datetime
|
| |
from flask_script import Option
|
| |
- from coprs import db
|
| |
+ from coprs import db_session_scope
|
| |
from coprs import app
|
| |
from coprs import exceptions
|
| |
from coprs.logic import coprs_logic
|
| |
@@ -15,19 +15,19 @@
|
| |
activate = (action == "activate")
|
| |
for chroot_name in chroot_names:
|
| |
try:
|
| |
- mock_chroot = coprs_logic.MockChrootsLogic.edit_by_name(
|
| |
- chroot_name, activate)
|
| |
+ with db_session_scope():
|
| |
+ mock_chroot = coprs_logic.MockChrootsLogic.edit_by_name(
|
| |
+ chroot_name, activate)
|
| |
|
| |
- if action != "eol":
|
| |
- continue
|
| |
+ if action != "eol":
|
| |
+ continue
|
| |
|
| |
- for copr_chroot in mock_chroot.copr_chroots:
|
| |
- delete_after_days = app.config["DELETE_EOL_CHROOTS_AFTER"] + 1
|
| |
- delete_after_timestamp = datetime.datetime.now() + datetime.timedelta(delete_after_days)
|
| |
- # Workarounding an auth here
|
| |
- coprs_logic.CoprChrootsLogic.update_chroot(copr_chroot.copr.user, copr_chroot,
|
| |
- delete_after=delete_after_timestamp)
|
| |
- db.session.commit()
|
| |
+ for copr_chroot in mock_chroot.copr_chroots:
|
| |
+ delete_after_days = app.config["DELETE_EOL_CHROOTS_AFTER"] + 1
|
| |
+ delete_after_timestamp = datetime.datetime.now() + datetime.timedelta(delete_after_days)
|
| |
+ # Workarounding an auth here
|
| |
+ coprs_logic.CoprChrootsLogic.update_chroot(copr_chroot.copr.user, copr_chroot,
|
| |
+ delete_after=delete_after_timestamp)
|
| |
except exceptions.MalformedArgumentException:
|
| |
self.print_invalid_format(chroot_name)
|
| |
except exceptions.NotFoundException:
|
| |
Please have a look at the db_session_scope idiom, whether it makes sense.