def main():
    c.config = Config(__file__)
    init_app_log_dir()
    log(f'Starting {__file__}')

    applications = []
    while 1:
        for app_name in c.config.APPLICATIONS:
            app_running = False
            app_path = f'{c.config.grandparent_dir}\\{app_name}\\run.py'
            for app_process in applications:
                if app_process.args[1] == app_path:
                    poll = app_process.poll()
                    if poll is None:
                        app_running = True
                    else:
                        stdout, stderr = app_process.communicate()
                        log('Error detected, terminating ' + app_path)
                        log('Error message : ' + repr(stderr))
                        app_process.terminate()
                        applications.remove(app_process)
                        send_email('Error Message : ' + repr(stderr),
                                   ['*****@*****.**'], [''],
                                   subject='[APP ERROR] ' + app_name)
            if not app_running:
                app_process = subprocess.Popen([sys.executable, app_path],
                                               stdout=subprocess.PIPE,
                                               stderr=subprocess.PIPE,
                                               shell=True)
                applications.append(app_process)
                log('Started ' + app_path)
Beispiel #2
0
def scheduler_task():
    start_date, end_date = data.get_dates()
    for salesman in c.config.SALESMEN:
        delete_pdfs()
        report_pdf = run_ninja(start_date, end_date, salesman)
        send_email('Weekly Sales Report', [salesman['email']],
                   ['*****@*****.**'], [report_pdf])
Beispiel #3
0
def order_email(ord_no, email_to, email_cc):
    email_body = ''
    email_body = files.email_body_generator(email_body, ord_no, header=None)
    # email_pdf = files.pdf_generator(email_body)
    # attachments = [email_pdf]
    time_stamp = files.time_stamp_generator()
    subject = f'{ord_no} {time_stamp}'
    send_email(email_body, [email_to], [email_cc],
               # attachments,
               subject=subject)
Beispiel #4
0
def purchasing_emails(config):
    email_body = ''
    email_body = email_body_generator(config, email_body)
    time_stamp = time_stamp_generator()
    subject = f'Critical Parts {time_stamp}'

    email_pdf = pdf_generator(config, email_body, time_stamp)
    attachments = [email_pdf]

    send_email(email_body, ['*****@*****.**'], ['*****@*****.**'],
               attachments, subject)
Beispiel #5
0
def outstanding_pos_task():
    for purchaser in outstanding_purchase_order_purchasers():
        for sup_id in outstanding_purchase_order_suppliers(purchaser[0]):
            sup_name = get_sup_name1(sup_id[0])
            pdfs = []
            for po_number in outstanding_purchase_order_numbers(sup_id[0]):
                pdf = outstanding_pos_ninja(po_number[0])
                pdfs.append(pdf)
            subject = f"Purchasing Followup - {purchaser[0]} - {sup_name}"
            send_email('TEST', ['*****@*****.**'], [], pdfs, subject)
    delete_pdfs()
Beispiel #6
0
def production_emails():
    email_body = ''
    email_body = email_body_generator(email_body)
    time_stamp = time_stamp_generator()
    subject = f'Assemblies/Sub-assemblies {time_stamp}'

    email_pdf = pdf_generator(email_body, time_stamp)
    attachments = [email_pdf]

    # send_email(email_body, ['*****@*****.**'], ['*****@*****.**'], attachments, subject)
    send_email(email_body, ['*****@*****.**'], ['*****@*****.**'],
               attachments, subject)
Beispiel #7
0
def salesman_emails(cc_override=None, pending_orders=False):
    log('Starting salesmen emails')
    for salesman in c.config.SALESMEN:
        email_body = ''
        for grouping in c.config.GROUPINGS:
            file_name = f'{salesman} {grouping}'
            email_body = files.email_body_generator(email_body, file_name, header=grouping)

        if email_body != '':
            # email_pdf = files.pdf_generator(email_body)
            # attachments = [email_pdf]

            time_stamp = files.time_stamp_generator()
            subject = f'{salesman} {time_stamp}'

            if salesman == 'MARK STACHOWSKI':
                cc_list = cc_override if cc_override is not None else ['*****@*****.**']
                send_email(email_body, ['*****@*****.**'], cc_list,
                           # attachments,
                           subject=subject)
            elif salesman == 'GREG PHILLIPS':
                if pending_orders is False:
                    send_email(email_body, ['*****@*****.**'], ['*****@*****.**'],
                               # attachments,
                               subject=subject)
            # files.delete_pdf_file(email_pdf)
        else:
            if datetime.datetime.today().weekday() not in (5, 6):
                email_body = 'No orders entered for current report time frame.'
                if salesman == 'MARK STACHOWSKI':
                    send_email(email_body, ['*****@*****.**'], [''])
                elif salesman == 'GREG PHILLIPS':
                    if pending_orders is False:
                        send_email(email_body, ['*****@*****.**'], ['*****@*****.**'])
Beispiel #8
0
def scheduler_task():
    if not dev_check():
        pass
    email_body = pending_orders_email()
    if email_body:
        send_email(email_body, ['*****@*****.**'], ['*****@*****.**'], subject='Pending Orders')
Beispiel #9
0
def pending_emails():
    log('Starting pending email')
    email_body = ''
    email_body = files.email_body_generator(email_body, 'MARK STACHOWSKI OLD PENDING', header='OLD PENDING')
    email_body = files.email_body_generator(email_body, 'MARK STACHOWSKI OLD QUOTES', header='OLD QUOTES')
    send_email(email_body, ['*****@*****.**'], ['*****@*****.**'], subject='PENDING ORDERS TO BE REVISED')