0

how to not load or unload files with certain extensions

I'm trying to stop rv from loading files with certain extensions.  Just simply ignore them and do nothing.  From what I can gather, not loading them is not possible.  I'm instead trying to UNload them after they are loaded by calling commands.deleteNode() on a new-source event but this is not working (seg faults instead).  Is there a way to do this?

댓글 4개

  • 0
    Avatar
    Nick Burdan

    For example, I'd like to ignore txt files if they are dragged into rv.  Here I am trying to delete them after they are loaded, which causes seg fault:

    class NewSourcePathMode(rvtypes.MinorMode):
        def __init__(self):
            rvtypes.MinorMode.__init__(self)
            self.enabled = True
            self.init("New Source",
                      None,
                      [("new-source", self.newSource, "New Source")],
                      None
                      )

        def newSource(self, event):
            contents = event.contents()
            tokens = contents.split(';;')
            node = tokens[0]
            filepath = tokens[2]
            if filepath.endswith('.txt'):
                commands.deleteNode(node)
            event.reject()      

    def createMode():
        return NewSourcePathMode()

  • 0
    Avatar
    (Michael) Kessler

    Hi Nick,

     

    Thanks for writing in!  I'm sorry you've been wrestling this, but I think I've come up with something that might work for you.  You are indeed correct in looking for a way to rectify loading something that was intended to be loaded; there's not really a way I can see to prevent something from loading that was already requested to be loaded.

     

    The events require a bit more use out of the nodes that are created immediately after the events are fired, so it is unsafe to modify them then, however immediately after source-group-complete you are free to remove the node.  I do this with a 0ms timer which effectively places the removal event at the end of the event loop.  This ensures that the events are complete.  This is my implemention to do what you are asking about.

     

    I hope this finds you well.  Please note that there may be some things you want to add to this, but this should at least get you started.

     

    -Kessler

     

    from rv import commands, extra_commands, rvtypes
    from rv.commands import NeutralMenuState

    def groupMemberOfType(node, memberType):
    for n in commands.nodesInGroup(node):
    if commands.nodeType(n) == memberType:
    return n
    return None

    class {PACKAGE_NAME}Mode(rvtypes.MinorMode):

    def __init__(self):
    rvtypes.MinorMode.__init__(self)

    globalBindings = [
    ("source-group-complete", self.newSource, "New Source"),
    ]
    localBindings = None

    menu = None

    self.init("{PACKAGE_NAME}", globalBindings, localBindings, menu, 'zz_source_setup', 0)

    def filterSourcePaths(self, sourcePaths):
    # Do your own logic for filtering source paths.
    return [i for i in sourcePaths if not i.endswith('.txt')]


    def newSource(self, event):
    try:
    args = event.contents().split(";;")
    group = args[0]
    fileSource = groupMemberOfType(group, "RVFileSource")
    if fileSource:
    mmp = "%s.media.movie" % fileSource
    sourcePaths = commands.getStringProperty(mmp)
    filteredSourcePaths = self.filterSourcePaths(sourcePaths)
    if not filteredSourcePaths:

    def deleteFileSource():
    (_,outputs) = commands.nodeConnections(group)

    # Remove all dependencies. See session manager for similar behavior.
    for output in outputs:
    (inputs, _) = commands.nodeConnections(output)
    commands.setNodeInputs(output, [i for i in inputs if i != group])

    commands.deleteNode(group)

    # Delay this until after the event completes.
    from PySide import QtCore
    self._deleteTimer = QtCore.QTimer.singleShot(0, deleteFileSource)
    else:
    # If we have removed media paths from our source, then re-set the source path to remove the garbage.
    # This allows garbage to be removed from second eyes or when trying to add audio.
    if sourcePaths != filteredSourcePaths:
    commands.setStringProperty(mmp, filteredSourcePaths, True)

    # Ignore the event if the source isn't deleted, otherwise absorb it to prevent further processing.
    event.reject()
    except Exception as e:
    print e
    event.reject()

    def createMode():
    return {PACKAGE_NAME}Mode()
  • 0
    Avatar
    Nick Burdan

    Thanks so much!  That works!  The console window still pops up with the ERROR: Open of ... failed: unsupported media type but the file itself is successfully removed from the sources.  Is there is a way to close/dismiss the console window?

  • 0
    Avatar
    Nick Burdan

    I suppose I can add this to the prefs to not open the console by default:

    [Console]
    showOn=4

    I'm curious though if there is a way to close it with the api after it opens?

     

댓글을 남기려면 로그인하세요.