Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Scripting.java #521

Closed
wants to merge 1 commit into from
Closed

Update Scripting.java #521

wants to merge 1 commit into from

Conversation

cri-s
Copy link
Contributor

@cri-s cri-s commented Apr 15, 2017

No description provided.

changed Scripting to create Examples directory only when it need to create scripts directory.
This is for real usage, where one want remove the example directory because scripts are already setup better to check for examples.
@vonnieda
Copy link
Member

Hi @cri-s, please run one test for me. Make sure that if you start OpenPnp with an empty config directory that the examples get created and copied. If that works okay, let me know, and I will merge this.

@vonnieda
Copy link
Member

@cri-s After thinking about this some more, I think we should do it a different way. The primary use case for this is letting people who upgrade get new script examples to try. With your change they will not get the new examples, and will have to go find them in Git and copy them manually. Since having the Example scripts does no harm, and does give the user more options, I don't want to change this.

What I'd suggest is that you add code that checks for the presence of a .ignore file in each directory as it's loaded. If .ignore is present then don't load that directory or show it in the menu. That way you can even hide the entire Examples menu item.

What do you think?

@vonnieda
Copy link
Member

@cri-s Thanks, I will add it. Ready in 5 mins.

@vonnieda vonnieda closed this Apr 15, 2017
vonnieda added a commit that referenced this pull request Apr 15, 2017
…ll now exclude that directory from the scipts menu.
@vonnieda
Copy link
Member

@cri-s Feature has been added in c001c01

@dzach
Copy link
Contributor

dzach commented Apr 15, 2017

I'm getting the following error when starting the machine:

java.lang.NullPointerException
        at org.apache.commons.io.FileUtils.copyURLToFile(FileUtils.java:1257)
        at org.openpnp.Scripting.<init>(Scripting.java:89)
        at org.openpnp.model.Configuration.load(Configuration.java:288)
        at org.openpnp.gui.MainFrame.<init>(MainFrame.java:500)
        at org.openpnp.Main$1.run(Main.java:106)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
        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.awt.EventQueue.dispatchEvent(EventQueue.java:726)
        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)

@vonnieda
Copy link
Member

@dzach Are you running from source or from a download?

@dzach
Copy link
Contributor

dzach commented Apr 15, 2017

Latest source, develop branch.
All directories are there, I haven't changed anything, nor have I included any .ignore file.

@vonnieda
Copy link
Member

Make sure that you've done a right click refresh in Eclipse. It's possible some files are missing from the cache. If that doesn't fix it, please add:
System.out.println(name);
to line 89 in Scripting.java, right above FileUtils.copyURLToFile and try again. See what it prints out and then see if that file is missing.

@vonnieda
Copy link
Member

@dzach ^

@dzach
Copy link
Contributor

dzach commented Apr 15, 2017

No IDE here, just plain console.

I get:

Python/Print_Hallo_Openpnp.py
java.lang.NullPointerException
        at org.apache.commons.io.FileUtils.copyURLToFile(FileUtils.java:1257)
        at org.openpnp.Scripting.<init>(Scripting.java:90)
[...]

but the file that came in the resources is

openpnp/src/main/resources/scripts/Examples/Python/Print_Hallo_OpenPnP.py

i.e. Print_Hallo_OpenPnP.py and not Print_Hallo_Openpnp.py

So the problem seems to be here, in line 78:

String[] exampleScripts =
new String[] {"JavaScript/Call_Java.js", "JavaScript/Hello_World.js", "JavaScript/Print_Scripting_Info.js",
"JavaScript/Reset_Strip_Feeders.js", "JavaScript/Move_Machine.js", "JavaScript/Utility.js", "JavaScript/QrCodeXout.js",
"Python/Print_Hallo_Openpnp.py", "Python/Print_Methods_Vars.py",
"Python/Print_Nozzle_Info.py"};

@vonnieda
Copy link
Member

vonnieda commented Apr 15, 2017 via email

@vonnieda
Copy link
Member

@dzach Fixed now: 7e59e64

vonnieda added a commit that referenced this pull request Jun 23, 2017
* develop:
  Fixes part of #501, where the job could not be loaded if the panelization process was not completed.
  Changed Scripting.execute from private to public. Will now accept a String filepath, as well.
  Fixes case of an example script which was causing problems on case sensitive filesystems.
  Update README.md
  Update README.md
  Fixes #521: Placing a .ignore file in a subdirectory under scripts will now exclude that directory from the scipts menu.
  Updated changes for two new PRs.
  Remove example scripts that are not working, or that don't use submitMachineTask interface. Move script examples into Python and JavaScript subdirectories.
  Improves tests for eagle mountsmd importer. Adds a test for #390.
  added example-files to Scripting.java for copy action
  relocate files from Python to Examples dir ... and remove CMD/RUN in the filenames
  proposal with yellow power button for issue #379 to visualize missing home
  Fixes #431 by limiting the cam transform to 90 degrees.
  Removes the NavigationView. This feature was never finished and is unlikely to be in this iteration of the user interface. Removing it saves us startup time, removes the JavaFX dependency and solves some bugs. Fixes #396.
  Delete CMD_clear_log.py
  Delete RUN_tool_change_all_nozzle.py
  initial release
  intial commit
  Create CMD_clear_log.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants