Example #1
0
    def globalConfigInfo(self):
        """A TALES friendly configuration info mapping for global configuration"""

        return {
            'config_file': CONFIG_FILE,
            'strategy': ZCONFIG.storageStrategyForSite('/'),
            'storage_path': ZCONFIG.storagePathForSite('/'),
            'backup_path': ZCONFIG.backupPathForSite('/')
        }
Example #2
0
    def globalConfigInfo(self):
        """A TALES friendly configuration info mapping for global configuration"""

        return {
            'config_file': CONFIG_FILE,
            'strategy': ZCONFIG.storageStrategyForSite('/'),
            'storage_path': ZCONFIG.storagePathForSite('/'),
            'backup_path': ZCONFIG.backupPathForSite('/')
            }
Example #3
0
    def testDefaultConfig(self):
        from iw.fss.config import ZCONFIG

        self.assertEqual(ZCONFIG.storagePathForSite('/any/site'),
                         os.path.normpath(os.path.expandvars('$INSTANCE_HOME/var/fss_storage')))
        self.assertEqual(ZCONFIG.backupPathForSite('/any/site'),
                         os.path.normpath(os.path.expandvars('$INSTANCE_HOME/var/fss_backup')))
        self.assertEqual(ZCONFIG.storageStrategyForSite('/any/site'), 'flat')
        self.assertEqual(len(ZCONFIG.sites), 0)
        return
Example #4
0
    def getStorageStrategy(self):
        """Returns the storage strategy"""

        global _strategy_map
        portal = getSite()
        portal_path = '/'.join(portal.getPhysicalPath())
        strategy_class = _strategy_map[ZCONFIG.storageStrategyForSite(portal_path)]
        return strategy_class(
            ZCONFIG.storagePathForSite(portal_path),
            ZCONFIG.backupPathForSite(portal_path))
Example #5
0
    def getStorageStrategy(self):
        """Returns the storage strategy"""

        global _strategy_map
        portal = getSite()
        portal_path = '/'.join(portal.getPhysicalPath())
        strategy_class = _strategy_map[ZCONFIG.storageStrategyForSite(
            portal_path)]
        return strategy_class(ZCONFIG.storagePathForSite(portal_path),
                              ZCONFIG.backupPathForSite(portal_path))
Example #6
0
    def siteConfigInfo(self):
        """A TALES friendly configuration info mapping for this Plone site"""

        portal = getSite()
        portal_path = '/'.join(portal.getPhysicalPath())
        return {
            'config_file': CONFIG_FILE,
            'strategy': ZCONFIG.storageStrategyForSite(portal_path),
            'storage_path': ZCONFIG.storagePathForSite(portal_path),
            'backup_path': ZCONFIG.backupPathForSite(portal_path)
            }
Example #7
0
    def siteConfigInfo(self):
        """A TALES friendly configuration info mapping for this Plone site"""

        portal = getSite()
        portal_path = '/'.join(portal.getPhysicalPath())
        return {
            'config_file': CONFIG_FILE,
            'strategy': ZCONFIG.storageStrategyForSite(portal_path),
            'storage_path': ZCONFIG.storagePathForSite(portal_path),
            'backup_path': ZCONFIG.backupPathForSite(portal_path)
        }
def ModifiedElement(object, evt):
    request = getattr(object, "REQUEST", None)
    try:
        integrity_info = request.link_integrity_info
        if integrity_info.has_key("deleted") == True:
            return
        else:
            pass
    except AttributeError:
        pass
    portal = getSite()
    portal_path = "/".join(portal.getPhysicalPath())
    STORAGE = ZCONFIG.storagePathForSite(portal)
    # pdb.set_trace()
    file_object = object.getField(object.portal_type)
    name_original_file = file_object.getFilename(object)
    original_path = path.join(STORAGE, evt.object._getURL())
    # pdb.set_trace()
    for file_name in listdir(original_path):
        # pdb.set_trace()
        if (
            (file_name == name_original_file)
            or (file_name == "fss.cfg")
            or (file_name == MTD.nginxpath(name_original_file))
        ):
            pass
        else:
            remove(path.join(original_path, file_name))
    return
