Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion patchwork/steps/CallSQL/CallSQL.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __build_engine(self, inputs: dict):
**{k: v for k, v in kwargs.items() if v is not None},
)

connect_args = None
connect_args = dict()
if inputs.get("db_driver_args") is not None:
connect_args = parse_to_dict(inputs.get("db_driver_args"))

Expand Down
34 changes: 34 additions & 0 deletions patchwork/steps/SendEmail/SendEmail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from __future__ import annotations

import smtplib
from email.mime.text import MIMEText

from patchwork.common.utils.utils import mustache_render
from patchwork.step import Step
from patchwork.steps.SendEmail.typed import SendEmailInputs, SendEmailOutputs


class SendEmail(Step, input_class=SendEmailInputs, output_class=SendEmailOutputs):
def __init__(self, inputs):
super().__init__(inputs)
self.email_template_value = inputs.get("email_template_value", dict())
self.subject = inputs.get("subject", "Patchwork Execution Email")
self.body = inputs.get("body", "Patchwork Execution Email")
self.sender_email = inputs["sender_email"]
self.recipient_email = inputs["recipient_email"]
self.password = inputs["sender_email_password"]
self.smtp_host = inputs.get("smtp_host", "smtp.gmail.com")
self.smtp_port = int(inputs.get("smtp_port", 465))

def run(self) -> dict:
msg = MIMEText(mustache_render(self.body, self.email_template_value))
msg["Subject"] = mustache_render(self.subject, self.email_template_value)
msg["From"] = self.sender_email
msg["To"] = self.recipient_email

# TODO: support smtp without ssl
with smtplib.SMTP_SSL(self.smtp_host, self.smtp_port) as smtp_server:
smtp_server.login(self.sender_email, self.password)
smtp_server.sendmail(self.sender_email, self.recipient_email, msg.as_string())

return dict()
Empty file.
21 changes: 21 additions & 0 deletions patchwork/steps/SendEmail/typed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from typing_extensions import Annotated, Any, Dict, TypedDict

from patchwork.common.utils.step_typing import StepTypeConfig


class __SendEmailRequiredInputs(TypedDict):
sender_email: str
recipient_email: str
sender_email_password: str


class SendEmailInputs(__SendEmailRequiredInputs, total=False):
email_template_value: dict[str, Any]
subject: str
body: str
smtp_host: str
smtp_port: int


class SendEmailOutputs(TypedDict):
pass
2 changes: 2 additions & 0 deletions patchwork/steps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from patchwork.steps.ScanDepscan.ScanDepscan import ScanDepscan
from patchwork.steps.ScanSemgrep.ScanSemgrep import ScanSemgrep
from patchwork.steps.ScanSonar.ScanSonar import ScanSonar
from patchwork.steps.SendEmail.SendEmail import SendEmail
from patchwork.steps.SimplifiedLLM.SimplifiedLLM import SimplifiedLLM
from patchwork.steps.SimplifiedLLMOnce.SimplifiedLLMOnce import SimplifiedLLMOnce
from patchwork.steps.SlackMessage.SlackMessage import SlackMessage
Expand Down Expand Up @@ -99,6 +100,7 @@
"ScanDepscan",
"ScanSemgrep",
"ScanSonar",
"SendEmail",
"SimplifiedLLM",
"SimplifiedLLMOnce",
"SimplifiedLLMOncePB",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "patchwork-cli"
version = "0.0.97"
version = "0.0.98"
description = ""
authors = ["patched.codes"]
license = "AGPL"
Expand Down