Replace deprecated Logging.warn calls with Logging.warning.

This commit is contained in:
derAnfaenger
2017-10-02 11:11:42 +02:00
parent 7d63928fe1
commit d1afab7199
6 changed files with 12 additions and 12 deletions

View File

@@ -137,7 +137,7 @@ def sanity_check_output(data):
for table in tables: for table in tables:
if table not in data: if table not in data:
logging.warn('??? NO DATA EXPORTED FOR TABLE %s!!!' % (table,)) logging.warning('??? NO DATA EXPORTED FOR TABLE %s!!!' % (table,))
def write_data_to_file(output_file, data): def write_data_to_file(output_file, data):
# type: (Path, Any) -> None # type: (Path, Any) -> None

View File

@@ -112,8 +112,8 @@ def send_apple_push_notification(user_id, devices, payload_data):
try: try:
return client.get_notification_result(stream_id) return client.get_notification_result(stream_id)
except HTTP20Error as e: except HTTP20Error as e:
logging.warn("APNs: HTTP error sending for user %d to device %s: %s", logging.warning("APNs: HTTP error sending for user %d to device %s: %s",
user_id, device.token, e.__class__.__name__) user_id, device.token, e.__class__.__name__)
return None return None
result = attempt_send() result = attempt_send()
@@ -127,8 +127,8 @@ def send_apple_push_notification(user_id, devices, payload_data):
logging.info("APNs: Success sending for user %d to device %s", logging.info("APNs: Success sending for user %d to device %s",
user_id, device.token) user_id, device.token)
else: else:
logging.warn("APNs: Failed to send for user %d to device %s: %s", logging.warning("APNs: Failed to send for user %d to device %s: %s",
user_id, device.token, result) user_id, device.token, result)
# TODO delete token if status 410 (and timestamp isn't before # TODO delete token if status 410 (and timestamp isn't before
# the token we have) # the token we have)

View File

@@ -53,7 +53,7 @@ Usage: ./manage.py deliver_email
send_email(**loads(job.data)) send_email(**loads(job.data))
job.delete() job.delete()
except EmailNotDeliveredException: except EmailNotDeliveredException:
logger.warn("%r not delivered" % (job,)) logger.warning("%r not delivered" % (job,))
time.sleep(10) time.sleep(10)
else: else:
# Less load on the db during times of activity, and more responsiveness when the load is low # Less load on the db during times of activity, and more responsiveness when the load is low

View File

@@ -39,7 +39,7 @@ class Command(BaseCommand):
This process is watched by Django's autoreload, so exiting This process is watched by Django's autoreload, so exiting
with status code 3 will cause this process to restart. with status code 3 will cause this process to restart.
""" """
logger.warn("SIGUSR1 received. Restarting this queue processor.") logger.warning("SIGUSR1 received. Restarting this queue processor.")
sys.exit(3) sys.exit(3)
if not settings.USING_RABBITMQ: if not settings.USING_RABBITMQ:

View File

@@ -349,7 +349,7 @@ class HandlePushNotificationTest(PushNotificationTest):
mock.patch('zerver.lib.push_notifications.gcm') as mock_gcm, \ mock.patch('zerver.lib.push_notifications.gcm') as mock_gcm, \
mock.patch('zerver.lib.push_notifications._apns_client') as mock_apns, \ mock.patch('zerver.lib.push_notifications._apns_client') as mock_apns, \
mock.patch('logging.info') as mock_info, \ mock.patch('logging.info') as mock_info, \
mock.patch('logging.warn'): mock.patch('logging.warning'):
apns_devices = [ apns_devices = [
(apn.b64_to_hex(device.token), device.ios_app_id, device.token) (apn.b64_to_hex(device.token), device.ios_app_id, device.token)
for device in RemotePushDeviceToken.objects.filter( for device in RemotePushDeviceToken.objects.filter(
@@ -556,7 +556,7 @@ class TestAPNs(PushNotificationTest):
mock.patch('zerver.lib.push_notifications.logging') as mock_logging: mock.patch('zerver.lib.push_notifications.logging') as mock_logging:
mock_apns.get_notification_result.return_value = 'Success' mock_apns.get_notification_result.return_value = 'Success'
self.send() self.send()
mock_logging.warn.assert_not_called() mock_logging.warning.assert_not_called()
for device in self.devices(): for device in self.devices():
mock_logging.info.assert_any_call( mock_logging.info.assert_any_call(
"APNs: Success sending for user %d to device %s", "APNs: Success sending for user %d to device %s",
@@ -571,7 +571,7 @@ class TestAPNs(PushNotificationTest):
[hyper.http20.exceptions.StreamResetError()], [hyper.http20.exceptions.StreamResetError()],
itertools.repeat('Success')) itertools.repeat('Success'))
self.send() self.send()
mock_logging.warn.assert_called_once_with( mock_logging.warning.assert_called_once_with(
"APNs: HTTP error sending for user %d to device %s: %s", "APNs: HTTP error sending for user %d to device %s: %s",
self.user_profile.id, self.devices()[0].token, "StreamResetError") self.user_profile.id, self.devices()[0].token, "StreamResetError")
for device in self.devices(): for device in self.devices():

View File

@@ -420,7 +420,7 @@ def get_event(request, payload, branches):
return 'assigned_or_unassigned_pull_request' return 'assigned_or_unassigned_pull_request'
if action == 'closed': if action == 'closed':
return 'closed_pull_request' return 'closed_pull_request'
logging.warn(u'Event pull_request with {} action is unsupported'.format(action)) logging.warning(u'Event pull_request with {} action is unsupported'.format(action))
return None return None
if event == 'push': if event == 'push':
if is_commit_push_event(payload): if is_commit_push_event(payload):
@@ -433,7 +433,7 @@ def get_event(request, payload, branches):
return "push_tags" return "push_tags"
elif event in list(EVENT_FUNCTION_MAPPER.keys()) or event == 'ping': elif event in list(EVENT_FUNCTION_MAPPER.keys()) or event == 'ping':
return event return event
logging.warn(u'Event {} is unknown and cannot be handled'.format(event)) logging.warning(u'Event {} is unknown and cannot be handled'.format(event))
return None return None
def get_body_function_based_on_type(type): def get_body_function_based_on_type(type):