Skip to content

Commit

Permalink
Upgrade gmail-connector and references
Browse files Browse the repository at this point in the history
Un-hook package version dependencies
  • Loading branch information
dormant-user committed Apr 4, 2023
1 parent e7fc09a commit d8faf1f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
7 changes: 0 additions & 7 deletions gen_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ set -e

branch="$(git rev-parse --abbrev-ref HEAD)"
checker=$(git diff --name-only `git merge-base $branch HEAD`)
if [[ ! $checker =~ "__init__.py" ]]; then
echo -e "\n********************************************************************ERROR********************************************************************"
echo "Docs generation was ABORTED since module version was not bumped!! Changelog generator requires the commit number and package version in sync."
echo -e "*********************************************************************************************************************************************\n"
exit 255
fi

if [[ ! $checker =~ "release_notes.rst" ]]; then
echo -e "\n********************************************************************ERROR**********************************************************"
echo "Docs generation was ABORTED since release notes was not updated!! Changelog generator requires the release notes to be in sync."
Expand Down
5 changes: 5 additions & 0 deletions release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Release Notes
=============

0.7.1 (02/11/2023)
------------------
- Upgrade `gmail-connector` and references
- Un-hook package version dependencies

0.7.0 (02/11/2023)
------------------
- Make `PEM_FILE` and `INFO_FILE` available at module level
Expand Down
2 changes: 1 addition & 1 deletion vpn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
from vpn.controller import (INFO_FILE, PEM_FILE, VPNServer, # noqa: F401
settings)

version = "0.7.0"
version = "0.9"
22 changes: 11 additions & 11 deletions vpn/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@

import boto3
import dotenv
import gmailconnector
import requests
import urllib3
from botocore.exceptions import ClientError
from gmailconnector import SendEmail, SendSMS
from gmailconnector.responder import Response
from urllib3.exceptions import InsecureRequestWarning

from .config import SSHConfig
Expand All @@ -27,7 +26,7 @@
urllib3.disable_warnings(InsecureRequestWarning) # Disable warnings for self-signed certificates

if os.path.isfile('.env'):
dotenv.load_dotenv(dotenv_path='.env', verbose=True, override=True)
dotenv.load_dotenv(dotenv_path='.env', verbose=False)
settings = Settings()

PEM_FILE = os.path.join(os.getcwd(), 'OpenVPN.pem')
Expand Down Expand Up @@ -761,23 +760,24 @@ def _notify(self, message: str, attachment: Optional[str] = None) -> None:
"""
subject = f"VPN Server::{datetime.now().strftime('%B %d, %Y %I:%M %p')}"
if self.recipient:
email_response = SendEmail(gmail_user=self.gmail_user,
gmail_pass=self.gmail_pass).send_email(recipient=self.recipient,
subject=subject, body=message,
sender='VPNServer', attachment=attachment)
email_response = gmailconnector.SendEmail(
gmail_user=self.gmail_user, gmail_pass=self.gmail_pass
).send_email(
recipient=self.recipient, subject=subject, body=message, sender='VPNServer', attachment=attachment
)
self._notification_response(response=email_response)
else:
self.logger.warning('ENV vars are not configured for an email notification.')

if self.phone:
sms_response = SendSMS(gmail_user=self.gmail_user,
gmail_pass=self.gmail_pass).send_sms(phone=self.phone, subject=subject,
message=message)
sms_response = gmailconnector.SendSMS(
gmail_user=self.gmail_user, gmail_pass=self.gmail_pass
).send_sms(phone=self.phone, subject=subject, message=message)
self._notification_response(response=sms_response)
else:
self.logger.warning('ENV vars are not configured for an SMS notification.')

def _notification_response(self, response: Response) -> NoReturn:
def _notification_response(self, response: gmailconnector.Response) -> NoReturn:
"""Logs the response after sending notifications.
Args:
Expand Down

0 comments on commit d8faf1f

Please sign in to comment.