Skip to content
Snippets Groups Projects
Commit eabf7677 authored by Mattia Mancini's avatar Mattia Mancini
Browse files

OSB-34: code cleanup.

parent 21f2e147
No related branches found
No related tags found
2 merge requests!89Monitoring maintenance Epic branch merge,!1Resolve OSB-13 "Monitoringmaintenance "
......@@ -180,4 +180,4 @@ REST_FRAMEWORK = {
CELERY_RESULT_BACKEND = 'amqp://guest@localhost//'
# LOFAR SPECIFIC PARAMETERS
URL_TO_RTSM_PLOTS = 'https://proxy.lofar.eu/rtsm/obs_plots/'
URL_TO_STORE_RTSM_PLOTS = '/home/mmancini/svn-tree/MonitoringMaintenance-OSB-32/build/gnucxx11_debug/plots'
\ No newline at end of file
URL_TO_STORE_RTSM_PLOTS = '/home/mmancini/svn-tree/MonitoringMaintenance-OSB-34/build/gnucxx11_debug/plots'
\ No newline at end of file
......@@ -117,6 +117,7 @@ class FilePathSerializer(serializers.Field):
file_name = os.path.relpath(self.path, data)
return file_name
class RTSMSummaryPlotSerializer(serializers.ModelSerializer):
uri = FilePathSerializer(settings.URL_TO_STORE_RTSM_PLOTS)
class Meta:
......
......@@ -5,6 +5,7 @@ from .views.station_test_views import *
from .views.rtsm_views import *
from .views.logs_view import *
from rest_framework.documentation import include_docs_urls
from django.urls import path
log_router = routers.DefaultRouter()
log_router.register(r'action_log', ActionLogViewSet)
......@@ -37,12 +38,13 @@ urlpatterns = [
url(r'^api/api-auth', include('rest_framework.urls', namespace='rest_framework')),
url(r'^api/stationtests/raw/insert', insert_raw_station_test),
url(r'^api/rtsm/raw/insert', insert_raw_rtsm_test),
url(r'^api/rtsm/error_summary_plot/(?P<pk>\d+)', get_summary_plot),
path('api/rtsm/error_summary_plot/<int:pk>', get_summary_plot, name='rtsm-summary-plot'),
url(r'^api/view/ctrl_stationoverview', ControllerStationOverview.as_view()),
url(r'^api/view/ctrl_stationtestsummary', ControllerStationTestsSummary.as_view()),
url(r'^api/view/ctrl_latest_observation', ControllerLatestObservations.as_view()),
url(r'^api/view/ctrl_stationtest_statistics', ControllerStationTestStatistics.as_view()),
url(r'^api/view/ctrl_list_component_error_types', ControllerAllComponentErrorTypes.as_view()),
url(r'^api/view/ctrl_station_component_errors', ControllerStationComponentErrors.as_view()),
url(r'^api/view/ctrl_station_component_element_errors', ControllerStationComponentElementErrors.as_view()),
url(r'^api/docs', include_docs_urls(title='Monitoring DB API'))
]
......@@ -42,11 +42,12 @@ def get_summary_plot(request, pk):
return HttpResponse('<h1>NOT FOUND</h1>', status=status.HTTP_404_NOT_FOUND)
try:
if(os.path.exists(uri) and os.path.isfile(uri)):
if os.path.exists(uri) and os.path.isfile(uri):
with open(uri, 'rb') as f_stream:
image = f_stream.read()
return HttpResponse(image, status=status.HTTP_200_OK, content_type='image/gif')
else:
check_error_summary_plot.delay(pk)
return HttpResponse('<h1>NOT FOUND</h1>', status=status.HTTP_404_NOT_FOUND)
except Exception as e:
return HttpResponse('exception %s occurred: %s' % (e.__class__.__name__, e),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment