Exemplo n.º 1
0
    def send_mail(self, to):
        """
        Send mail
        :param to: string, receiver's e-mail address
        :return: int, 1 for success, 0 for error
        """
        import smtplib
        from email.mime.text import MIMEText
        from email.header import Header
        from baseDriver import get_all_config
        settings = get_all_config()

        receivers = list()
        receivers.append(to)

        if self.mail_type == 1:
            mail_msg = self.success_job()
        else:
            mail_msg = self.error_job()

        message = MIMEText(mail_msg, 'html', 'utf-8')
        message['From'] = Header("BioQueue", 'utf-8')
        message['To'] = Header(to, 'utf-8')

        message['Subject'] = Header('Job notice', 'utf-8')

        try:
            if settings['mail']['mail_host'] != '':
                if settings['mail']['ssl'] != '':
                    # ssl connection
                    url = "%s:%d" % (settings['mail']['mail_host'],
                                     int(settings['mail']['mail_port']))
                    smtp_object = smtplib.SMTP_SSL(
                        settings['mail']['mail_host'],
                        int(settings['mail']['mail_port']))
                elif settings['mail']['tls'] != '':
                    # tls connection
                    smtp_object = smtplib.SMTP(
                        settings['mail']['mail_host'],
                        int(settings['mail']['mail_port']))
                    smtp_object.ehlo()
                    smtp_object.starttls()
                else:
                    # normal connection
                    smtp_object = smtplib.SMTP(
                        settings['mail']['mail_host'],
                        int(settings['mail']['mail_port']))

                smtp_object.ehlo()
                smtp_object.login(settings['mail']['mail_user'],
                                  settings['mail']['mail_password'])
            else:
                smtp_object = smtplib.SMTP('localhost')

            smtp_object.sendmail(settings['mail']['mail_user'], receivers,
                                 message.as_string())
            smtp_object.close()
            return 1
        except smtplib.SMTPException as e:
            print(e)
Exemplo n.º 2
0
#!/usr/bin/env python
from multiprocessing import cpu_count
import baseDriver
import time
import os
import parameterParser
import django_initial
import HTMLParser
import checkPoint
from ui.models import Queue, Protocol, References, Training
import threading
import subprocess
import psutil

settings = baseDriver.get_all_config()
CPU_POOL, MEMORY_POOL, DISK_POOL = baseDriver.get_init_resource()
MAX_JOB = cpu_count()
JOB_TABLE = dict()
USER_REFERENCES = dict()
JOB_PARAMETERS = dict()
JOB_COMMAND = dict()
RUN_PARAMETERS = dict()
JOB_INPUT_FILES = dict()
LAST_OUTPUT_STRING = dict()
OUTPUTS = dict()
OUTPUT_DICT = dict()
OUTPUT_DICT_SUFFIX = dict()
NEW_FILES = dict()
LAST_OUTPUT = dict()
LAST_OUTPUT_SUFFIX = dict()
INPUT_SIZE = dict()
Exemplo n.º 3
0
#!/usb/bin/env python
from __future__ import print_function
from numpy import *
import numpy
from baseDriver import get_all_config
import django_initial
from ui.models import Training, Prediction

settings = get_all_config()


def fill_missing_data_with_mean(to_handle):
    """
    fill missing data with mean value
    :param to_handle: list, data with or without missing values
    :return: list, data without missing values
    """
    no_missing_data = []
    for data in to_handle:
        if data != -1:
            no_missing_data.append(data)
    if len(no_missing_data) > 0:
        mean_value = mean(no_missing_data)
        for key, value in enumerate(to_handle):
            if value == -1:
                to_handle[key] = mean_value
    return to_handle


def load_train_frame(step_hash):
    """