Esempio n. 1
0
    def getDocumentData(self, meetingID, docID, strictJSON=False):
        slidedeckArchive = osconfig.slidedeckArchive()
        [installationID, dimdimID] = osconfig.splitIdentity(meetingID)
        meetingID = installationID + '____' + dimdimID
        jsonSuccess = jsonObject()
        jsonSuccess.clearResponse()
        jsonSuccess.add('result', 'true')
        jsonSuccess.add('method', 'getDocumentData')
        jsonSuccess.add('meetingID', meetingID)
        entries = self.findDocuments(slidedeckArchive, meetingID, docID)
        
        strictSuccess = {'result' : 'true', 'method' : 'getDocumentData', 'meetingID' : meetingID}

        if len(entries) == 0:
            if not strictJSON:
                jsonError = jsonObject()
                jsonError.clearResponse()
                jsonError.add('result', 'false')
                jsonError.add('method', 'getDocumentData')
                jsonError.add('meetingID', meetingID)
                jsonError.add('docID', docID)
                jsonError.add('error', '7404')
                return jsonError.jsonResponse()
            else:
                strictError = {'result':'false', 'method':'getDocumentData', 'meetingID':meetingID, 'docID':docID, 'error':7404}
                response = self.demHelper.encode(strictError)
                return response.encode()

        if not strictJSON:
            for i in range(0, len(entries)):
                fp = serialObject()
                fp.clearBuffer()
                fp.importData(entries[i])
                #jsonSuccess.add('docName', fp.get('docName'))
                jsonSuccess.add('docID', docID)
                jsonSuccess.add('docName', fp.get('docName'))
                jsonSuccess.add('noOfPages', string.atoi(fp.get('noOfPages')))
                jsonSuccess.add('width', fp.get('width'))
                jsonSuccess.add('height', fp.get('height'))
            jsonSuccess.add('error', '7200')
            return jsonSuccess.jsonResponse()
        else:
            for i in range(0, len(entries)):
                fp = serialObject()
                fp.clearBuffer()
                fp.importData(entries[i])
                strictSuccess.update({'docID':docID, 'docName':fp.get('docName'), 'noOfPages' : string.atoi(fp.get('noOfPages')), \
                                      'width': string.atoi(fp.get('width')), 'height': string.atoi(fp.get('height'))})
                
            response = self.demHelper.encode(strictSuccess)
            return response.encode()
Esempio n. 2
0
    def uploadPPTXSlide(self, docFile, meetingID, docID, docName, pageNo, noOfPages):
        # 'Type' will be 'regular', becuase PPTX slides are uploaded by the presenter
        # There is no conversion involved in this operation. We just need to commit this file to archive

        iPageNo = string.atoi(pageNo)
        iNoOfPages = string.atoi(noOfPages)

        jsonComplete = jsonObject()
        jsonComplete.clearResponse()
        jsonComplete.add('result', 'true')
        jsonComplete.add('method', 'uploadPPTXSlide')
        jsonComplete.add('docID', docID)

        slidedeckArchive = osconfig.slidedeckArchive()
        specArchive = os.path.join(slidedeckArchive, meetingID)

        if docID == 'GENERATE' or docID == '':
            docID = idgen.gen()

        specArchive = os.path.join(specArchive, docID)

        if not os.path.isdir(specArchive):
            os.makedirs(specArchive)

        storedFileName = os.path.join(specArchive, pageNo)
        storedFileName += ".jpg"

        if sys.platform.startswith('win'):
            storedFile = open(storedFileName, 'wb')
        else:
            storedFile = open(storedFileName, 'w')
        while True:
            data = docFile.file.read(8192)
            if not data:
                break
            storedFile.write(data)

        storedFile.close()

        if (iPageNo == iNoOfPages - 1):
            # store some details for probable future use
            storeObject = filehelper.serialObject()
            storeObject.clearBuffer()
            storeObject.add('docName', docName)
            storeObject.add('docID',docID)
            storeObject.add('noOfPages',noOfPages)
            dataStore = os.path.join(specArchive, 'documentData.txt');
            storeObject.exportData(dataStore)

            jsonComplete.add('complete', 'true')
            return jsonComplete.jsonResponse()

        jsonComplete.add('complete', 'false')
        return jsonComplete.jsonResponse()
