diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 30c5a405..56623a8c 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -4,28 +4,28 @@ name: Build status on: - release: - types: [created] + release: + types: [created] jobs: - deploy: + deploy: + runs-on: ubuntu-latest - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py sdist bdist_wheel - twine upload dist/* + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.x" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install build twine + python -m pip install --editable . + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python -m build + twine upload dist/* diff --git a/.gitignore b/.gitignore index 4a453898..9f6f3f4a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,7 @@ F_BUILD/ AFEM.egg-info/ *.pyc secrets.txt -sendEmail.py +# sendEmail.py *.cpython-37.pyc *.csv *.log diff --git a/docs/source/conf.py b/docs/source/conf.py index 6a1659ea..ad5ea172 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -15,7 +15,7 @@ import sys sys.path.insert(0, os.path.abspath('../../src/')) sys.path.insert(0, os.path.abspath('../../')) -__version__ = importlib.metadata.version('FEM') +__version__ = importlib.metadata.version('AFEM') # -- Project information ----------------------------------------------------- project = 'FEM' diff --git a/sendEmail.py b/sendEmail.py new file mode 100644 index 00000000..6bb726af --- /dev/null +++ b/sendEmail.py @@ -0,0 +1,101 @@ +import smtplib +from email.utils import formataddr +from email.message import EmailMessage +from email.mime.application import MIMEApplication +from email.mime.text import MIMEText +from os.path import basename +from email.mime.multipart import MIMEMultipart + + +def sendMailOutlook(mss="Tu script ha finalizado de correr", secrests_path='secrets.txt', files=None): + """Envia un correo electrónico a travez de Outlook/Hotmial/Live. Se debe crear un archivos secrets.txt que contenga: + + Primera linea: correo electronico del que envia el mensaje. Ejemplo: espaiderman@hotmail.com + Segunda linea: contraseña del correo electrónico + Tercera linea: correo electrónico del destinatario. Ejemplo: fatman@gmail.com + + El archivo completo se ve así: + + espaiderman@hotmail.com + MeDanMiedoLosGatos + fatman@gmail.com + + Args: + mss (str, optional): Cuerpo del correo electrónico. Defaults to "Tu script ha finalizado de correr". + secrests_path (str, optional): Ruta al archivo secrets.txt . Defaults to 'secrets.txt'. + """ + + with open(secrests_path) as f: + e, p, r = f.readlines() + e = e.replace("\n", "") + p = p.replace("\n", "") + r = r.replace("\n", "") + y = {"sender_email": e, "password": p, "recipient_email": r} + + msg = MIMEMultipart() + msg['From'] = formataddr(('Python', y["sender_email"])) + msg['To'] = y['recipient_email'] + msg['Subject'] = "Tu script ha finalizado!" + msg.attach(MIMEText(mss)) + # 1/0 + for f in files or []: + with open(f, "rb") as fil: + part = MIMEApplication( + fil.read(), + Name=basename(f) + ) + # After the file is closed + part['Content-Disposition'] = 'attachment; filename="%s"' % basename(f) + msg.attach(part) + s = smtplib.SMTP("smtp-mail.outlook.com", 587) + # Hostname to send for this command defaults to the fully qualified domain name of the local host. + s.ehlo() + s.starttls() # Puts connection to SMTP server in TLS mode + s.ehlo() + s.login(y["sender_email"], y['password']) + s.sendmail(y["sender_email"], y["recipient_email"], msg.as_string()) + s.quit() + + +def sendMailGmail(mss="Tu script ha finalizado de correr", secrests_path='secrets.txt'): + """Envia un correo electrónico a travez de Gmail. Se debe crear un archivos secrets.txt que contenga: + + Primera linea: correo electronico del que envia el mensaje. Ejemplo: espaiderman@gmail.com + Segunda linea: contraseña del correo electrónico + Tercera linea: correo electrónico del destinatario. Ejemplo: fatman@gmail.com + + El archivo completo se ve así: + + espaiderman@gmail.com + MeDanMiedoLosGatos + fatman@gmail.com + + Args: + mss (str, optional): Cuerpo del correo electrónico. Defaults to "Tu script ha finalizado de correr". + secrests_path (str, optional): Ruta al archivo secrets.txt . Defaults to 'secrets.txt'. + """ + with open(secrests_path) as f: + e, p, r = f.readlines() + e = e.replace("\n", "") + p = p.replace("\n", "") + r = r.replace("\n", "") + y = {"sender_email": e, "password": p, "recipient_email": r} + + msg = EmailMessage() + msg['From'] = formataddr(('Python', y["sender_email"])) + msg['To'] = y['recipient_email'] + msg['Subject'] = "Tu script ha finalizado!" + msg.set_content(mss) + # 1/0 + s = smtplib.SMTP("smtp.gmail.com", 587) + # Hostname to send for this command defaults to the fully qualified domain name of the local host. + s.ehlo() + s.starttls() # Puts connection to SMTP server in TLS mode + s.ehlo() + s.login(y["sender_email"], y['password']) + s.sendmail(y["sender_email"], y["recipient_email"], msg.as_string()) + s.quit() + + +if __name__ == '__main__': + sendMailOutlook() diff --git a/src/FEM/__init__.py b/src/FEM/__init__.py index 60138c5f..060b5375 100644 --- a/src/FEM/__init__.py +++ b/src/FEM/__init__.py @@ -2,7 +2,7 @@ """ __author__ = "Arturo Rodriguez - da.rodriguezh@uniandes.edu.co" -__version__ = "1.0.30" +__version__ = "1.0.31" from .Elements import * from .Geometry import * from .Core import *