from celery import Celery,app
import os
import time
import gc

import rowingdata
from rowingdata import main as rmain
from rowingdata import rowingdata as rdata
import rowingdata
#from rowers.models import Workout
from matplotlib.backends.backend_agg import FigureCanvas
#from matplotlib.backends.backend_cairo import FigureCanvasCairo as FigureCanvas
import matplotlib.pyplot as plt
from matplotlib import figure

import stravalib

from django.core.mail import send_mail, BadHeaderError,EmailMessage


@app.task
def add(x, y):
    return x + y

@app.task
def handle_sendemailwork(bcclist,name,date,comment):

    # send email with attachment
    subject = "Nova brigada "+str(date)
    message = "Ahoj,\n\n"
    message += "Nova brigada.\n\n"
    message += "Datum: "+str(date)+"\n"
    message += "Nazev: "+str(name)+"\n\n"
    message += comment+"\n\n"

    email = EmailMessage(subject, message,
			 'Rowsandall <info@rowsandall.com>',
			 ['info@rowsandall.com'],
			 bcclist)
			 

    res = email.send()

    return 1