Esempio n. 3
0
    def convertDocument(self):
        storePath = ''
        #print 'in convert document'
        try:
            storePath = self.getPDFLocation()
            #print storePath
        except:
            cherrypy.log(
                'Conversion could have been cancelled... meeting ID = ' +
                self.meetingID + ' and docID = ' + self.docID)
            if self.getErrorCode() == 7200:
                self.setErrorCode(7406)
            return

        if storePath == '':
            tempError = self.getErrorCode()
            self.setErrorCode(tempError)
            return

        if self.getConversionState() == 'CANCELLED':
            return

        retval = self.pdfAcquire()
        if not retval:
            if self.getErrorCode() == 7200:
                self.setErrorCode(7406)
            return

        cherrypy.log(
            'PDF available. Proceeding to SWF creation... meeting ID = ' +
            self.meetingID + ' and docID = ' + self.docID)
        if sys.platform.startswith('win'):
            infile = storePath + '\\conv.pdf'
        else:
            infile = storePath + 'conv.pdf'
#        print infile
        if self.getConversionState() == 'CANCELLED':
            return

        cherrypy.log('Retrieving page count... meeting ID = ' +
                     self.meetingID + ' and docID = ' + self.docID)
        self.getPageCount(storePath)

        if self.totalPageCount == 0:
            cherrypy.log('Invalid page count... meeting ID = ' +
                         self.meetingID + ' and docID = ' + self.docID)
            if (self.getErrorCode() != 7901 and self.getErrorCode() != 7902):
                self.setErrorCode(7406)
            self.pdfRelease()

            return

        if self.getConversionState() == 'CANCELLED':
            return

        cherrypy.log('Retrieving page dimensions... meeting ID = ' +
                     self.meetingID + ' and docID = ' + self.docID)
        self.getPageDimensions(storePath)
        self.pagesConverted = 1

        self.setConversionState('PDF2SWF')

        for i in range(2, self.totalPageCount + 1):

            if self.getConversionState() == 'CANCELLED':
                return

            if self.getErrorCode() != 7200:
                cherrypy.log('Must have detected self-kill... meeting ID = ' +
                             self.meetingID + ' and docID = ' + self.docID)
                self.pdfRelease()
                return
            if sys.platform.startswith('win'):
                outfile = storePath + '\\' + str(i - 1) + '.swf'
                shellCmd = 'c:\\swftools\\pdf2swf.exe -qq -p ' + str(
                    i) + ' ' + infile + ' -o ' + outfile
            else:
                outfile = storePath + '/' + str(i - 1) + '.swf'
                shellCmd = 'pdf2swf -qq -p ' + str(
                    i) + ' ' + infile + ' -o ' + outfile

            try:
                os.system(shellCmd)
                print shellCmd
                self.pagesConverted += 1
            except:
                #print 'exception: convertDocument1'
                pass

            if not os.path.isfile(outfile):
                if sys.platform.startswith('win'):
                    shellCmd = 'copy ' + mediaArchive + '\\placeholder.swf' ' ' + outfile
                else:
                    shellCmd = 'cp ' + mediaArchive + '/placeholder.swf' ' ' + outfile
                os.system(shellCmd)

        if self.getConversionState() == 'CANCELLED':
            return

        self.pdfRelease()

        self.setConversionState('POSTPROC')

        cherrypy.log('Burning document information to disk... meeting ID = ' +
                     self.meetingID + ' and docID = ' + self.docID)
        storeObject = filehelper.serialObject()
        storeObject.clearBuffer()
        storeObject.add('docName', self.docName)
        storeObject.add('docID', self.docID)
        storeObject.add('noOfPages', self.totalPageCount)
        storeObject.add('width', self.width)
        storeObject.add('height', self.height)
        storeObject.exportData(storePath + 'documentData.txt')

        self.conversionComplete = True

        # upload the pdf to mail box
        curlHandle = pycurl.Curl()

        formData = []
        formData.append(('dimdimId', self.meetingID))
        formData.append(('roomId', self.roomID))
        formData.append(('sessionId', self.sessionID))
        formData.append(('fileName', self.docID + '.pdf'))
        formData.append(('fileType', 'PPT'))
        formData.append(('myFile', (pycurl.FORM_FILE, infile)))

        curlHandle.setopt(curlHandle.URL, mailboxURL + 'uploadSessionFile')
        curlHandle.setopt(curlHandle.HTTPPOST, formData)
        curlHandle.setopt(pycurl.HTTPHEADER, ["Expect: "])

        try:
            curlResponse = curlHandle.perform()
        except:
            cherrypy.log(
                'Caught exception trying to upload pdf to mailbox... ' +
                self.meetingID + '/' + self.roomID + '/' + self.sessionID)

        try:
            os.remove(self.location)
        except:
            #print 'exception: convertDocument1'
            pass

        return
