webgme / bindings

WebGME API bindings for Python
MIT License
1 stars 4 forks source link

Python-based plugin namespace is not set correctly #3

Closed cahartsell closed 5 years ago

cahartsell commented 5 years ago

For python-based plugins, the namespace does not appear to be set correctly in "run_plugin.py". Relevant snippet below:

PORT = sys.argv[1]
COMMIT_HASH = sys.argv[2].strip('"')
BRANCH_NAME = sys.argv[3].strip('"')
ACTIVE_NODE_PATH = sys.argv[4].strip('"')
ACTIVE_SELECTION_PATHS = []

if sys.argv[4] != '""':
    ACTIVE_SELECTION_PATHS = sys.argv[4].strip('"').split(',')
    if ACTIVE_SELECTION_PATHS[0] == '':
        ACTIVE_SELECTION_PATHS.pop(0)

NAMESPACE = sys.argv[5].strip('"')

Also, the value of my 'sys.args' according to the logs:

sys.args: ['/alc/webgme/src/plugins/ROSLaunchGenerator/run_plugin.py',
                 '5555',
                 '"#5c334a5ba9aaa69c2a1a48e01db06e037dc3816b"',
                 '"master"',
                 '"/y/V/V/X"',
                 '"/y/V/V/X/g"',
                 '"ALCMeta"']

So it looks like the "active-selection-path" should be sys.argv[5] instead of 4 and "namespace" should be sys.argv[6] instead of 5. In my case everything happens to work when there is no active node selected because this results in namespace="". I reference all my META objects with the absolute path (eg. "ALC_Meta.MyObject") so an empty namespace is not a problem. However, if any node is selected when the plugin is run, then it fails with an "Invalid Namespace" error.

pmeijer commented 5 years ago

Charlie, good catch. The template for the boilerplate generator is in https://github.com/webgme/webgme-engine/blob/master/src/plugin/coreplugins/PluginGenerator/run_plugin_py.ejs. (It could be worth the while fix it here to - but has lower prio). Can you create an issue in the webgme-engine? Or even better a PR ;) Thanks

cahartsell commented 5 years ago

I've copied this issue to the webgme-engine repo and created a PR with the fix. I'm not entirely sure where the fix would go in this (webgme/bindings) repo. I'll leave this issue open for now