Beispiel #1
0
def main():
    students_file, course, university, max_students, \
     end, start_semester, get_repos, get_repos_filepath, get_feedback, \
      get_feedback_filepath, smtp = read_command_line()

    if end:
        org = "%s-%s" % (university, course)
        end_group(org)

    elif get_repos:
        from get_all_repos import collect_repos
        auth = get_password()
        collect_repos(auth, university, course, get_repos_filepath)

    elif get_feedback:
        from get_all_feedbacks import Feedbacks
        auth = get_password()
        feedbacks = Feedbacks(auth, university, course, get_feedback_filepath)
        feedbacks()

    else:
        # Set up e-mail server
        if smtp == 'google':
            server = SMTPGoogle()
        elif smtp == 'uio':
            server = SMTPUiO()
        send_email = Email(server)

        students = create_students(students_file, course, university,
                                   send_email)
        if not start_semester:
            Collaboration(students, max_students, send_email)

        # Logout e-mail server
        send_email.logout()
def main():
    students_file, course, university, max_students, \
     end, start_semester, get_repos, get_repos_filepath, get_feedback, \
      get_feedback_filepath, smtp = read_command_line()

    if end:
        org = "%s-%s" % (university, course)
        end_group(org)

    elif get_repos:
        from get_all_repos import collect_repos
        auth = get_password()
        collect_repos(auth, university, course, get_repos_filepath)

    elif get_feedback:
        from get_all_feedbacks import Feedbacks
        auth = get_password()
        feedbacks = Feedbacks(auth, university, course, get_feedback_filepath)
        feedbacks()

    else:
        # Set up e-mail server
        if smtp == 'google':
            server = SMTPGoogle()
        elif smtp == 'uio':
            server = SMTPUiO()
        send_email = Email(server)

        students = create_students(students_file, course, university, send_email)
        if not start_semester:
            Collaboration(students, max_students, send_email)

        # Logout e-mail server
        send_email.logout()
Beispiel #3
0
def send_email(file_name):
    print "zend email"
    fromaddr = '*****@*****.**'
    password = '******'
    toaddrs = ['*****@*****.**']

    mail = Email()
    mail.send(file_name,fromaddr,password,toaddrs)
 def send_email(self, subject, content, html=True, files=()):
     if self._send_email and self._email_recipients:
         self.log.debug('Send email to {}'.format(self._email_recipients))
         em = Email(self._conf['email']['server'],
                    self._conf['email']['sender'],
                    self._email_recipients)
         em.send(subject, content, html, files=files)
     else:
         self.log.warning("Won't send email (send_email: %s, recipients: %s)",
                          self._send_email, self._email_recipients)
Beispiel #5
0
 def send_email(self, subject, content, html=True, files=()):
     if self._send_email and self._email_recipients:
         self.log.debug('Send email to {}'.format(self._email_recipients))
         em = Email(self._conf['email']['server'],
                    self._conf['email']['sender'],
                    self._email_recipients)
         em.send(subject, content, html, files=files)
     else:
         self.log.warning("Won't send email (send_email: %s, recipients: %s)",
                          self._send_email, self._email_recipients)
Beispiel #6
0
 def send_email_records(subject: str, content: str,
                        to_account: str) -> bool:
     try:
         Email.send_email(subject,
                          content,
                          from_account="*****@*****.**",
                          SMTP_host="smtp.163.com",
                          from_password="******",
                          to_account=to_account)
         print("邮件报告发送成功")
         return True
     except smtplib.SMTPException or Exception as e:
         print("邮件报告发送失败!", e)
         return False
def main():
    """
    Entry-point for the function.
    """

    email_connection_params = {
        "host": "smtp.gmail.com",
        "port": 587,
        "user": "******",
        "password": "******",
        "use_tls": True
    }
    send_email = Email(**email_connection_params)
    send_email.send(to_address=['*****@*****.**'])
Beispiel #8
0
def main():
    process_list = []
    for process in sys_process.Win32_Process():
        process_list.append([process.CommandLine, process.Caption])
    if [CommandLine, Caption] in process_list:
        log.logger.info('进程正在运行')
    else:
        log.logger.error('process get_data_futures deth')
        log.logger.info('正在准备重启')
        restart_process = 'start /b python ' + restart_process_path
        try:
            os.system(restart_process)
            log.logger.info('已经重启')
            Email(em_user, pwd, address,
                  smtp_server).send_email(message='sp数据抓取进程已经重启,请查看是否出错',
                                          title='sp数据抓取重启')
        except Exception as e:
            log.logger.error('重启失败' + str(e))
            Email(em_user, pwd, address,
                  smtp_server).send_email(message='sp数据抓取进程重启失败,请查看哪里出错',
                                          title='sp数据抓取重启失败')
