Exemplo n.º 1
0
    def _initialize(self):
        try:
            self._initParameters()

            if self._viewType == self.VIEW_TYPE_DASHBOARD:
                # handle Xml vs. entity name
                logger.debug("dashboardName=%s dashboardXml=%s" % (self._dashboardName, self._dashboardXml))
                if self._dashboardXml != None:
                    (self._title, self._description, self._views) = pv.getDashboardTitleAndPanelsFromXml(
                        dashboardXml=self._dashboardXml,
                        namespace=self._namespace,
                        owner=self._owner,
                        sessionKey=self.sessionKey)
                elif self._dashboardName != None:
                    (self._title, self._description, self._views) = pv.getDashboardTitleAndPanels(
                        dashboard_name=self._dashboardName, 
                        namespace=self._namespace, 
                        owner=self._owner, 
                        sessionKey=self.sessionKey)
            elif self._viewType == self.VIEW_TYPE_REPORT:
                self._views.append(pv.Report(savedSearchName=self._reportName, namespace=self._namespace, owner=self._owner, sessionKey=self.sessionKey))
                self._title = self._reportName
            elif self._viewType == self.VIEW_TYPE_SEARCH:
                self._title = self._reportName
                self._views.append(pv.SearchReport(search=self._searchStr, et=self._et, lt=self._lt, title=self._title, namespace=self._namespace, owner=self._owner, sessionKey=self.sessionKey))

            self._handlePresetSearchIDs()
            
            # instantiate the pdfRenderer object with a file-like object
            self._pdfBuffer = cStringIO.StringIO()
            self._pdfRenderer = pdfrenderer.PDFRenderer(namespace=self._namespace, title=self._title,
                                                        description=self._description, outputFile=self._pdfBuffer,
                                                        paperSize=self._paperSize, timestamp=self._timestampStr,
                                                        includeSplunkLogo=self._includeSplunkLogo,
                                                        cidFontList=self._cidFontList, pdfSettings=self._pdfSettings,
                                                        requestSettings=self._requestSettings)
            return True
        except ArgError as e:
            self.response.setStatus(400)
            self.response.write(e.message)
        except Exception as e:
            errorMsg = "Bailing out of Integrated PDF Generation. Exception raised while preparing to render \"%s\" to PDF. %s" % (self._title, e)
            pu.logErrorAndTrace(errorMsg)
            self._outputError([errorMsg])
        return False
    def _initialize(self):
        try:
            self._initParameters()

            if self._viewType == self.VIEW_TYPE_DASHBOARD:

                # handle Xml vs. entity name

                logger.debug('dashboardName=%s dashboardXml=%s' %
                             (self._dashboardName, self._dashboardXml))
                if self._dashboardXml != None:
                    (self._title, self._description, self._views) = \
                        pv.getDashboardTitleAndPanelsFromXml(dashboardXml=self._dashboardXml,
                            namespace=self._namespace,
                            owner=self._owner,
                            sessionKey=self.sessionKey)
                elif self._dashboardName != None:
                    (self._title, self._description, self._views) = \
                        pv.getDashboardTitleAndPanels(dashboard_name=self._dashboardName,
                            namespace=self._namespace,
                            owner=self._owner,
                            sessionKey=self.sessionKey)
            elif self._viewType == self.VIEW_TYPE_REPORT:
                self._views.append(
                    pv.Report(savedSearchName=self._reportName,
                              namespace=self._namespace,
                              owner=self._owner,
                              sessionKey=self.sessionKey))
                self._title = self._reportName
            elif self._viewType == self.VIEW_TYPE_SEARCH:
                self._title = self._reportName
                self._views.append(
                    pv.SearchReport(
                        search=self._searchStr,
                        et=self._et,
                        lt=self._lt,
                        title=self._title,
                        namespace=self._namespace,
                        owner=self._owner,
                        sessionKey=self.sessionKey,
                    ))

            self._handlePresetSearchIDs()

            # instantiate the pdfRenderer object with a file-like object

            self._pdfBuffer = cStringIO.StringIO()
            self._pdfRenderer = pdfrenderer.PDFRenderer(
                namespace=self._namespace,
                title=self._title,
                description=self._description,
                outputFile=self._pdfBuffer,
                paperSize=self._paperSize,
                timestamp=self._timestampStr,
                includeSplunkLogo=self._includeSplunkLogo,
                cidFontList=self._cidFontList,
                pdfSettings=self._pdfSettings,
            )
            return True
        except ArgError, e:
            self.response.setStatus(400)
            self.response.write(e.message)