1+ import os
2+ import platform
3+ import smtplib
4+ import sys
5+ from email .mime .text import MIMEText
6+ from email .mime .multipart import MIMEMultipart
7+ from email .header import Header
8+
9+ try :
10+ from aceinna import VERSION
11+ except : # pylint: disable=bare-except
12+ sys .path .append ('./src' )
13+ from aceinna import VERSION
14+
15+ SYS = platform .system ()
16+ SENDER = os .environ ['EMAIL_ADDRESS' ]
17+ 18+ PASSWORD = os .environ ['EMAIL_PASSWORD' ]
19+
20+ MESSAGE = MIMEMultipart ()
21+ MESSAGE [
'From' ]
= Header (
"[email protected] " ,
'utf-8' )
22+ MESSAGE ['To' ] = ";" .join (RECEIVERS )
23+ SUBJECT = '[{0}] CI Executable' .format (SYS )
24+ MESSAGE ['Subject' ] = Header (SUBJECT , 'utf-8' )
25+
26+ MESSAGE .attach (
27+ MIMEText ('<p>[Inceptio Branch] Built executable on {0}</p><p>Version: {1}</p>' .format (SYS , VERSION ), 'html' , 'utf-8' ))
28+
29+ FILE_NAME = 'ans-devices.exe' if SYS == "Windows" else 'ans-devices'
30+
31+ ATTACHMENT = MIMEText (open (os .path .join (os .getcwd (), 'dist' , FILE_NAME ),
32+ 'rb' ).read (), 'base64' , 'utf-8' )
33+ ATTACHMENT ["Content-Type" ] = 'application/octet-stream'
34+ ATTACHMENT ["Content-Disposition" ] = 'attachment; filename="{0}"' .format (
35+ FILE_NAME )
36+ MESSAGE .attach (ATTACHMENT )
37+
38+ try :
39+ smtp_client = smtplib .SMTP ('smtp.office365.com' , 587 )
40+ smtp_client .ehlo ()
41+ smtp_client .starttls ()
42+ smtp_client .login (SENDER , PASSWORD )
43+ smtp_client .sendmail (SENDER , RECEIVERS , MESSAGE .as_string ())
44+ except smtplib .SMTPException as error :
45+ print (error )
0 commit comments