Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #243: use the warnings module #491

Merged
merged 1 commit into from
Mar 2, 2023
Merged
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
12 changes: 9 additions & 3 deletions vertica_python/vertica/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import ssl
import getpass
import uuid
import warnings
from struct import unpack
from collections import deque, namedtuple
import random
Expand Down Expand Up @@ -518,7 +519,9 @@ def balance_load(self, raw_socket):
raw_socket = self.establish_socket_connection(self.address_list)
else:
self._logger.debug('<= LoadBalanceResponse: %s', response)
self._logger.warning("Load balancing requested but not supported by server")
no_load_balancing = "Load balancing requested but not supported by server"
warnings.warn(no_load_balancing)
self._logger.warning(no_load_balancing)

return raw_socket

Expand Down Expand Up @@ -646,6 +649,8 @@ def handle_asynchronous_message(self, message):
if getattr(self, 'notice_handler', None) is not None:
self.notice_handler(message)
else:
notice = f'[{message.severity}] {message.message}'
warnings.warn(notice)
self._logger.warning(message.error_message())

def read_string(self):
Expand Down Expand Up @@ -833,8 +838,9 @@ def startup_connection(self):
self._logger.error(msg)
raise errors.ConnectionError(msg)
elif message.code == messages.Authentication.PASSWORD_GRACE:
self._logger.warning('The password for user {} will expire soon.'
' Please consider changing it.'.format(self.options['user']))
password_grace = f'The password for user {self.options["user"]} will expire soon. Please consider changing it.'
warnings.warn(password_grace)
self._logger.warning(password_grace)
elif message.code == messages.Authentication.GSS:
self.make_GSS_authentication()
else:
Expand Down