Beispiel #9
0
def send_image():
    filename = picroscope.capture()
    if filename is not None:
        picroscope.toggle_preview()

        email = Email(server)
        email.subject = EMAIL_SUBJECT
        email.recipient = input("Recipient: ")
        email.add_attachment(filename)

        print()
        try:
            print("Please wait ...")
            email.send()
        except SMTPRecipientsRefused:
            print("Invalid email address.")
def main():
    students_file, course, university, max_students, \
     end, start_semester, get_repos, get_repos_filepath, get_feedback, \
      get_feedback_filepath, smtp, rank, email = read_command_line()

    if end:
        org = "%s-%s" % (university, course)
        end_group(org)

    elif get_repos:
        from get_all_repos import collect_repos
        auth = get_password()
        collect_repos(auth, university, course, get_repos_filepath)

    elif get_feedback:
        from get_all_feedbacks import Feedbacks
        auth = get_password()
        feedbacks = Feedbacks(auth, university, course, get_feedback_filepath)
        feedbacks()

    else:
        if email:
            # Set up e-mail server
            if smtp == 'google':
                server = SMTPGoogle()
            elif smtp == 'uio':
                server = SMTPUiO()
            send_email = Email(server)
        else:
            send_email = None

        students = create_students(students_file, course, university, send_email, rank)
        if not start_semester:
            # The email server logs off again after some time, so we need to
            # login again
            if email:
                # Set up e-mail server
                if smtp == 'google':
                    server = SMTPGoogle()
                elif smtp == 'uio':
                    server = SMTPUiO()
                send_email = Email(server)
            else:
                send_email = None
            Collaboration(students, max_students, send_email, rank)

        # Logout e-mail server
        if email:
            try:
                send_email.logout()
            except:
                pass
Beispiel #11
0
def run(prod_code):
    time.sleep(5)
    while True:
        ret = sp_account.write_data_for_file(prod_code)
        if ret is False:
            time.sleep(1)
            msg = sp_account.login()
            if msg is False:
                # 发邮件提醒
                email_msg = '登陆失败,请检测是程序出错还是服务出错\n,' + str(msg)
                email_title = 'SP数据抓取问题'
                try:
                    Email(em_user=em_user,
                          pwd=pwd,
                          address=address,
                          smtp_server=smtp_server).send_email(
                              message=email_msg, title=email_title)
                except Exception as e:
                    log.logger.error(e)
                break
            else:
                time.sleep(2)
                sp_account.subscription(prod_code)
                continue
Beispiel #12
0
username = config.get('MOVIES', 'MYSQL_USER')
password = config.get('MOVIES', 'MYSQL_PASSWORD')

##-----------------------------------------------------------------------------
##-----------------------------------------------------------------------------
conn = Connection(username, password)
conn.connect()
conn.create_table()

print("Enter Number of Users you want to Register", end=" ")
n = int(input())
for i in range(n):
    x = input("Email address:")
    tv = input("TV series:")
    insert = True
    for ser in conn.select_value(x):
        if ser[0] == tv:
            insert = False
    if insert:
        conn.insert_value(x.lower(), tv.lower())
    else:
        print("Database already has your information")

email = Email()
grab = grabber()
for x in conn.select_all():
    recv, series = x[0], x[1]
    email.send(recv, grab.information(series))

conn.close_connection()
Beispiel #13
0
def get_mail_server():
    global mail_server
    if not mail_server:
        mail_server = Email(mail_conf)

    return mail_server
            if weekday in [5, 6] and time_st.hour < 12:
                time_slots.append((time_st, weekday, time_st.hour))

    except error.HTTPError as e:
        print(e.reason)


    return time_slots

if __name__ == '__main__':

    duration = 3  # seconds
    freq = 440  # Hz

    email_server = Email()
    last_email = None
    sleep_interval = 60

    while True:

        time.sleep(sleep_interval)

        time_slots = download_page(month=2)
        time_slots += download_page(month=3)
        time_slots += download_page(month=4)

        if len(time_slots) == 0:
            continue
        else:
            print(datetime.now(), time_slots)
            print "Student are no longer taking this course: ", file_name

