Exemple #1
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()
Exemple #2
0
    def uploadDocument(self, docFile, meetingID, roomID, sessionID, docID, docType, uploadType):

        # 'uploadType' accepts "global" or "preloaded". If neither is specified, it is assumed as a regular presentation.
        # if the type is global, "global-meeting" is used as a meeting key. Any meeting ID specified is discarded
        oosetupsemaphore = threading.BoundedSemaphore(1)
        if not docType == 'pdf':
            #print 'in upload document function'
            self.isOOHealthy = self.checkOO()
            #print self.isOOHealthy+' ooHealthy'
            if self.isOOHealthy=="False":
                oosetupsemaphore.acquire()
                self.startOO()
                oosetupsemaphore.release()
        uploadType = string.lower(uploadType)

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

        fileStoreLocation = os.path.join(mediaDirectory, docID)
        fileStoreLocation += '.' + docType
        storedFile = None
        if sys.platform.startswith('win'):
            storedFile = open(fileStoreLocation, 'wb')
        else:
            storedFile = open(fileStoreLocation, 'w')
        while True:
            data = docFile.file.read(8192)
            if not data:
                break
            storedFile.write(data)

        storedFile.close()
        xPorter = exportEngine(meetingID, roomID, sessionID, fileStoreLocation, docID, uploadType, os.path.basename(docFile.filename), docType, self.officeLock, self.pdfLock, self.collator)

        self.processMap[docID] = xPorter
        xPorter.start()

        # JSON Response BEGIN
        jsondata = jsonObject()
        jsondata.clearResponse()
        jsondata.add('result','true')
        jsondata.add('method','uploadDocument')
        jsondata.add('docName',os.path.basename(docFile.filename))
        jsondata.add('docType',docType)
        jsondata.add('docID',docID)
        #JSON Response END

        return jsondata.jsonResponse()
Exemple #3
0
    def uploadPreloadedDocument(self, docFile, fileName, meetingID, docID, docType, strictJSON = False):

         # fileName can be empty. If that is the case, we take the name from the file object

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

        fileStoreLocation = os.path.join(mediaDirectory, docID)
        fileStoreLocation += '.' + docType
        storedFile = None
        if sys.platform.startswith('win'):
            storedFile = open(fileStoreLocation, 'wb')
        else:
            storedFile = open(fileStoreLocation, 'w')
        while True:
            data = docFile.file.read(8192)
            if not data:
                break
            storedFile.write(data)

        storedFile.close()

        if len(fileName) == 0:
            fileName = os.path.basename(docFile.filename)

        xPorter = exportEngine(meetingID, '', '', fileStoreLocation, docID, 'preloaded', fileName, docType, self.officeLock, self.pdfLock, self.collator)

        self.processMap[docID] = xPorter
        xPorter.start()

        if not strictJSON:
            # JSON Response BEGIN
            jsondata = jsonObject()
            jsondata.clearResponse()
            jsondata.add('result','true')
            jsondata.add('method','uploadPreloadedDocument')
            jsondata.add('docName',fileName)
            jsondata.add('docType',docType)
            jsondata.add('docID',docID)
            #JSON Response END
    
            return jsondata.jsonResponse()
        else:
            strictData = {'result' : 'true', 'method' : 'uploadPreloadedDocument', 'docName' : fileName, 'docType' : docType, 'docID': docID}
            response = self.demHelper.encode(strictData)
            return response.encode()
Exemple #4
0
    def uploadPreloadedDocumentWithPath(self, filePath, fileName, meetingID, docID, docType, strictJSON = False):

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

        docPath = os.path.join(osconfig.preloadedDocumentRoot(),filePath)
        if not os.path.isfile(docPath):
            return 'invalid file location'

        fileStoreLocation = os.path.join(mediaDirectory, docID)
        fileStoreLocation += '.' + docType

        # copy the file from location to media directory

        if sys.platform.startswith('win'):
            os.system('copy ' + docPath + ' ' + fileStoreLocation)
        else:
            os.system('cp ' + docPath + ' ' + fileStoreLocation)

        if len(fileName) == 0:
            fileName = os.path.basename(docPath)
        xPorter = exportEngine(meetingID, '', '', fileStoreLocation, docID, 'preloaded', fileName, docType, self.officeLock, self.pdfLock, self.collator)

        self.processMap[docID] = xPorter
        xPorter.start()
        
        if not strictJSON:
            # JSON Response BEGIN
            jsondata = jsonObject()
            jsondata.clearResponse()
            jsondata.add('result','true')
            jsondata.add('method','uploadPreloadedDocumentWithPath')
            jsondata.add('docName',fileName)
            jsondata.add('docType',docType)
            jsondata.add('docID',docID)
            #JSON Response END
    
            return jsondata.jsonResponse()
        else:
            jsondata = {'result': 'true', 'method' : 'uploadPreloadedDocumentWithPath', 'docName': fileName, 'docType' : docType, 'docID' : docID}
            response = self.demHelper.encode(jsondata)
            return response.encode()
Exemple #5
0
 def generateDocID(self):
     return idgen.gen()
Exemple #6
0
 def generatePPTIDxx(self):
     doc = xml.dom.minidom.Document()
     textNode = doc.createElement("jb")
     textNode.appendChild(doc.createTextNode(idgen.gen()))
     doc.appendChild(textNode)
     return doc.toxml()