Example #1
0
    def _export_to_zip(self, mp, location=None, is_action=True):
        if not location:
            name = datetime.now().replace(microsecond=0).isoformat()
            location = location or os.path.join(self.export_path,
                                                name + '.zip')
        if is_action:
            logger.info("Executing ExportToZIP for MP {0}".format(
                mp.getIdentifier()))
            mp.setOpStatus('exporttozip', mediapackage.OP_PROCESSING)
            self.dispatcher.emit('start-operation', 'exporttozip', mp)
            self.repo.update(mp)
        else:
            logger.info("Zipping MP {0}".format(mp.getIdentifier()))
        if True:  #try:
            serializer.save_in_zip(mp, location)
            if is_action:
                mp.setOpStatus('exporttozip', mediapackage.OP_DONE)
                self.dispatcher.emit('stop-operation', 'exporttozip', mp, True)

        else:  #except:
            if is_action:
                logger.error("Zip failed for MP {0}".format(mp.identifier))
                mp.setOpStatus('exporttozip', mediapackage.OP_FAILED)
                self.dispatcher.emit('stop-operation', 'exporttozip', mp,
                                     False)
            else:
                pass
        self.repo.update(mp)
Example #2
0
 def _export_to_zip(self, mp, location=None, is_action=True):
     if not location:
         name = datetime.now().replace(microsecond=0).isoformat()
         location = location or os.path.join(self.export_path, name + '.zip')
     if is_action:
         self.logger.info("Executing ExportToZIP for MP {0}".format(mp.getIdentifier()))
         mp.setOpStatus('exporttozip',mediapackage.OP_PROCESSING)
         self.dispatcher.emit('start-operation', 'exporttozip', mp)
         self.repo.update(mp)
     else:
         self.logger.info("Zipping MP {0}".format(mp.getIdentifier()))
     try:
         serializer.save_in_zip(mp, location, self.use_namespace, self.logger)
         if is_action:
             mp.setOpStatus('exporttozip',mediapackage.OP_DONE)
             self.dispatcher.emit('stop-operation', 'exporttozip', mp, True)
     
     except:
         if is_action:
             self.logger.error("Zip failed for MP {0}".format(mp.identifier))
             mp.setOpStatus('exporttozip',mediapackage.OP_FAILED)
             self.dispatcher.emit('stop-operation', 'exporttozip', mp, False)
         else:
             pass
     self.repo.update(mp)
Example #3
0
    def _export_to_zip(self, mp, location=None, is_action=True):
        location = location or self.gen_location('zip')
        if is_action:
            self.logger.info("Executing ExportToZIP for MP {0}".format(
                mp.getIdentifier()))
            mp.setOpStatus('exporttozip', mediapackage.OP_PROCESSING)
            self.dispatcher.emit('start-operation', 'exporttozip', mp)
            self.repo.update(mp)
        else:
            self.logger.info("Zipping MP {0}".format(mp.getIdentifier()))
        try:
            serializer.save_in_zip(mp, location, self.use_namespace,
                                   self.logger)
            if is_action:
                mp.setOpStatus('exporttozip', mediapackage.OP_DONE)
                self.dispatcher.emit('stop-operation', 'exporttozip', mp, True)

        except:
            if is_action:
                self.logger.error("Zip failed for MP {0}".format(
                    mp.identifier))
                mp.setOpStatus('exporttozip', mediapackage.OP_FAILED)
                self.dispatcher.emit('stop-operation', 'exporttozip', mp,
                                     False)
            else:
                pass
        self.repo.update(mp)
Example #4
0
    def _export_to_zip(self, mp, params={}):
        """Tries to immediately export the mediapackage to a particular location as a zip.
        If the exportation cannot be done, logger prints it properly.
        Args:
            mp (Mediapackage): the mediapackage to be exported as a zip.
            location (str): absolute path of the destination export file.
            is_action (bool): true if the action was done by the user. False if is a subtask.
        """
        location = self.gen_location('zip') if not "location" in params else params["location"]
        is_action = True if not "is_action" in params else params["is_action"]

        if not is_action:
            self.logger.info("Zipping MP {} to {}".format(mp.getIdentifier(), location if type(location) in [str,str] else location.name))

        serializer.save_in_zip(mp, location, self.use_namespace, self.logger)
    def _export_to_zip(self, mp, params={}):
        """Tries to immediately export the mediapackage to a particular location as a zip.
        If the exportation cannot be done, logger prints it properly.
        Args:
            mp (Mediapackage): the mediapackage to be exported as a zip.
            location (str): absolute path of the destination export file.
            is_action (bool): true if the action was done by the user. False if is a subtask.
        """
        location = self.gen_location('zip') if not "location" in params else params["location"]
        is_action = True if not "is_action" in params else params["is_action"]

        if not is_action:
            self.logger.info("Zipping MP {} to {}".format(mp.getIdentifier(), location if type(location) in [str,unicode] else location.name))

        serializer.save_in_zip(mp, location, self.use_namespace, self.logger)
Example #6
0
 def _export_to_zip(self, mp, location=None, is_action=True):
     location = location or self.gen_location('zip')
     if is_action:
         self.logger.info("Executing ExportToZIP for MP {0}".format(mp.getIdentifier()))
         mp.setOpStatus('exporttozip',mediapackage.OP_PROCESSING)
         self.dispatcher.emit('start-operation', 'exporttozip', mp)
         self.repo.update(mp)
     else:
         self.logger.info("Zipping MP {0}".format(mp.getIdentifier()))
     try:
         serializer.save_in_zip(mp, location, self.use_namespace, self.logger)
         if is_action:
             mp.setOpStatus('exporttozip',mediapackage.OP_DONE)
             self.dispatcher.emit('stop-operation', 'exporttozip', mp, True)
     
     except:
         if is_action:
             self.logger.error("Zip failed for MP {0}".format(mp.identifier))
             mp.setOpStatus('exporttozip',mediapackage.OP_FAILED)
             self.dispatcher.emit('stop-operation', 'exporttozip', mp, False)
         else:
             pass
     self.repo.update(mp)
Example #7
0
    def _export_to_zip(self, mp, params={}):
        """Tries to immediately export the mediapackage to a particular location as a zip.
        If the exportation cannot be done, logger prints it properly.
        Args:
            mp (Mediapackage): the mediapackage to be exported as a zip.
            location (str): absolute path of the destination export file.
            is_action (bool): true if the action was done by the user. False if is a subtask. 
        """
        location = self.gen_location("zip") if not "location" in params else params["location"]
        is_action = True if not "is_action" in params else params["is_action"]

        if is_action:
            self.logger.info(
                "Executing ExportToZIP for MP {} to {}".format(
                    mp.getIdentifier(), location if type(location) in [str, unicode] else location.name
                )
            )
            mp.setOpStatus("exporttozip", mediapackage.OP_PROCESSING)
            self.dispatcher.emit("start-operation", "exporttozip", mp)
            self.repo.update(mp)
        else:
            self.logger.info(
                "Zipping MP {} to {}".format(
                    mp.getIdentifier(), location if type(location) in [str, unicode] else location.name
                )
            )
        try:
            serializer.save_in_zip(mp, location, self.use_namespace, self.logger)
            if is_action:
                self.operation_success(mp, ZIPPING)
        except Exception as exc:
            if is_action:
                self.operation_error(mp, ZIPPING, exc)
            else:
                pass
        self.repo.update(mp)