Example #1
0
 def __init__(self, deferred, workspace, item_id, source_variant_name):    
     if self.get_cmdline is None:
         raise Exception('Analyzer is an abstract base class: instantiate a derived class')
     self.deferred = deferred
     self._fc = Storage()
     self.workspace = workspace
     self.item, self.source = get_source_rendition(item_id, source_variant_name, workspace)
Example #2
0
    def get_url(self, full_address=False):
        """
        Returns the component url (something like /storage/res_id.ext)
        """

        storage = Storage()
        url = None
        try:
            file_name = self.uri
            if storage.exists(file_name):
                url = os.path.join(STORAGE_SERVER_URL, file_name)

                if full_address:
                    url = SERVER_PUBLIC_ADDRESS + url

        except Exception, ex:
            logger.exception(ex)
            return url
Example #3
0
def _get_resource_url(id):
    """
    Returns resource path
    """

    storage = Storage()

    if not id:
        return None

    try:

        if storage.exists(id):
            url = '/storage/' + id
        else:
            url = None
    except:
        url = None
    return url
Example #4
0
def get_variant_url(request, item_ID, variant_name):
    from mediadart.storage import Storage
    from django.views.generic.simple import redirect_to
    
    try:
        workspace = request.session['workspace']
        storage = Storage()
        
        try:
            component = Component.objects.get(item___id = item_ID, workspace = workspace, variant__name = variant_name)
            url =  component.get_url()
                        
        except Component.DoesNotExist, ex:
            return HttpResponseNotFound()
            
#        if not url:
#            url = settings.INPROGRESS
        logger.debug('url %s'%url)
        return redirect_to(request, url)
Example #5
0
class XMPEmbedderImpl:
    def __init__(self):
        self._fc = Storage()

    def metadata_synch(self, component_id, changes):

        # get xmp

        # the filename is needed because the extension is unknown, the following line of code is
        # tmp code because c.ID will include extension file (not only basename)
        # in the new MediaDART release
        #print 'MediaDART resource path: ', md_res_path
        try:
            myxmpfilename = str(self._fc.abspath(component_id))
        except Exception, err:
            print '\n    found some problems getting filename, err: ', err, '\n'

        xmpfile = XMPFiles(file_path=myxmpfilename,
                           open_forupdate=files.XMP_OPEN_FORUPDATE)
        xmp = xmpfile.get_xmp()

        if not xmp:
            xmp = XMPMeta()

        for ns in changes.keys():
            #print 'Property ', str(i[0]),':', str(i[1])
            # first of all check if namespace str(i[0]) and property name str(i[1]) exist
            prefix = None
            try:
                prefix = xmp.get_prefix_for_namespace(str(ns))
            except XMPError, err:
                print 'Error in get_prefix_for_namespace: ', err
            if prefix == None:
                #print 'prefix ', prefix[:-1] , ' does not exist.'
                try:
                    log.debug('%s %s' % (str(ns), str(changes[ns]['prefix'])))
                    res = xmp.register_namespace(
                        str(ns), str(changes[ns]['prefix']))  # CHANGE ME
                    #print 'register_namespace gave res = ', res
                except XMPError, err:
                    print 'Error in register_namespace: ', err
Example #6
0
class XMPEmbedderImpl:
    def __init__(self):
        self._fc = Storage()

    def metadata_synch(self, component_id, changes):

        # get xmp

        # the filename is needed because the extension is unknown, the following line of code is
        # tmp code because c.ID will include extension file (not only basename)
        # in the new MediaDART release
        # print 'MediaDART resource path: ', md_res_path
        try:
            myxmpfilename = str(self._fc.abspath(component_id))
        except Exception, err:
            print "\n    found some problems getting filename, err: ", err, "\n"

        xmpfile = XMPFiles(file_path=myxmpfilename, open_forupdate=files.XMP_OPEN_FORUPDATE)
        xmp = xmpfile.get_xmp()

        if not xmp:
            xmp = XMPMeta()

        for ns in changes.keys():
            # print 'Property ', str(i[0]),':', str(i[1])
            # first of all check if namespace str(i[0]) and property name str(i[1]) exist
            prefix = None
            try:
                prefix = xmp.get_prefix_for_namespace(str(ns))
            except XMPError, err:
                print "Error in get_prefix_for_namespace: ", err
            if prefix == None:
                # print 'prefix ', prefix[:-1] , ' does not exist.'
                try:
                    log.debug("%s %s" % (str(ns), str(changes[ns]["prefix"])))
                    res = xmp.register_namespace(str(ns), str(changes[ns]["prefix"]))  # CHANGE ME
                    # print 'register_namespace gave res = ', res
                except XMPError, err:
                    print "Error in register_namespace: ", err
Example #7
0
 def __init__(self):
     self._fc = Storage()
Example #8
0
 def __init__(self):
     self._fc = Storage()