Esempio n. 4
0
    def convertDocument(self):
        storePath = ''
        #print 'in convert document'
        try:
            storePath = self.getPDFLocation()
            #print storePath
        except:
            cherrypy.log('Conversion could have been cancelled... meeting ID = ' + self.meetingID + ' and docID = ' + self.docID)
            if self.getErrorCode() == 7200:
                self.setErrorCode(7406)
            return

        if storePath == '':
            tempError = self.getErrorCode()
            self.setErrorCode(tempError)
            return

        if self.getConversionState() == 'CANCELLED':
            return

        retval = self.pdfAcquire()
        if not retval:
            if self.getErrorCode() == 7200:
                self.setErrorCode(7406)
            return

        cherrypy.log('PDF available. Proceeding to SWF creation... meeting ID = ' + self.meetingID + ' and docID = ' + self.docID)
        if sys.platform.startswith('win'):
            infile = storePath + '\\conv.pdf'
        else:
            infile = storePath + 'conv.pdf'
#        print infile
        if self.getConversionState() == 'CANCELLED':
            return

        cherrypy.log('Retrieving page count... meeting ID = ' + self.meetingID + ' and docID = ' + self.docID)
        self.getPageCount(storePath)

        if self.totalPageCount == 0:
            cherrypy.log('Invalid page count... meeting ID = ' + self.meetingID + ' and docID = ' + self.docID)
            if (self.getErrorCode() != 7901 and self.getErrorCode() != 7902):
                self.setErrorCode(7406)
            self.pdfRelease()

            return

        if self.getConversionState() == 'CANCELLED':
            return

        cherrypy.log('Retrieving page dimensions... meeting ID = ' + self.meetingID + ' and docID = ' + self.docID)
        self.getPageDimensions(storePath)
        self.pagesConverted = 1

        self.setConversionState('PDF2SWF')

        for i in range(2, self.totalPageCount + 1):

            if self.getConversionState() == 'CANCELLED':
                return

            if self.getErrorCode() != 7200:
                cherrypy.log('Must have detected self-kill... meeting ID = ' + self.meetingID + ' and docID = ' + self.docID)
                self.pdfRelease()
                return
            if sys.platform.startswith('win'):
                outfile = storePath + '\\' + str(i - 1) + '.swf'
                shellCmd = 'c:\\swftools\\pdf2swf.exe -qq -p ' + str(i) + ' ' + infile + ' -o ' + outfile
            else:
                outfile = storePath + '/' + str(i - 1) + '.swf'
                shellCmd = 'pdf2swf -qq -p ' + str(i) + ' ' + infile + ' -o ' + outfile

            try:
                os.system(shellCmd)
                print shellCmd
                self.pagesConverted += 1
            except:
                #print 'exception: convertDocument1'
                pass

            if not os.path.isfile(outfile):
                if sys.platform.startswith('win'):
                    shellCmd = 'copy ' + mediaArchive + '\\placeholder.swf' ' ' + outfile
                else:
                    shellCmd = 'cp ' + mediaArchive + '/placeholder.swf' ' ' + outfile
                os.system(shellCmd)

        if self.getConversionState() == 'CANCELLED':
            return

        self.pdfRelease()

        self.setConversionState('POSTPROC')

        cherrypy.log('Burning document information to disk... meeting ID = ' + self.meetingID + ' and docID = ' + self.docID)
        storeObject = filehelper.serialObject()
        storeObject.clearBuffer()
        storeObject.add('docName',self.docName)
        storeObject.add('docID',self.docID)
        storeObject.add('noOfPages',self.totalPageCount)
        storeObject.add('width', self.width)
        storeObject.add('height', self.height)
        storeObject.exportData(storePath+'documentData.txt')

        self.conversionComplete = True

        # upload the pdf to mail box
        curlHandle = pycurl.Curl()

        formData = []
        formData.append(('dimdimId', self.meetingID))
        formData.append(('roomId', self.roomID))
        formData.append(('sessionId', self.sessionID))
        formData.append(('fileName', self.docID + '.pdf'))
        formData.append(('fileType', 'PPT'))
        formData.append(('myFile', (pycurl.FORM_FILE, infile)))

        curlHandle.setopt(curlHandle.URL, mailboxURL+'uploadSessionFile')
        curlHandle.setopt(curlHandle.HTTPPOST, formData)
        curlHandle.setopt(pycurl.HTTPHEADER, ["Expect: "])

        try:
            curlResponse = curlHandle.perform()
        except:
            cherrypy.log('Caught exception trying to upload pdf to mailbox... ' + self.meetingID + '/' + self.roomID + '/' + self.sessionID)


        try:
            os.remove(self.location)
        except:
            #print 'exception: convertDocument1'
            pass

        return
