Advertisement
daddydean

Untitled

Jul 11th, 2017
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. /**
  2.  * Python Command (v2.0)
  3.  * GoToLoop (2017/Jul/05)
  4.  *
  5.  * https://Forum.Processing.org/two/discussion/23324/
  6.  * executing-python-3-code-from-within-processing#Item_38
  7.  *
  8.  * https://GitHub.com/GoToLoop/command/blob/patch-1/src/
  9.  * deadpixel/command/Command.java
  10.  */
  11.  
  12. import deadpixel.command.Command;
  13.  
  14. static final String BASH =
  15.   platform == WINDOWS? "cmd /C " :
  16.   platform == MACOSX? "open" : "xdg-open";
  17.  
  18. static final String CD = "cd ", PY_APP = "python ";
  19. static final String AMP = " && ", SPC = " ";
  20.  
  21. static final String PY_DIR = "scripts/";
  22. //static final String PY_FILE = PY_DIR + "abc.py";
  23. static final String PY_FILE = PY_DIR + "segmenting.py";
  24.  
  25. static final String PICS_DIR = "images/";
  26. static final String PICS_EXTS = "extensions=,png,jpg,jpeg,gif";
  27.  
  28. void setup() {
  29.   final String dp = dataPath(""), py = dataPath(PY_FILE);
  30.   final String prompt = BASH + CD + dp + AMP + PY_APP + py;
  31.  
  32.   final String pd = dataPath(PICS_DIR);
  33.   final String pics = join(listPaths(pd, PICS_EXTS), SPC);
  34.  
  35.   final Command cmd = new Command(prompt + SPC + pics);
  36.   println(cmd.command, ENTER);
  37.  
  38.   println("Successs:", cmd.run(), ENTER);
  39.   printArray(cmd.getOutput());
  40.  
  41.   exit();
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement