If I am in a Python console window, and also have a node editor window open, and I try the command "bpy.ops.node.xxxxnodecommandxxx" for any node editor context sensitive commands, it gives me an incorrect context error because I am in the Python window, not the node editor window. How do I change the window focus from the Python console?
put the bpy.ops call into the simple operator template, change it to be a node operator, remove the test call at the bottom, run script, go to node view and hit spacebar, type the name of your new operator and click/return
you can also override the context, see:
I'm sitting, waiting, wishing, building Blender in superstition...