You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2016/08/16 17:56:38 UTC

tinkerpop git commit: so close, yet so far away. really close to getting gremlin-python working in docs.... Might need @dkuppitz help from here on. :(.

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1278 15c220fb2 -> dc79f8fdf


so close, yet so far away. really close to getting gremlin-python working in docs.... Might need @dkuppitz help from here on. :(.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/dc79f8fd
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/dc79f8fd
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/dc79f8fd

Branch: refs/heads/TINKERPOP-1278
Commit: dc79f8fdf134a445ce7b06e13e8975986f41c40c
Parents: 15c220f
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Tue Aug 16 11:56:31 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Tue Aug 16 11:56:31 2016 -0600

----------------------------------------------------------------------
 docs/preprocessor/awk/init-code-blocks.awk | 39 +++++++------------------
 docs/preprocessor/install-plugins.sh       |  1 +
 2 files changed, 11 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dc79f8fd/docs/preprocessor/awk/init-code-blocks.awk
----------------------------------------------------------------------
diff --git a/docs/preprocessor/awk/init-code-blocks.awk b/docs/preprocessor/awk/init-code-blocks.awk
index 25f8442..dfed351 100644
--- a/docs/preprocessor/awk/init-code-blocks.awk
+++ b/docs/preprocessor/awk/init-code-blocks.awk
@@ -53,32 +53,11 @@ BEGIN {
     print "import org.apache.tinkerpop.gremlin.python.jsr223.PythonTranslator"
     print "import javax.script.ScriptEngineManager"
     print "import javax.script.SimpleBindings"
-    print "def downloadFile(String url, final String localPath) {"
-    print "  def f = new File(localPath)"
-    print "  while (!f.exists() && url) {"
-    print "    url.toURL().openConnection().with { def conn ->"
-    print "      conn.instanceFollowRedirects = false"
-    print "      url = conn.getHeaderField('Location')"
-    print "      if (!url) {"
-    print "        f.withOutputStream { def output ->"
-    print "          conn.inputStream.with { def input ->"
-    print "            output << input"
-    print "            input.close()"
-    print "          }"
-    print "        }"
-    print "      }"
-    print "    }"
-    print "  }"
-    print "  return f"
-    print "}"
-    pythonVersion = "2.7.0"
-    print "pathToLocalJar = System.getProperty('java.io.tmpdir') + File.separator + 'jython-standalone-" pythonVersion ".jar'"
-    print "jarDownloadUrl = 'http://search.maven.org/remotecontent?filepath=org/python/jython-standalone/" pythonVersion "/jython-standalone-" pythonVersion ".jar'"
-    print "loader = new URLClassLoader(downloadFile(jarDownloadUrl, pathToLocalJar).toURI().toURL())"
-    print "jython = new ScriptEngineManager(loader).getEngineByName('jython')"
+    print "jython = new org.apache.tinkerpop.gremlin.python.jsr223.GremlinJythonScriptEngine()"
     print "jython.eval('import sys')"
-    print "jython.eval('sys.path.append(\"" PYTHONPATH "\")')"
+    # print "jython.eval('sys.path.append(\"" PYTHONPATH "\")')"
     print "jython.eval('sys.path.append(\"" TP_HOME "/gremlin-python/target/test-classes/Lib\")')"
+    # print "jython.eval('sys.path.append(\"/Users/marko/software/tinkerpop/gremlin-python/target/test-classes/Lib\")')"
     print "jython.eval('from gremlin_python import statics')"
     print "jython.eval('from gremlin_python.process.graph_traversal import GraphTraversal')"
     print "jython.eval('from gremlin_python.process.graph_traversal import GraphTraversalSource')"
@@ -88,15 +67,15 @@ BEGIN {
     print "jython.eval('from gremlin_python.process.traversal import Operator')"
     print "jython.eval('from gremlin_python.process.graphson import GraphSONWriter')"
     print "jython.eval('from gremlin_python.process.graphson import serializers')"
-    print "jython.eval(' from gremlin_python.process.traversal import Bytecode')"
+    print "jython.eval('from gremlin_python.process.traversal import Bytecode')"
     print "jython.eval('statics.load_statics(globals())')"
-    print "jythonBindings = new SimpleBindings()"
+    print "jythonBindings = jython.createBindings()"
     print "jythonBindings.put('g', jython.eval('RemoteGraph(None).traversal()'))"
     print "jython.getContext().setBindings(jythonBindings, javax.script.ScriptContext.GLOBAL_SCOPE)"
-    print "groovyBindings = new SimpleBindings()"
+    print "groovy = new org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine()"
+    print "groovyBindings = groovy.createBindings()"
     print "groovyBindings.put('g', g)"
     print "groovyBindings.put('TinkerGraphComputer', TinkerGraphComputer)"
-    print "groovy = new org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine()"
     print "groovy.getContext().setBindings(groovyBindings, javax.script.ScriptContext.GLOBAL_SCOPE)"
   }
   print "'-IGNORE'"
@@ -106,7 +85,9 @@ BEGIN {
   if (delimiter == 2 && !($0 ~ /^pb\([0-9]*\); '----'/)) {
     switch (lang) {
       case "python":
-        print "groovy.eval jython.eval(\"\"\"" gensub("\\('id',([0-9]+)\\)", "\\1", "g") "\"\"\").toString()"
+        print "jython.getContext().getBindings(javax.script.ScriptContext.GLOBAL_SCOPE).put('j',\"\"\"" gensub("\\('id',([0-9]+)\\)", "\\1", "g") "\"\"\")"
+        print "groovy.getContext().getBindings(javax.script.ScriptContext.GLOBAL_SCOPE).put('j', jython.eval('GraphSONWriter.writeObject(j)').toString())"
+        print "groovy.eval(groovy.eval('GroovyTranslator.of(\"g\").translate(GraphSONReader.build().create().mapper.readValue(j,Bytecode.class))').toString())"
         break
       default:
         print

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dc79f8fd/docs/preprocessor/install-plugins.sh
----------------------------------------------------------------------
diff --git a/docs/preprocessor/install-plugins.sh b/docs/preprocessor/install-plugins.sh
index ae6b049..8411f37 100755
--- a/docs/preprocessor/install-plugins.sh
+++ b/docs/preprocessor/install-plugins.sh
@@ -50,6 +50,7 @@ while [ ${i} -lt ${pluginsCount} ]; do
   fi
   ((i++))
 done
+echo ":install org.apache.tinkerpop gremlin-python ${TP_VERSION}" >> ${INSTALL_FILE}
 
 echo "System.exit(0)" >> ${INSTALL_FILE}
 echo -ne " * tinkerpop-sugar ... "