Skip to content

Commit

Permalink
Miscellaneous fixes
Browse files Browse the repository at this point in the history
- Don't parse non-python files/modules
- Enrich sendgrid debug messages
- Remove unnecessary packages from setup.py
  • Loading branch information
subhashb committed Oct 2, 2021
1 parent 90ab253 commit 41be6ac
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ def read(*names, **kwargs):

testing_requires = all_external_requires + [
"mock==4.0.2",
"passlib==1.7.2",
"pluggy==0.13.1",
"pyjwt==1.7.1",
"pytest-asyncio>=0.15.1",
"pytest-cov==2.8.1",
"pytest-flake8>=1.0.7",
Expand Down
8 changes: 6 additions & 2 deletions src/protean/adapters/email/sendgrid.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""" Define the send-grid email provider """
import logging

from python_http_client.exceptions import HTTPError
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail, TemplateId

Expand Down Expand Up @@ -31,11 +32,14 @@ def send_email(self, message, dynamic_template=False):

if response.status_code != 202:
logger.error(
f"Error encountered while sending Email: {response.status_code}"
f"Failure: ({response.status_code}) - "
f"{response.reason} - {response.body}"
)

logger.debug("Email pushed to SendGrid successfully.")
except HTTPError as e:
logger.error(f"{e}: {e.to_dict}")
except Exception as e:
logger.error(f"Error encountered while sending Email: {e}")
logger.error(f"Exception: Error while sending email: {e}")

return True
4 changes: 4 additions & 0 deletions src/protean/domain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ def init(self):
for file in files:
file_base_name = os.path.basename(file)

# Ignore if the file is not a python file
if os.path.splitext(file_base_name)[1] != ".py":
continue

# Construct the module path to import from
if file_base_name != "__init__":
sub_module_name = os.path.splitext(file_base_name)[0]
Expand Down

0 comments on commit 41be6ac

Please sign in to comment.