コード例 #1
0
def RenameObject(object, evt, STORAGE):
    #pdb.set_trace()
    file_object=object.getField(object.portal_type)
    name_original_file=file_object.getFilename(object)
    original_path=path.join(STORAGE,evt.oldParent._getURL(), evt.oldName)
    extension=MTD.CheckExtension(name_original_file)
    path_of_original_object=path.join(original_path,name_original_file)
    original_trascoded_file=MTD.nginxpath(path_of_original_object)
    if evt.oldParent is evt.newParent:
        destination_path=path.join(STORAGE,evt.oldParent._getURL(),evt.newName)
    else:
        destination_path=path.join(STORAGE,evt.newParent._getURL(),evt.newName)
    moved_object=path.join(destination_path, name_original_file)
    moved_transcode_object=path.join(destination_path,MTD.nginxpath(name_original_file))
    #pdb.set_trace()
    if extension is 'ogg' or extension is 'OGG' or extension is 'ogv' or extension is 'OGV':
        return
    else:
        #pdb.set_trace()
        if ServiceList.root['waiting'] is not None:
            #El elemento esta en lista de espera para ser codificado
            if {evt.oldName:path_of_original_object} in ServiceList.root['waiting']:
                ServiceList.root['waiting'].remove({evt.oldName:path_of_original_object})
                ServiceList.root['waiting'].append({evt.newName:moved_object})
                ServiceList.SaveInZODB()
        elif ServiceList.root['ready'] is not None:
            if {evt.oldName:original_trascoded_file} in ServiceList.root['ready']:
                #El elemento fue recodificado
                ServiceList.root['ready'].remove({evt.oldName:original_trascoded_file})
                if path.isfile(original_trascoded_file)==True and path.isdir(destination_path)==True:
                    move(original_trascoded_file,destination_path)
                    ServiceList.root['ready'].append({evt.newName:moved_transcode_object})
                    ServiceList.SaveInZODB()
                else:
                    return
        elif path_of_original_object==ServiceList.root['current'] and isThisRunning('/usr/bin/ffmpeg -i '+path_of_original_object):
            # El elemento esta siendo codificado
            print "El archivo actual esta siendo codificado"
            system('/usr/bin/killall ffmpeg')
            if path.isdir(original_path)==True:
                if path.isfile(original_trascoded_file)==True:
                    sleep(3)
                    remove(trascoded_file)
                    ServiceList.root['ready'].remove({object.id:original_trascoded_file})
                    ServiceList.root['waiting'].append({object.id:moved_object})
                    ServiceList.root['current']=""
                    ServiceList.SaveInZODB()
                else:
                    return
        else:
            return
コード例 #2
0
def RemoveObjectsFromHDD(extension, path_of_dir, path_of_object, trascoded_file, ElementID):
    if extension is "ogg" or extension is "OGG":
        if path.isdir(path_of_dir)==False:
            print "FSS ha movido el archivo"
        else:
            print "Algo esta pasando, tenemos un objeto no deseado"
    elif extension is not "ogg" or extension is not "OGG":
        #if path.isdir(path_of_dir)==True and path.isfile(trascoded_file)==True:
        print "El archivo a borrar existe en este directorio"
        if path.isfile(trascoded_file)==True and ({ElementID:trascoded_file} in ServiceList.root['ready'] \
            or path_of_object is ServiceList.root['current']):
            print "El archivo a borrar es "+ trascoded_file
            print "Esperando... 3seg"
            sleep(3)
            remove(trascoded_file)
            print "Archivo Borrado"
            if {ElementID:trascoded_file} in ServiceList.root['ready']:
                print "VERDADERO"
                #pdb.set_trace()
                try:
                    ServiceList.root['ready'].remove({ElementID:trascoded_file})
                except AttributeError:
                    return
            else:
                print "Archivo Borrado"
                return
            if path_of_object is ServiceList.root['current']:
                ServiceList.root['current']=""
        elif ServiceList.root['waiting'] is not None:
            if {ElementID:path_of_object} in ServiceList.root['waiting']:
                ServiceList.root['waiting'].remove({ElementID:path_of_object})
        elif path_of_object==ServiceList.root['current'] and isThisRunning('/usr/bin/ffmpeg -i '+path_of_object):
            print "El archivo actual esta siendo codificado"
            system('/usr/bin/killall ffmpeg')
            if path.isdir(path_of_dir)==True:
                print "El archivo a borrar existe en este directorio"
                if path.isfile(trascoded_file)==True:
                    print "El archivo a borrar es "+ trascoded_file
                    sleep(3)
                    remove(trascoded_file)
                    ServiceList.root['ready'].remove({ElementID:trascoded_file})
                    ServiceList.root['current']=""
                else:
                    return
コード例 #3
0
def Custom_CopyObjet(object, evt):
    #TODO
    #pdb.set_trace()
    request=getattr(evt.original, 'REQUEST', None)
    portal = getSite()
    portal_path = '/'.join(portal.getPhysicalPath())
    STORAGE=ZCONFIG.storagePathForSite(portal)
    destination_path=path.join(STORAGE,request['PARENTS'][0]._getURL(),evt.object.tpURL())
    original_path=path.join(STORAGE,evt.original._getURL())
    
    """
    while path.isdir(destination_path)==False:
        if path.isdir(destination_path)==False:
            pass
        else:
    """
    file_object=evt.original.getField(evt.original.portal_type)
    file_name=file_object.getFilename(evt.original)
    path_of_original_object=path.join(original_path, file_name)
    extension=MTD.CheckExtension(file_name)
    copy_object=path.join(destination_path, MTD.nginxpath(file_name))
    #pdb.set_trace()
    if extension is 'ogg' or extension is 'OGG'\
    or extension is 'ogv' or extension is 'OGV':
        return
    else:
        #pdb.set_trace()
        if ServiceList.root['waiting'] is not None:
            #El elemento esta en lista de espera para ser codificado
            if {object.id:path_of_original_object} in ServiceList.root['waiting']:
                ServiceList.root['waiting'].append({object.id:copy_object})
                ServiceList.SaveInZODB()
        #pdb.set_trace()
        elif ServiceList.root['ready'] is not None:
            original_trascoded_file=MTD.nginxpath(path_of_original_object)
            
            if {object.id:original_trascoded_file} in ServiceList.root['ready']:
                #El elemento fue recodificado
                pdb.set_trace()
                if path.isdir(destination_path)==False:
                    mkdir(destination_path)
                    copy(original_trascoded_file,copy_object)
                    ServiceList.root['ready'].append({object.id:copy_object})
                    ServiceList.SaveInZODB()
                else:
                    pdb.set_trace()
                    if path.isfile(original_trascoded_file)==True:
                        copy(original_trascoded_file,copy_object)
                        ServiceList.root['ready'].append({object.id:copy_object})
                        ServiceList.SaveInZODB()
        #pdb.set_trace()
        elif path_of_original_object==ServiceList.root['current'] and isThisRunning('/usr/bin/ffmpeg -i '+path_of_original_object):
            # El elemento esta siendo codificado
            print "El archivo actual esta siendo codificado"
            system('/usr/bin/killall ffmpeg')
            if path.isdir(original_path)==True:
                if path.isfile(original_trascoded_file)==True:
                    sleep(3)
                    remove(trascoded_file)
                    ServiceList.root['ready'].remove({ElementID:original_trascoded_file})
                    ServiceList.root['waiting'].append({object.id:copy_object})
                    ServiceList.root['current']=""
                    ServiceList.SaveInZODB()
        else:
            return