diff --git a/LCU/Maintenance/DBInterface/django_postgresql/settings.py b/LCU/Maintenance/DBInterface/django_postgresql/settings.py index 01e15ed33e960a7cb655331be2e552416e4fb914..f0cbc115e13e2de7587f28570be85cb08b7f7aa2 100644 --- a/LCU/Maintenance/DBInterface/django_postgresql/settings.py +++ b/LCU/Maintenance/DBInterface/django_postgresql/settings.py @@ -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 diff --git a/LCU/Maintenance/DBInterface/monitoringdb/serializers/rtsm.py b/LCU/Maintenance/DBInterface/monitoringdb/serializers/rtsm.py index 38640fdd33e39049294d191ef7c62995838db3cf..23ab677706c69ea23db45af20f9689ee0616af70 100644 --- a/LCU/Maintenance/DBInterface/monitoringdb/serializers/rtsm.py +++ b/LCU/Maintenance/DBInterface/monitoringdb/serializers/rtsm.py @@ -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: diff --git a/LCU/Maintenance/DBInterface/monitoringdb/urls.py b/LCU/Maintenance/DBInterface/monitoringdb/urls.py index 55302abc5295044a997a4d6edc16d2e0d241ebf6..d75e6d9c38932ed917a7a3d9fffeb84209596d77 100644 --- a/LCU/Maintenance/DBInterface/monitoringdb/urls.py +++ b/LCU/Maintenance/DBInterface/monitoringdb/urls.py @@ -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')) ] diff --git a/LCU/Maintenance/DBInterface/monitoringdb/views/rtsm_views.py b/LCU/Maintenance/DBInterface/monitoringdb/views/rtsm_views.py index 3cbf3109ebc8c1f10e6b07fc5ffe6a3758fdef9c..5649d10a18cba751ee82bf2d433c1a4857f0aa34 100644 --- a/LCU/Maintenance/DBInterface/monitoringdb/views/rtsm_views.py +++ b/LCU/Maintenance/DBInterface/monitoringdb/views/rtsm_views.py @@ -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),