Beispiel #1
0
def send_email_by_indexes(config: Configuration, excel: SalaryFileReader,
                          generator: EmailGenerator, emailer: Emailer):
    email = config['tester_email']
    user_info = get_user_info_by_index(excel)
    if user_info:
        email = input_email(
            '请输入邮箱: ' if email is None else '请输入邮箱 或直接使用 %s: ' % email, False,
            email)
        if email:
            config['tester_email'] = email
        else:
            email = config['tester_email']
        if not email:
            return False
        path = generator.make_file(user_info)
        print(path)
    else:
        print('Error index')
        return False
    print('---->', email)
    email_content = generator.make_email(user_info)
    return emailer.send(email, email_content['subject'],
                        email_content['content'], path)
    pass
Beispiel #2
0
#!/usr/bin/env python
# This file is part of Car Quotz Scraper by Nikolay Pasko.
#
# Car Quotz Scraper is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Car Quotz Scraper is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Foobar.  If not, see <http://www.gnu.org/licenses/>.

from emailer import Emailer
from zipper import Zipper

Zipper.zip_dir()

Emailer.send()
Beispiel #3
0
def execute_all(excel: SalaryFileReader,
                generator: EmailGenerator,
                emailer: Emailer,
                start_seq: int = 1):
    bye_people_need_email = True
    bye_people_has_other_email = False
    no_email_need_email = True
    only_bye_no_email_people = False
    if emailer:
        if excel.has_noemail_people:
            how_for_byes = [
                '不发送工资邮件',
                '手动输入邮箱',
                '回到主菜单',
            ]
            ipos = tty_menu(how_for_byes, "发现表格中有部分成员没有邮箱。对于他们将?")
            if ipos == 0:
                no_email_need_email = False
            elif ipos == len(how_for_byes):
                return False
        if excel.has_bye_people:
            how_for_byes = [
                '按表格中的邮箱发送',
                '不发送工资邮件',
                '手动输入离职人员邮箱',
                '回到主菜单',
            ]
            ipos = tty_menu(how_for_byes, "发现表格中有离职成员。对于他们将?")
            if ipos == 0:
                bye_people_need_email = True
                bye_people_has_other_email = False
            elif ipos == 1:
                bye_people_need_email = False
                bye_people_has_other_email = False
            elif ipos == 2:
                bye_people_need_email = True
                bye_people_has_other_email = True
            elif ipos == len(how_for_byes):
                return False
    if start_seq < 0:
        only_bye_no_email_people = True
    with progressbar.ProgressBar(
            max_value=len(excel.user_value_map.items()) + 1,
            redirect_stdout=True,
    ) as p:
        p.update(0)
        for i, user_info in excel.user_value_map.items():
            p.update(i)
            # user_info = excel.user_value_map[i]
            if user_info['seq'] < start_seq:
                continue
            if only_bye_no_email_people and (user_info['email']
                                             and not user_info['out_day']):
                continue

            path = generator.make_file(user_info, make=True)
            if emailer and user_info['out_day']:
                p.finish(dirty=True)
                print('%s已于%s离职。' % (user_info['name'], user_info['out_day']))
                if bye_people_need_email:
                    if bye_people_has_other_email:
                        user_info['email'] = input_email(
                            "请输入邮箱 或 直接回车 %s:\n" %
                            (('使用' + user_info['email'])
                             if user_info['email'] else '不发送'),
                            default=user_info['email'],
                            empty=True)
                    else:
                        if not user_info['email'] and no_email_need_email:
                            user_info['email'] = input_email("请输入邮箱:\n")
                        pass
                else:
                    user_info['email'] = None
            elif emailer and user_info['email'] is None:
                p.finish(dirty=True)
                print('%s未填写邮箱。' % (user_info['name']))
                if no_email_need_email:
                    user_info['email'] = input_email("请输入邮箱:\n", empty=True)
            if user_info['email'] is None:
                print('%s 未发送邮件。文件保存在:%s\n' % (user_info['name'], path))
                continue
            # p.start()
            print('---->', user_info['email'], user_info['name'])

            email_content = generator.make_email(user_info)
            if emailer:
                emailer.send(user_info['email'], email_content['subject'],
                             email_content['content'], path)
            else:
                print(email_content['subject'])
                print(email_content['content'])
            p.update(i + 1)
            time.sleep(0.05)
    pass