celery_tasks.py
Python script, ASCII text executable
1import time 2import os 3import config 4from celery import shared_task 5from app import db 6from misc_utils import * 7from models import * 8from smtplib import SMTP 9 10 11@shared_task(ignore_result=False) 12def send_notification(notification_id, users, level): 13notification = db.session.get(Notification, notification_id) 14 15for user in users: 16db.session.add(UserNotification(db.session.get(User, user), notification, level)) 17db.session.commit() 18 19return 0 # notification sent successfully 20 21 22@shared_task(ignore_result=False) 23def merge_heads(head_route, head_branch, base_route, base_branch): 24server_repo_location = os.path.join(config.REPOS_PATH, base_route.lstrip("/")) 25if not os.path.isdir(server_repo_location): 26raise FileNotFoundError(f"Repo {server_repo_location} not found, cannot merge.") 27 28git_command(server_repo_location, b"", "checkout", "-f", f"heads/{base_branch}") 29out, err = git_command(server_repo_location, b"", "merge", f"heads/{head_branch}", return_err=True) 30 31return out, err 32