Quantcast
Channel: MySQL Forums - MySQL Workbench
Viewing all articles
Browse latest Browse all 3739

Creating new plugin fails (multiple issues) (no replies)

$
0
0
Open MySQL WB, go to menu Scripting -> Scripting Shell (new window appearing).

Right-click in File Browser to the left -> Add New File (dialog opening).

Select "Python Plugin" -> choose "Generic Plugin" from radio items, leave default names. Then click "Create".

A new tab appears with the default name "myplugin_grt.py" (having an asterisk). Save using Ctrl+S. The new plugin file now appears in the File Browser to the left.

The debugger panel below says:

"Script saved as C:\Users\Kawu\AppData\Roaming\MySQL\Workbench\scripts\myplugin_grt.py
"

The new plugin file has the following contents:

--

# MySQL Workbench Plugin
# <description>
# Written in MySQL Workbench 8.0.36

from wb import *
import grt
#import mforms

ModuleInfo = DefineModule(myplugin, author="Author Name", version="1.0", description="Contains Plugin myplugin")

# This plugin takes no arguments
@ModuleInfo.plugin(myplugin, caption="Caption", description="description", input=[wbinputs.currentModel()], pluginMenu="Utilities")
@ModuleInfo.export(grt.INT)
def myplugin():
# Put plugin contents here
return 0

--

Now click on the lightning button in the toolbar saying "Execute script".

This results in:

"> run
Uncaught exception while executing C:\Users\Kawu\AppData\Roaming\MySQL\Workbench\scripts\myplugin_grt.py:
File "<string>", line 9, in <module>
NameError: name 'myplugin' is not defined"

It's kinda obvious this cannot work. The plugin name must be a string (on line 9 and line 12 respectively).

--

# MySQL Workbench Plugin
# <description>
# Written in MySQL Workbench 8.0.36

from wb import *
import grt
#import mforms

ModuleInfo = DefineModule("myplugin", author="Author Name", version="1.0", description="Contains Plugin myplugin")

# This plugin takes no arguments
@ModuleInfo.plugin("myplugin", caption="Caption", description="description", input=[wbinputs.currentModel()], pluginMenu="Utilities")
@ModuleInfo.export(grt.INT)
def myplugin():
# Put plugin contents here
return 0

--

Now running this results in:

"> run
Execution finished"

Before return 0 if I enter:

print("Here I am!")

executing the script outputs:

"> run
Execution finished"

Where's the output of my print statement? Why is nothing being output?

BTW, this is really embarassing WB guys...

Regards
Karsten

Viewing all articles
Browse latest Browse all 3739

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>