<commit_before>
# -*- coding: utf-8 -*-
from genologics.lims import *
from genologics.config import BASEURI, USERNAME, PASSWORD
from datetime import *
from email.mime.text import MIMEText

import smtplib
import argparse

def main(args):
    lims = Lims(BASEURI, USERNAME, PASSWORD)

    sixMonthsAgo=date.today()-timedelta(weeks=26);
    yesterday=date.today()-timedelta(days=1)
    pjs=lims.get_projects(open_date=sixMonthsAgo.strftime("%Y-%m-%d"))

    operator="<EMAIL>"
    summary={}
    project_types=['Bcl Conversion & Demultiplexing (Illumina SBS) 4.0','Illumina Sequencing (Illumina SBS) 4.0',
    'MiSeq Run (MiSeq) 4.0','Cluster Generation (Illumina SBS) 4.0','Denature, Dilute and Load Sample (MiSeq) 4.0', 'Aggregate QC (DNA) 4.0','Aggregate QC (RNA) 4.0', 'Project Summary 1.3']

    def clean_names(name):
        return name.replace(u"\u00f6", "o").replace(u"\u00e9", "e").replace(u"\u00e4", "a")

    def get_email(fullname):
        #shotgun
        #In multipart names, the first token is taken as first name and the rest taken as surname
        names=fullname.split(" ", 1)
        try:
            researchers=lims.get_researchers(firstname=names[0], lastname=names[1])
        except:
            names=clean_names(fullname).split(" ", 1)
            researchers=lims.get_researchers(firstname=names[0], lastname=names[1])
        email=''
        for r in researchers:
            try:
                if not r.account_locked:
                    email=r.email
                    break
            except AttributeError:
                continue

        return email

    for p in pjs:
        #Assuming this will be run on the early morning, this grabs all processes from the list that have been modified the day before
        pro=lims.get_processes(projectname=p.name, type=project_types, last_modified=yesterday.strftime("%Y-%m-%dT00:00:00Z"));
        completed=[]
        bfr=None
        lbr=None
        if pro:
            for pr in pro:
                date_start=None
                #Special case for the project summary
                if pr.type.name== 'Project Summary 1.3':
                    if 'Queued' in pr.udf and pr.udf['Queued'] == yesterday.strftime("%Y-%m-%d"):
                        completed.append({'project':p.name,
                            'action':'has been queued',
                            'date':pr.udf['Queued'],
                            'techID':pr.udf['Signature Queued'],<commit_msg>Added check for NGI Role<commit_after>
# -*- coding: utf-8 -*-
from genologics.lims import *
from genologics.config import BASEURI, USERNAME, PASSWORD
from datetime import *
from email.mime.text import MIMEText

import smtplib
import argparse

def main(args):
    lims = Lims(BASEURI, USERNAME, PASSWORD)

    sixMonthsAgo=date.today()-timedelta(weeks=26);
    yesterday=date.today()-timedelta(days=1)
    pjs=lims.get_projects(open_date=sixMonthsAgo.strftime("%Y-%m-%d"))

    operator="<EMAIL>"
    summary={}
    project_types=['Bcl Conversion & Demultiplexing (Illumina SBS) 4.0','Illumina Sequencing (Illumina SBS) 4.0',
    'MiSeq Run (MiSeq) 4.0','Cluster Generation (Illumina SBS) 4.0','Denature, Dilute and Load Sample (MiSeq) 4.0', 'Aggregate QC (DNA) 4.0','Aggregate QC (RNA) 4.0', 'Project Summary 1.3']

    def clean_names(name):
        return name.replace(u"\u00f6", "o").replace(u"\u00e9", "e").replace(u"\u00e4", "a")

    def hasNGIRole(roles):
        flag=False
        for role in roles:
            if role.name in ['Facility Administrator', 'Researcher', 'System Administrator']:
                flag=True
                break
        return flag

    def get_email(fullname):
        #shotgun
        #In multipart names, the first token is taken as first name and the rest taken as surname
        names=fullname.split(" ", 1)
        try:
            researchers=lims.get_researchers(firstname=names[0], lastname=names[1])
        except:
            names=clean_names(fullname).split(" ", 1)
            researchers=lims.get_researchers(firstname=names[0], lastname=names[1])
        email=''
        for r in researchers:
            try:
                if not r.account_locked and hasNGIRole(r.roles):
                    email=r.email
                    break
            #older Contacts would not have the account_locked field which would throw an AttributeError
            except AttributeError:
                continue

        return email

    for p in pjs:
        #Assuming this will be run on the early morning, this grabs all processes from the list that have been modified the day before
        pro=lims.get_processes(projectname=p.name, type=project_types, last_modified=yesterday.strftime("%Y-%m-%dT00:00:00Z"));
        completed=[]
        bfr=None
        lbr=None
        if pro:
            for pr in pro:
                date_start=None
                #Special case for the project summary
                if pr.type.name== 'Project Summary 1.3':
                    if 'Queued' in pr.udf and pr.udf['Queued'] == yesterday.strftime("%Y-%m-%d"):
                        completed.append({'project':p.name,
                            'action':'has been queued',
                            'date':pr.udf['Queued'],
                            'techID':pr.udf['Signature Queued'],
{'fraction_non_alphanumeric': 0.11751369733610428, 'fraction_numerical': 0.016247874551294162, 'mean_word_length': 2.29228855721393, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1162411', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1610, 'n_words': 409}