# Not in use
#file = open('INF5620_stats', 'w')
#for parameters in students.itervalues():
#    values = parameters.values()
#    tmp_str = " // ".join(values)
#    file.write(tmp_str)
#file.close()

#print students
exceptions = ['Arnfinn Aamodt', 'Matthew Terje Aadne', 'Jens Kristoffer Reitan Markussen']
skip = False

smtp = SMTPGoogle()
email = Email(smtp)

#text_zero = email.get_text('message_missing_all_classes.rst')
text_missing_one = email.get_text('message_missing_one_class.rst')
text_passed = email.get_text('message_missing_none.rst')

for parameters in students.itervalues():
    if parameters['name'] in exceptions: 
        skip = True

    if parameters['pressent'] == 0 and not skip:
        print "None: ", parameters['name'], "NO EMAIL"
        #text_tmp = text_zero % parameters

    if parameters['pressent'] == 1 and not skip:
        #text_tmp = text_one % parameters
Beispiel #16
0
            print "Student are no longer taking this course: ", file_name

# Not in use
#file = open('INF5620_stats', 'w')
#for parameters in students.itervalues():
#    values = parameters.values()
#    tmp_str = " // ".join(values)
#    file.write(tmp_str)
#file.close()

#print students
exceptions = ['Arnfinn Aamodt', 'Matthew Terje Aadne', 'Jens Kristoffer Reitan Markussen']
skip = False

smtp = SMTPGoogle()
email = Email(smtp)

#text_zero = email.get_text('message_missing_all_classes.rst')
text_missing_one = email.get_text('message_missing_one_class.rst')
text_passed = email.get_text('message_missing_none.rst')

for parameters in students.itervalues():
    if parameters['name'] in exceptions: 
        skip = True

    if parameters['pressent'] == 0 and not skip:
        print "None: ", parameters['name'], "NO EMAIL"
        #text_tmp = text_zero % parameters

    if parameters['pressent'] == 1 and not skip:
        #text_tmp = text_one % parameters
