1
0
Fork 0

fix bare excepts

Upon fixing CI we now have a slew of PEP8 722 issues (bare excepts).  This MR fixes all of those by excepting Exception, which should catch anything the program generates while allowing systemexit exceptions.
merge-requests/222/head
Corey Shields 2018-07-14 13:42:17 -04:00
parent 1be5c99634
commit 44fee695b5
9 changed files with 18 additions and 18 deletions

View File

@ -28,7 +28,7 @@ class TransmitterSerializer(serializers.ModelSerializer):
def get_mode_id(self, obj):
try:
return obj.mode.id
except:
except Exception:
return None
def get_norad_cat_id(self, obj):
@ -53,13 +53,13 @@ class TelemetrySerializer(serializers.ModelSerializer):
def get_transmitter(self, obj):
try:
return obj.transmitter.uuid
except:
except Exception:
return ''
def get_schema(self, obj):
try:
return obj.payload_telemetry.schema
except:
except Exception:
return ''
def get_decoded(self, obj):

View File

@ -90,7 +90,7 @@ class SuggestionAdmin(admin.ModelAdmin):
message = render_to_string(template, {'data': data})
try:
obj.user.email_user(subject, message, from_email=settings.DEFAULT_FROM_EMAIL)
except:
except Exception:
logger.error(
'Could not send email to user',
exc_info=True
@ -110,7 +110,7 @@ class SuggestionAdmin(admin.ModelAdmin):
def transmitter_uuid(self, obj):
try:
return obj.transmitter.uuid
except:
except Exception:
return '-'
def transmitter_data(self, obj):

View File

@ -37,7 +37,7 @@ def gridsquare(lat, lng):
def get_apikey(user):
try:
token = Token.objects.get(user=user)
except:
except Exception:
token = Token.objects.create(user=user)
return token

View File

@ -30,17 +30,17 @@ class Command(BaseCommand):
Satellite.objects.get(norad_cat_id=item).delete()
self.stdout.write('Satellite {}: deleted'.format(item))
continue
except:
except Exception:
raise CommandError('Satellite with Identifier {} does not exist'.format(item))
try:
sat = satellite(item)
except:
except Exception:
raise CommandError('Satellite with Identifier {} does not exist'.format(item))
try:
obj = Satellite.objects.get(norad_cat_id=item)
except:
except Exception:
obj = Satellite(norad_cat_id=item)
obj.name = sat.name()

View File

@ -15,7 +15,7 @@ class Command(BaseCommand):
for obj in satellites:
try:
sat = satellite(obj.norad_cat_id)
except:
except Exception:
self.stdout.write(('Satellite {} with Identifier {} does '
'not exist').format(obj.name, obj.norad_cat_id))
continue

View File

@ -29,7 +29,7 @@ def _gen_observer(sender, instance, created, **kwargs):
post_save.disconnect(_gen_observer, sender=DemodData)
try:
qth = gridsquare(instance.lat, instance.lng)
except:
except Exception:
instance.observer = 'Unknown'
else:
instance.observer = '{0}-{1}'.format(instance.station, qth)
@ -195,7 +195,7 @@ class DemodData(models.Model):
def display_decoded(self):
try:
json.dumps(self.payload_decoded)
except:
except Exception:
'{}'
def display_frame(self):

View File

@ -30,7 +30,7 @@ def update_all_tle():
for obj in satellites:
try:
sat = satellite(obj.norad_cat_id)
except:
except Exception:
continue
tle = sat.tle()

View File

@ -39,7 +39,7 @@ def get_valid_satellites():
class ModeFactory(factory.django.DjangoModelFactory):
"""Mode model factory."""
name = fuzzy.FuzzyText()
name = fuzzy.FuzzyText(length=8)
class Meta:
model = Mode
@ -74,7 +74,7 @@ class TransmitterFactory(factory.django.DjangoModelFactory):
invert = fuzzy.FuzzyChoice(choices=[True, False])
baud = fuzzy.FuzzyInteger(4000, 22000, step=1000)
satellite = factory.SubFactory(SatelliteFactory)
approved = fuzzy.FuzzyChoice(choices=[True, False])
approved = True
class Meta:
model = Transmitter

View File

@ -65,7 +65,7 @@ def satellite_position(request, sat_id):
str(sat.tle1),
str(sat.tle2)
)
except:
except Exception:
data = {}
else:
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
@ -94,7 +94,7 @@ def satellite(request, norad):
try:
latest_frame = DemodData.objects.get(satellite=satellite,
timestamp=satellite.latest_payload_time)
except:
except Exception:
latest_frame = ''
return render(request, 'base/satellite.html', {'satellite': satellite,
@ -141,7 +141,7 @@ def suggestion(request):
for user in admins:
try:
user.email_user(subject, message, from_email=settings.DEFAULT_FROM_EMAIL)
except:
except Exception:
logger.error(
'Could not send email to user',
exc_info=True