Esempio n. 5
0
    def listDocuments(self, meetingID, strictJSON = False):
        slidedeckArchive = osconfig.slidedeckArchive()
        [installationID, dimdimID] = osconfig.splitIdentity(meetingID)
        meetingID = installationID + '____' + dimdimID
        jsondata = jsonObject()
        jsondata.clearResponse()
        entries = self.findMeetingDocuments(slidedeckArchive, meetingID)

        if len(entries) == 0:
            if not strictJSON:
                jsondata.add('result', 'false')
                jsondata.add('method', 'listDocuments')
                jsondata.add('error', '7404')
                jsondata.add('meetingID', meetingID)
                return jsondata.jsonResponse()
            else:
                jsondata = {'result':'false', 'method':'listDocuments', 'error':7404, 'meetingID':meetingID}
                response = self.demHelper.encode(jsondata)
                return response.encode()
            
        if not strictJSON:
            jsondata.add('result', 'true')
            jsondata.add('method', 'listDocuments')
            jsondata.add('meetingID', meetingID)
            jsondata.add('error', '7200')
    
            entryJSONValue = '['
            for i in range(0, len(entries)):
                entryJSON = jsonObject()
                entryJSON.clearResponse()
                fp = serialObject()
                fp.clearBuffer()
                fp.importData(entries[i])
                entryJSON.add('docName',fp.get('docName'))
                entryJSON.add('docID',fp.get('docID'))
                entryJSON.add('width', fp.get('width'))
                entryJSON.add('height', fp.get('height'))
                entryJSON.add('noOfPages',string.atoi(fp.get('noOfPages')))
                if entries[i].find('global-meeting') >= 0:
                    entryJSON.add('Type', "global")
                else:
                    entryJSON.add('Type', "preloaded")
                entryJSONValue += entryJSON.jsonResponse()
                if i < len(entries) -1:
                    entryJSONValue += ','
    
            entryJSONValue += ']'
            jsondata.add('docs',entryJSONValue)
            return jsondata.jsonResponse()
        else:
            jsondata = {'result':'true', 'method':'listDocuments', 'meetingID':meetingID, 'error':7200}
            entryList = []
            for i in range(0, len(entries)):
                fp = serialObject()
                fp.clearBuffer()
                fp.importData(entries[i])
                entryMap = {'docName' : fp.get('docName'), 'docID' : fp.get('docID'), 'width' : string.atoi(fp.get('width')), \
                                        'height': string.atoi(fp.get('height')), 'noOfPages' : string.atoi(fp.get('noOfPages')) }
                if entries[i].find('global-meeting') >= 0:
                    entryMap.update({'Type':'global'})
                else:
                    entryMap.update({'Type' : 'preloaded'})
                entryList.append(entryMap)
            jsondata.update({'docs':entryList})
            response = self.demHelper.encode(jsondata)
            return response.encode()