linting for W0703
broad-except, I added explicit exceptions where I felt safe doing so - but we do have a lot of broad exceptions accepted. Signed-off-by: Corey Shields <cshields@gmail.com>merge-requests/399/head
parent
fe1f989d7b
commit
6bc64e9217
|
@ -49,14 +49,14 @@ class TransmitterSerializer(serializers.ModelSerializer):
|
|||
"""Returns mode ID"""
|
||||
try:
|
||||
return obj.mode.id
|
||||
except Exception:
|
||||
except Exception: # pylint: disable=broad-except
|
||||
return None
|
||||
|
||||
def get_mode(self, obj):
|
||||
"""Returns mode name"""
|
||||
try:
|
||||
return obj.mode.name
|
||||
except Exception:
|
||||
except Exception: # pylint: disable=broad-except
|
||||
return None
|
||||
|
||||
def get_norad_cat_id(self, obj):
|
||||
|
@ -87,7 +87,7 @@ class TelemetrySerializer(serializers.ModelSerializer):
|
|||
"""Returns Transmitter UUID"""
|
||||
try:
|
||||
return obj.transmitter.uuid
|
||||
except Exception:
|
||||
except Exception: # pylint: disable=broad-except
|
||||
return ''
|
||||
|
||||
# TODO: this is a relic of the old data decoding method, needs revisiting
|
||||
|
@ -95,7 +95,7 @@ class TelemetrySerializer(serializers.ModelSerializer):
|
|||
"""Returns Transmitter telemetry schema"""
|
||||
try:
|
||||
return obj.payload_telemetry.schema
|
||||
except Exception:
|
||||
except Exception: # pylint: disable=broad-except
|
||||
return ''
|
||||
|
||||
# TODO: this is a relic of the old data decoding method, needs revisiting
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from __future__ import absolute_import, division, print_function, \
|
||||
unicode_literals
|
||||
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from rest_framework.authtoken.models import Token
|
||||
|
||||
UPPER = 'ABCDEFGHIJKLMNOPQRSTUVWX'
|
||||
|
@ -52,6 +53,6 @@ def get_apikey(user):
|
|||
"""
|
||||
try:
|
||||
token = Token.objects.get(user=user)
|
||||
except Exception:
|
||||
except ObjectDoesNotExist:
|
||||
token = Token.objects.create(user=user)
|
||||
return token
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from __future__ import absolute_import, division, print_function, \
|
||||
unicode_literals
|
||||
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from db.base.models import Satellite
|
||||
|
@ -21,5 +22,5 @@ class Command(BaseCommand):
|
|||
Satellite.objects.get(norad_cat_id=norad_id).delete()
|
||||
self.stdout.write('Deleted satellite {}.'.format(norad_id))
|
||||
continue
|
||||
except Exception:
|
||||
except ObjectDoesNotExist:
|
||||
self.stderr.write('Satellite with Identifier {} does not exist'.format(norad_id))
|
||||
|
|
|
@ -49,7 +49,7 @@ def _gen_observer(sender, instance, created, **kwargs): # pylint: disable=W0613
|
|||
post_save.disconnect(_gen_observer, sender=DemodData)
|
||||
try:
|
||||
qth = gridsquare(instance.lat, instance.lng)
|
||||
except Exception:
|
||||
except Exception: # pylint: disable=broad-except
|
||||
instance.observer = 'Unknown'
|
||||
else:
|
||||
instance.observer = '{0}-{1}'.format(instance.station, qth)
|
||||
|
|
|
@ -170,5 +170,7 @@ def decode_recent_data():
|
|||
for obj in satellites:
|
||||
try:
|
||||
decode_data(obj.norad_cat_id, period=1)
|
||||
except Exception:
|
||||
except Exception: # pylint: disable=broad-except
|
||||
# an object could have failed decoding for a number of reasons,
|
||||
# keep going
|
||||
continue
|
||||
|
|
|
@ -227,14 +227,14 @@ def decode_data(norad, period=None):
|
|||
obj.is_decoded = True
|
||||
obj.save()
|
||||
break
|
||||
except Exception:
|
||||
except Exception: # pylint: disable=broad-except
|
||||
obj.is_decoded = False
|
||||
obj.save()
|
||||
continue
|
||||
else: # store in the local db instead of influx
|
||||
try:
|
||||
frame = decoder_class.from_bytes(bindata)
|
||||
except Exception:
|
||||
except Exception: # pylint: disable=broad-except
|
||||
obj.payload_decoded = ''
|
||||
obj.is_decoded = False
|
||||
obj.save()
|
||||
|
|
|
@ -10,6 +10,7 @@ from django.contrib.auth.decorators import login_required
|
|||
from django.contrib.auth.models import User
|
||||
from django.contrib.sites.shortcuts import get_current_site
|
||||
from django.core.cache import cache
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.db import OperationalError
|
||||
from django.http import HttpResponse, HttpResponseNotFound, \
|
||||
HttpResponseServerError, JsonResponse
|
||||
|
@ -105,7 +106,7 @@ def satellite(request, norad):
|
|||
|
||||
try:
|
||||
latest_frame = DemodData.objects.filter(satellite=satellite_obj).order_by('-id')[0]
|
||||
except Exception:
|
||||
except ObjectDoesNotExist:
|
||||
latest_frame = ''
|
||||
|
||||
return render(
|
||||
|
@ -179,7 +180,7 @@ def transmitter_suggestion(request):
|
|||
for user in admins:
|
||||
try:
|
||||
user.email_user(subject, message, from_email=settings.DEFAULT_FROM_EMAIL)
|
||||
except Exception:
|
||||
except Exception: # pylint: disable=broad-except
|
||||
LOGGER.error('Could not send email to user', exc_info=True)
|
||||
|
||||
messages.success(
|
||||
|
|
Loading…
Reference in New Issue