Example #9
0
    def PlayingVideoType(self):
	#import pdb; pdb.set_trace()
	registry = getUtility(IRegistry)
	settings = registry.forInterface(ITranscodeSetings)
	self.SERVER = self.RemoveSlash(settings.adress_of_streaming_server)
	VIDEO_PARAMETRES_TRANSCODE = settings.ffmpeg_parameters_video_line
	AUDIO_PARAMETRES_TRANSCODE = settings.ffmpeg_parameters_audio_line
	audio_content_types=settings.audio_valid_content_types
	video_content_types=settings.video_valid_content_types
	portal = getSite()
	self.STORAGE=ZCONFIG.storagePathForSite(portal)
	self.MyTitle = self.context.Title()
	idvideo=self.context.getId()
	self.MyTitleWhitOutSpace = MFNI.DeleteSpaceinNameOfFolderFile(MFNI.TitleDeleteSpace(self.MyTitle))
	self.PathOfFile = self.context._getURL()
	virtualobject=self.context.getVideo()
	self.filenamesaved=virtualobject.filename
	self.extension=MTDI.CheckExtension(self.filenamesaved)
	if self.extension=="ogg" or self.extension=="ogv" or self.extension=="OGG" or self.extension=="OGV":
	    self.folderfileOGG=path.join(self.PathOfFile,quote(self.filenamesaved))
	    self.prefiletranscoded=path.join(self.STORAGE,self.PathOfFile,self.filenamesaved)
	    if path.isfile(self.prefiletranscoded)==True:
		self.StatusOfFile=ServiceList.available(idvideo,self.prefiletranscoded)
		if self.StatusOfFile == False:
		    ServiceList.AddReadyElement(idvideo,self.prefiletranscoded)
		    self.StatusOfFile=True
		    ServiceList.SaveInZODB()
		    self.AbsoluteServerPath = path.join(self.SERVER,self.folderfileOGG)
		else:
		    self.AbsoluteServerPath = path.join(self.SERVER,self.folderfileOGG)
	    else:
		print _("File not found "+self.prefiletranscoded)
		self.Error=True
		self.ErrorSituation()
	else:
	    newtrans_init_(self.STORAGE,
			   self.PathOfFile,
			   self.filenamesaved,
			   idvideo,
			   VIDEO_PARAMETRES_TRANSCODE,
			   AUDIO_PARAMETRES_TRANSCODE,
			   audio_content_types,
			   video_content_types)
	    self.folderfileOGG=MTDI.newname(path.join(self.PathOfFile,self.filenamesaved))
	    self.AbsoluteServerPath = path.join(self.SERVER,MTDI.nginxpath(self.folderfileOGG))
	    self.newfiletranscoded=MTDI.nginxpath(path.join(self.STORAGE,self.folderfileOGG))
	    self.StatusOfFile = ServiceList.available(idvideo,self.newfiletranscoded)
	    #import pdb;pdb.set_trace()
	    if self.StatusOfFile == True:
		self.newfilename=MTDI.newname(self.filenamesaved)
	    else:
		self.newfilename=_('The file is not ready yet, please contact site administration')
	return
Example #10
0
    def scale(self):
        """ """
        path_dir = ZCONFIG.storagePathForSite('/')
        path = os.path.join(path_dir)
        filename = self.context.UID() + '_video_file'
        metadata = metaex.parse_file(path_dir + '/' + filename)
        height, width = metaex.scale_from_metadata(metadata)

        if MAX_WIDTH < width:
            height = int(height*MAX_WIDTH / width)
            width = MAX_WIDTH

        return "height: %dpx; width: %dpx;" % (height, width)