Beispiel #17
0
def excute_project():
    try:
        now_time = datetime.date.today()
        one_day=datetime.timedelta(days=1)
        yesterday=now_time-one_day
        yesterday_time=yesterday.strftime("%Y-%m-%d")
        year=yesterday.strftime("%Y")
        begin_time=yesterday_time+" 00:00:00"
        print(begin_time)
        end_time=yesterday_time+" 23:59:59"
        print(end_time)
        ort_sql=''' SELECT      
                 PROJECT_NO,
                 scheme_code,
                 customer_pn,
                 operation_no,   
                 PRODUCT_WEEK,
                 PRODUCT_DATE,
                 THE_ANNUAL,
                 ITEM_NO,
                 WORK_CENTER_NO,
                 SAMPLE_NUMBER,
                count(SFC_NO) as TOTAL
                 from ( 
                   select i.sfc_no as sfc_no,
                         to_char( to_date( wh.create_date,'yyyy-MM-dd hh24:mi:ss'),'yyyy-MM-dd') as product_date,
                         FUN_GET_SWD_WEEKDAY(to_date( wh.create_date,'yyyy-MM-dd hh24:mi:ss')) AS PRODUCT_WEEK,
                         to_char(to_date( wh.create_date,'yyyy-MM-dd hh24:mi:ss'),'yyyy') as THE_ANNUAL,
                         wh.result as apmt_result ,
                         di.value as project_no,
                         wh.item_no as item_no,
                         rt.scheme_code as SCHEME_CODE ,
                         rt.customer_pn as CUSTOMER_PN,
                         rt.operation_no as OPERATION_NO,
                         rt.sample_number as SAMPLE_NUMBER,
                         wh.workcenter_no as work_center_no
                from sfc_info i,  sfc_wip_log_his wh,m_custom_data_ins di,m_bom b,XWD_ORT_SAMPLE_INFO rt
                where 
                substr(i.bom_no,0,3)=100
                and di.context_id=b.pid
                and i.item_no=b.bom_no
                and wh.item_no=rt.swd_item
                and di.custom_data_id='6659d145de584f08aab8f78e6e4c912b'
                and i.pid=wh.sfc_id
                and di.value=rt.project_no
                and substr(wh.workcenter_no,1,2)='SW'
                and wh.create_date between to_char(to_date('{begin_time}','yyyy-MM-dd hh24:mi:ss'),'yyyyMMddhh24miss')  
                and  to_char(to_date('{end_time}','yyyy-MM-dd hh24:mi:ss'),'yyyyMMddhh24miss')
                and wh.operation_no=rt.operation_no
                union  
               select  i.sfc_no  as sfc_no,
                       to_char(to_date( w.create_date,'yyyy-MM-dd hh24:mi:ss'),'yyyy-MM-dd') as product_date,
                       FUN_GET_SWD_WEEKDAY(to_date( w.create_date,'yyyy-MM-dd hh24:mi:ss')) AS PRODUCT_WEEK,
                       to_char(to_date( w.create_date,'yyyy-MM-dd hh24:mi:ss'),'yyyy') as THE_ANNUAL,
                       w.result as apmt_result,
                       di.value as project_no,
                       w.item_no as item_no,
                       rt.scheme_code as SCHEME_CODE ,
                       rt.customer_pn as CUSTOMER_PN,
                       rt.operation_no as OPERATION_NO,
                       rt.sample_number as SAMPLE_NUMBER,
                       w.workcenter_no as WORK_CENTER_NO 
                 from sfc_info i,  sfc_wip_log w,m_custom_data_ins di,m_bom b,XWD_ORT_SAMPLE_INFO rt
                 where
                 substr(i.bom_no,0,3)=100
                 and di.context_id=b.pid
                 and i.item_no=b.bom_no
                 and  i.item_no=rt.swd_item
                 and di.custom_data_id='6659d145de584f08aab8f78e6e4c912b'
                 and i.pid=w.sfc_id
                 and di.value=rt.project_no
                 and substr(w.workcenter_no,1,2)='SW'
                 and w.create_date  between to_char(to_date('{begin_time}','yyyy-MM-dd hh24:mi:ss'),'yyyyMMddhh24miss')  
                  and  to_char(to_date('{end_time}','yyyy-MM-dd hh24:mi:ss'),'yyyyMMddhh24miss')
                 and w.operation_no=rt.operation_no
                 )  
                 group by PROJECT_NO,SCHEME_CODE,CUSTOMER_PN,ITEM_NO,
                   WORK_CENTER_NO,PRODUCT_DATE,THE_ANNUAL,PRODUCT_WEEK,OPERATION_NO,SAMPLE_NUMBER order by PRODUCT_DATE  
        '''.format(begin_time=begin_time,end_time=end_time)

        dsn = cx_Oracle.makedsn('aph-scan.sunwoda.cn', 1521, service_name='aph')
        orcl = cx_Oracle.connect('aphmes', 'aph2018mes1314', dsn)
        curs = orcl.cursor()
        curs.execute(ort_sql)
        desc = [d[0] for d in curs.description]
        result = [dict(zip(desc, line)) for line in curs]
        curs.close()

        # 创建redis 连接
        r = redis.Redis(host='192.168.9.50', password='******',port=6380,db=0)
        #设置key 值,并循环获取字典中的数据
        for value in result:
            value1=value.get("PRODUCT_WEEK")
            ort_key=year+'_'+value1
            value2=str(value)
            r.sadd(ort_key,value2)
        try:
                # 邮件内容
                message = """
                           <h3>'{yesterday_time}'ORT抽样确认数据已成功存储至redis</h3>""".format(yesterday_time=yesterday_time)

                # 邮件需发送的人的邮箱
                my_users=''' select u.email_address from mail_type t, mail_user u, mail_type_user s
                            where t.mail_type_id = s.mail_type_id
                             and s.user_id = u.user_id and t.mail_type_id = '6' '''
                list=oracle.get_all(my_users)
                my_user = []  #预警邮件收件人列表
                for i in list :
                    print(i[0])
                    my_user.append(i[0])
                    print(my_user)
                # my_user = ['*****@*****.**']
                # 发送邮件的邮箱
                my_sender = "*****@*****.**"
                message = Messages(my_sender, my_user, "ORT抽样确认数据已成功存储至redis", message).generate_message()
                Email(my_sender, my_user, "sunwoda+2019", "mail.sunwoda.com").send_mail(message)
        except Exception as e:
             print(e)
             print('成功')
    except Exception as e:
        print(e)