Beispiel #1
0
    def _get_screenshot(self) -> ScreenshotData:
        """
        Get a chart or dashboard screenshot

        :raises: ReportScheduleScreenshotFailedError
        """
        screenshot: Optional[BaseScreenshot] = None
        if self._report_schedule.chart:
            url = self._get_url(standalone="true")
            screenshot = ChartScreenshot(
                url,
                self._report_schedule.chart.digest,
                window_size=app.config["WEBDRIVER_WINDOW"]["slice"],
                thumb_size=app.config["WEBDRIVER_WINDOW"]["slice"],
            )
        else:
            url = self._get_url()
            screenshot = DashboardScreenshot(
                url,
                self._report_schedule.dashboard.digest,
                window_size=app.config["WEBDRIVER_WINDOW"]["dashboard"],
                thumb_size=app.config["WEBDRIVER_WINDOW"]["dashboard"],
            )
        image_url = self._get_url(user_friendly=True)
        user = self._get_screenshot_user()
        image_data = screenshot.compute_and_cache(
            user=user,
            cache=thumbnail_cache,
            force=True,
        )
        if not image_data:
            raise ReportScheduleScreenshotFailedError()
        return ScreenshotData(url=image_url, image=image_data)
    def _get_screenshot(self) -> ScreenshotData:
        """
        Get a chart or dashboard screenshot

        :raises: ReportScheduleScreenshotFailedError
        """
        screenshot: Optional[BaseScreenshot] = None
        if self._report_schedule.chart:
            url = self._get_url(standalone="true")
            screenshot = ChartScreenshot(
                url,
                self._report_schedule.chart.digest,
                window_size=app.config["WEBDRIVER_WINDOW"]["slice"],
                thumb_size=app.config["WEBDRIVER_WINDOW"]["slice"],
            )
        else:
            url = self._get_url()
            screenshot = DashboardScreenshot(
                url,
                self._report_schedule.dashboard.digest,
                window_size=app.config["WEBDRIVER_WINDOW"]["dashboard"],
                thumb_size=app.config["WEBDRIVER_WINDOW"]["dashboard"],
            )
        image_url = self._get_url(user_friendly=True)
        user = self._get_screenshot_user()
        try:
            image_data = screenshot.get_screenshot(user=user)
        except SoftTimeLimitExceeded:
            raise ReportScheduleScreenshotTimeout()
        except Exception as ex:
            raise ReportScheduleScreenshotFailedError(
                f"Failed taking a screenshot {str(ex)}")
        if not image_data:
            raise ReportScheduleScreenshotFailedError()
        return ScreenshotData(url=image_url, image=image_data)
Beispiel #3
0
 def _get_screenshot(self, report_schedule: ReportSchedule) -> ScreenshotData:
     """
     Get a chart or dashboard screenshot
     :raises: ReportScheduleScreenshotFailedError
     """
     url = self._get_url(report_schedule)
     screenshot: Optional[BaseScreenshot] = None
     if report_schedule.chart:
         screenshot = ChartScreenshot(url, report_schedule.chart.digest)
     else:
         screenshot = DashboardScreenshot(url, report_schedule.dashboard.digest)
     image_url = self._get_url(report_schedule, user_friendly=True)
     user = security_manager.find_user(app.config["THUMBNAIL_SELENIUM_USER"])
     image_data = screenshot.compute_and_cache(
         user=user, cache=thumbnail_cache, force=True,
     )
     if not image_data:
         raise ReportScheduleScreenshotFailedError()
     return ScreenshotData(url=image_url, image=image_data)
Beispiel #4
0
 def _get_screenshot(self) -> ScreenshotData:
     """
     Get a chart or dashboard screenshot
     :raises: ReportScheduleScreenshotFailedError
     """
     url = self._get_url()
     screenshot: Optional[BaseScreenshot] = None
     if self._report_schedule.chart:
         screenshot = ChartScreenshot(url, self._report_schedule.chart.digest)
     else:
         screenshot = DashboardScreenshot(
             url, self._report_schedule.dashboard.digest
         )
     image_url = self._get_url(user_friendly=True)
     user = self._get_screenshot_user()
     image_data = screenshot.compute_and_cache(
         user=user, cache=thumbnail_cache, force=True,
     )
     if not image_data:
         raise ReportScheduleScreenshotFailedError()
     return ScreenshotData(url=image_url, image=image_data)