processing-uploadtopi icon indicating copy to clipboard operation
processing-uploadtopi copied to clipboard

Add support for Python mode sketches

Open sheamusburns opened this issue 7 years ago • 11 comments

It threw an error when I tried in Python mode, but so figured it's only for Java, but didn't see any specifics in the docs so wanted to check.

Thanks!

sheamusburns avatar Nov 04 '17 22:11 sheamusburns

@sheamusburns What's the error?

gohai avatar Nov 05 '17 10:11 gohai

I get a "Cannot export sketch" error in the red banner and then the following in the console:

java.lang.NoSuchMethodException: jycessing.mode.PythonMode.handleExportApplication(processing.app.Sketch) at java.lang.Class.getMethod(Class.java:1786) at gohai.uploadtopi.UploadToPiTool.exportSketch(UploadToPiTool.java:311) at gohai.uploadtopi.UploadToPiTool.run(UploadToPiTool.java:126) at processing.app.contrib.ToolContribution.run(ToolContribution.java:124) at processing.app.Base$5.actionPerformed(Base.java:828) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.AbstractButton.doClick(AbstractButton.java:376) at com.apple.laf.ScreenMenuItem.actionPerformed(ScreenMenuItem.java:125) at java.awt.MenuItem.processActionEvent(MenuItem.java:669) at java.awt.MenuItem.processEvent(MenuItem.java:628) at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:357) at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:345) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:761) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90) at java.awt.EventQueue$4.run(EventQueue.java:731) at java.awt.EventQueue$4.run(EventQueue.java:729) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) at java.awt.EventQueue.dispatchEvent(EventQueue.java:728) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) java.lang.NoSuchMethodException: jycessing.mode.PythonMode.handleExportApplication(processing.app.Sketch)

sheamusburns avatar Nov 06 '17 02:11 sheamusburns

@sheamusburns Thanks. Can you "export" sketches in Python mode, or merely execute them?

gohai avatar Nov 06 '17 08:11 gohai

Yes, in addition to 'playing' the sketch from the application itself, I can also use the native Export Application option in the file menu.

sheamusburns avatar Nov 06 '17 14:11 sheamusburns

@sheamusburns Thanks! I looked at the code and it appears to me as if the Python mode is not exporting applications for the armv6hf architecture, though. The UploadToPi tool really just makes use of those exported applications to upload and launch on the ARM device - so that would be a precondition for making this work with the Python mode. (CC @jdf)

gohai avatar Nov 06 '17 18:11 gohai

Feel free to add me to this project and assign the bug to me. If you'd prefer not to, I'll create a new bug on my project, and refer to this one. Let me know!

jdf avatar Nov 06 '17 18:11 jdf

@jdf Export for armv6hf would be best handled in your repo - I'll make sure that this UploadToPi tool will make use of this functionality whenever you get around hacking on it!

gohai avatar Nov 06 '17 18:11 gohai

Just to make sure I understand, do I simply need to add a platform to this code

https://github.com/jdf/processing.py/blob/master/runtime/src/jycessing/mode/export/Exporter.java#L49

? And then your code will do the rest? Or is there more to it?

jdf avatar Nov 06 '17 18:11 jdf

@jdf If you add the equivalent of what you already have for other platforms to export (which would go on and pick the armv6hf library variants to bundle), this should allow me to do call that function with a bit of reflection magic in this tool.

This is the core of what my code is currently doing for Java mode: https://github.com/gohai/processing-uploadtopi/blob/master/src/gohai/uploadtopi/UploadToPiTool.java#L307

... it's a hack, but happy to add some heuristics to also deal with Python mode in a similar fashion.

gohai avatar Nov 06 '17 19:11 gohai

Gotcha. When I do get it working, you'll have to call the function on the Editor, and not the Mode.

https://github.com/gohai/processing-uploadtopi/blob/master/src/gohai/uploadtopi/UploadToPiTool.java#L311

because

https://github.com/jdf/processing.py/blob/master/runtime/src/jycessing/mode/PyEditor.java#L263

jdf avatar Nov 06 '17 19:11 jdf

@jdf Thanks for the heads-up!

gohai avatar Nov 06 '17 22:11 gohai