Example #11
0
 def href(self):
     """ """
     fss_storage = ZCONFIG.storagePathForSite('/')
     return fss_storage + '/' + self.context.UID() + '_video_file'
Example #12
0
    def usesGlobalConfig(self):
        """If the global configuration is in use for this site"""

        portal = getSite()
        return ZCONFIG.usesGlobalConfig(portal)
def type_custom_moved(object, evt, **kwargs):
    request = getattr(object, 'REQUEST', None)
    try:
        integrity_info=request.link_integrity_info
        if integrity_info.has_key('deleted')==True:
            return
        else:
            pass
    except AttributeError:
        pass
    portal = getSite()
    portal_path = '/'.join(portal.getPhysicalPath())
    STORAGE=ZCONFIG.storagePathForSite(portal)
    #pdb.set_trace()
    if hasattr(evt, 'oldName')==True and hasattr(evt,'newName')==True and evt.oldName is not None:
        if match(object.portal_type+"."+str(date.today())+"."+"[+\d]", evt.oldName):
            return
        else:
            if evt.newName is not evt.oldName:
                RenameObject(object, evt, STORAGE)
    
    if request.has_key('-C')==True and request.has_key('__factory__info__')==True \
    and request.has_key('__ac')==True and request.has_key('fieldname')==False \
    and request.has_key('value')==False:
        return
    
    if request.has_key('-C')==False and request.has_key('__factory__info__')==True \
    and request.has_key('__ac')==True and request.has_key('fieldname')==True \
    and request.has_key('value')==True:
        return
    
    if request.has_key('-C')==False and request.has_key('__factory__info__')==True \
    and request.has_key('__ac')==True and request.has_key('fieldname')==True \
    and request.has_key('value')==True and request.has_key('title')==True \
    and request.has_key('id')==True and request.has_key('form.button.save')==True:
        return
    
    if request.has_key('-C')==True and request.has_key('__factory__info__')==False \
    and request.has_key('__ac')==True and request.has_key('__cp')==True and request.has_key('fieldname')==False\
    and request.has_key('value')==False and request.has_key('title')==False \
    and request.has_key('id')==False and request.has_key('traverse_subpath')==True and request._steps[-1]=='object_paste':
        print 'Objeto Pegado en acciones'
        if evt.oldParent==None:
            #Copy/Paste
            #TODO
            return
        else:
            #Cut/Paste
            #TODO
            MoveObject(object, evt, STORAGE)
    
    if request.has_key('-C')==False and request.has_key('__factory__info__')==False \
    and request.has_key('__ac')==True and request.has_key('__cp')==True and request.has_key('fieldname')==False\
    and request.has_key('value')==False and request.has_key('title')==False \
    and request.has_key('id')==False and request.has_key('traverse_subpath')==True and request._steps[-1]=='folder_paste'\
    and request.has_key('selected_obj_paths')==True:
        print "Objeto Pegado en Contents"
        if evt.oldParent==None:
            #Copy/Paste
            #TODO
            return
        else:
            #Cut/Paste
            MoveObject(object, evt, STORAGE)
    
    if request.has_key('-C')==False and request.has_key('__factory__info__')==False \
    and request.has_key('__ac')==True and request.has_key('__cp')==True and request.has_key('fieldname')==False\
    and request.has_key('value')==False and request.has_key('title')==False \
    and request.has_key('id')==False and request.has_key('traverse_subpath')==True and request._steps[-1]=='folder_paste'\
    and request.has_key('selected_obj_paths')==False and request.has_key('folder_paste'):
        print 'Objeto Pegado en acciones'
        
        pdb.set_trace()
        if evt.oldParent==None:
            #Copy/Paste
            #TODO
            return
        else:
            #Cut/Paste
            MoveObject(object, evt, STORAGE)
    return
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
Example #15
0
    def usesGlobalConfig(self):
        """If the global configuration is in use for this site"""

        portal = getSite()
        return ZCONFIG.usesGlobalConfig(portal)