Skip to content

Commit

Permalink
Merge pull request #3581 from rtibbles/never_flitting_still_is_sitting
Browse files Browse the repository at this point in the history
Remove deprecated Raven pip dependency.
  • Loading branch information
bjester authored Aug 29, 2022
2 parents 2809cf8 + d05c147 commit 269e7e0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
24 changes: 12 additions & 12 deletions contentcuration/contentcuration/views/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from le_utils.constants.labels.resource_type import RESOURCETYPELIST
from le_utils.constants.labels.subjects import SUBJECTSLIST
from past.builtins import basestring
from raven.contrib.django.raven_compat.models import client
from rest_framework import status
from rest_framework.authentication import SessionAuthentication
from rest_framework.authentication import TokenAuthentication
Expand All @@ -32,6 +31,7 @@
from rest_framework.decorators import permission_classes
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from sentry_sdk import capture_exception

from contentcuration import ricecooker_versions as rc
from contentcuration.api import activate_channel
Expand Down Expand Up @@ -79,8 +79,8 @@ class NodeValidationError(ValidationError):
pass


def handle_server_error(request):
client.captureException(stack=True, tags={"url": request.path})
def handle_server_error(e, request):
capture_exception(e, tags={"url": request.path})


@api_view(["POST", "GET"])
Expand Down Expand Up @@ -177,7 +177,7 @@ def api_file_upload(request):
except KeyError:
return HttpResponseBadRequest("Invalid file upload request")
except Exception as e:
handle_server_error(request)
handle_server_error(e, request)
return HttpResponseServerError(content=str(e), reason=str(e))


Expand All @@ -200,7 +200,7 @@ def api_create_channel_endpoint(request):
except KeyError:
return HttpResponseBadRequest("Required attribute missing from data: {}".format(data))
except Exception as e:
handle_server_error(request)
handle_server_error(e, request)
return HttpResponseServerError(content=str(e), reason=str(e))


Expand Down Expand Up @@ -261,7 +261,7 @@ def api_commit_channel(request):
except KeyError:
return HttpResponseBadRequest("Required attribute missing from data: {}".format(data))
except Exception as e:
handle_server_error(request)
handle_server_error(e, request)
return HttpResponseServerError(content=str(e), reason=str(e))


Expand Down Expand Up @@ -307,7 +307,7 @@ def api_add_nodes_to_tree(request):
except NodeValidationError as e:
return HttpResponseBadRequest(str(e))
except Exception as e:
handle_server_error(request)
handle_server_error(e, request)
return HttpResponseServerError(content=str(e), reason=str(e))


Expand Down Expand Up @@ -336,7 +336,7 @@ def api_publish_channel(request):
except (KeyError, Channel.DoesNotExist):
return HttpResponseNotFound("No channel matching: {}".format(data))
except Exception as e:
handle_server_error(request)
handle_server_error(e, request)
return HttpResponseServerError(content=str(e), reason=str(e))


Expand All @@ -353,7 +353,7 @@ def activate_channel_internal(request):
except Channel.DoesNotExist:
return HttpResponseNotFound("No channel matching: {}".format(channel_id))
except Exception as e:
handle_server_error(request)
handle_server_error(e, request)
return HttpResponseServerError(content=str(e), reason=str(e))


Expand Down Expand Up @@ -402,7 +402,7 @@ def get_tree_data(request):
except ValueError:
return HttpResponseNotFound("No tree name matching: {}".format(tree_name))
except Exception as e:
handle_server_error(request)
handle_server_error(e, request)
return HttpResponseServerError(content=str(e), reason=str(e))


Expand Down Expand Up @@ -442,7 +442,7 @@ def get_node_tree_data(request):
except Channel.DoesNotExist:
return HttpResponseNotFound("No channel matching: {}".format(channel_id))
except Exception as e:
handle_server_error(request)
handle_server_error(e, request)
return HttpResponseServerError(content=str(e), reason=str(e))


Expand All @@ -467,7 +467,7 @@ def get_channel_status_bulk(request):
except KeyError:
raise ObjectDoesNotExist("Missing attribute from data: {}".format(data))
except Exception as e:
handle_server_error(request)
handle_server_error(e, request)
return HttpResponseServerError(content=str(e), reason=str(e))


Expand Down
6 changes: 3 additions & 3 deletions contentcuration/contentcuration/views/zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from django.views.decorators.clickjacking import xframe_options_exempt
from django.views.generic.base import View
from le_utils.constants import exercises
from raven.contrib.django.raven_compat.models import client
from sentry_sdk import capture_message
from webpack_loader.utils import get_files

from contentcuration.models import generate_object_storage_name
Expand Down Expand Up @@ -112,7 +112,7 @@ def options(self, request, *args, **kwargs):
return response

@xframe_options_exempt # noqa
def get(self, request, zipped_filename, embedded_filepath):
def get(self, request, zipped_filename, embedded_filepath): # noqa: C901
"""
Handles GET requests and serves a static file from within the zip file.
"""
Expand Down Expand Up @@ -174,7 +174,7 @@ def get(self, request, zipped_filename, embedded_filepath):
file_size = len(content_with_path)
except zipfile.BadZipfile:
just_downloaded = getattr(zf_obj, 'just_downloaded', "Unknown (Most likely local file)")
client.captureMessage("Unable to open zip file. File info: name={}, size={}, mode={}, just_downloaded={}".format(
capture_message("Unable to open zip file. File info: name={}, size={}, mode={}, just_downloaded={}".format(
zf_obj.name, zf_obj.size, zf_obj.mode, just_downloaded))
return HttpResponseServerError(
"Attempt to open zip file failed. Please try again, and if you continue to receive this message, please check that the zip file is valid."
Expand Down
1 change: 0 additions & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ django-redis
django-prometheus
future
sentry-sdk
raven
django-bulk-update
html5lib==1.1
pillow==9.2.0
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,6 @@ pytz==2022.1
# django
# django-postmark
# google-api-core
raven==6.10.0
# via -r requirements.in
redis==3.5.3
# via
# -r requirements.in
Expand Down

0 comments on commit 269e7e0

Please sign in to comment.