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
    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):
            self.enabled = True
            self.init("New Source",
                      [("new-source", self.newSource, "New Source")],

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

    def createMode():
        return NewSourcePathMode()

  • 0
    (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.




    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):

    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):
    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])


    # Delay this until after the event completes.
    from PySide import QtCore
    self._deleteTimer = QtCore.QTimer.singleShot(0, deleteFileSource)
    # 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.
    except Exception as e:
    print e

    def createMode():
    return {PACKAGE_NAME}Mode()
  • 0
    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
    Nick Burdan

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


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