Skip to content

Commit

Permalink
Fix #305, bump version to 2.2.2 (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
glennmatthews authored Jun 4, 2024
1 parent 4f19532 commit 1717e92
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
6 changes: 5 additions & 1 deletion docs/admin/release_notes/version_2.2.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# v2.2 Release Notes

<!-- towncrier release notes start -->
## [v2.2.2 (2024-06-04)](https://github.com/nautobot/nautobot-app-circuit-maintenance/releases/tag/v2.2.2)

### Fixed

- [#305](https://github.com/nautobot/nautobot-app-circuit-maintenance/issues/305) - Fixed an error at startup if `exchangelib` is not installed.

## [v2.2.1 (2024-06-04)](https://github.com/nautobot/nautobot-app-circuit-maintenance/releases/tag/v2.2.1)

### Dependencies

- [#303](https://github.com/nautobot/nautobot-app-circuit-maintenance/issues/303) - Added backwards-compatibility with Pydantic 1.x.


## [v2.2.0 (2024-06-04)](https://github.com/nautobot/nautobot-app-circuit-maintenance/releases/tag/v2.2.0)

### Added
Expand Down
17 changes: 13 additions & 4 deletions nautobot_circuit_maintenance/handle_notifications/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
from typing import Union
from urllib.parse import urlparse

import exchangelib
try:
import exchangelib

EXCHANGELIB_PRESENT = True
except ImportError:
EXCHANGELIB_PRESENT = False
from django.conf import settings
from google.auth.exceptions import RefreshError
from google.auth.transport.requests import Request
Expand Down Expand Up @@ -109,7 +114,7 @@ def test_authentication(self) -> Tuple[bool, str]:
return is_authenticated, message

@classmethod
def init(cls: Type[T], name: str) -> T:
def init(cls: Type[T], name: str) -> T: # pylint: disable=too-many-branches
"""Factory Pattern to get the specific Source Class depending on the scheme."""
for notification_source in settings.PLUGINS_CONFIG.get("nautobot_circuit_maintenance", {}).get(
"notification_sources", []
Expand Down Expand Up @@ -137,6 +142,8 @@ def init(cls: Type[T], name: str) -> T:
source_header=config.get("source_header", "From"),
)
if scheme == "ews":
if not EXCHANGELIB_PRESENT:
raise ValueError("You must install 'exchangelib' to use the 'ews' scheme.")
return ExchangeWebService(
name=name,
url=url,
Expand Down Expand Up @@ -434,7 +441,7 @@ class ExchangeWebService(EmailSource):
password: str
server: str
folder: Optional[str] = None
session: Optional[exchangelib.Account] = None
session: Optional["exchangelib.Account"] = None

class Config:
"""Pydantic BaseModel config."""
Expand All @@ -443,6 +450,8 @@ class Config:

def open_session(self):
"""Open session to EWS server."""
if not EXCHANGELIB_PRESENT:
raise RuntimeError("You must install 'exchangelib' to use this source")
if not self.session:
credentials = exchangelib.Credentials(
username=self.authentication_user,
Expand Down Expand Up @@ -500,7 +509,7 @@ def receive_notifications(
def get_notification_from_item(
self,
job: Job,
item: exchangelib.items.message.Message,
item: "exchangelib.items.message.Message",
) -> Optional[MaintenanceNotification]:
"""Return a MaintenanceNotification derived from a give email item."""
msg_id = item.id
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 = "nautobot-circuit-maintenance"
version = "2.2.1"
version = "2.2.2"
description = "Nautobot app to automatically handle Circuit Maintenances Notifications"
authors = ["Network to Code, LLC <[email protected]>"]
license = "Apache-2.0"
Expand Down

0 comments on commit 1717e92

Please sign in to comment.