Rev 2: Trying to get Java to interact with bzrlib seems to be failing...h in http://bzr.arbash-meinel.com/branches/bzr/bzrlib_java_test

John Arbash Meinel john at arbash-meinel.com
Fri Mar 30 17:53:52 BST 2007


At http://bzr.arbash-meinel.com/branches/bzr/bzrlib_java_test

------------------------------------------------------------
revno: 2
revision-id: john at arbash-meinel.com-20070330165351-0ng92k4gz0auhwap
parent: john at arbash-meinel.com-20070330163743-o5qallhstxmkrcj2
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: bzrlib_java_test
timestamp: Fri 2007-03-30 11:53:51 -0500
message:
  Trying to get Java to interact with bzrlib seems to be failing...h
  I'll keep trying, though.
modified:
  ImportBzrlibTest.java          importbzrlibtest.jav-20070330163449-4vo592rbe92sp2ql-1
  Makefile                       makefile-20070330163449-4vo592rbe92sp2ql-2
-------------- next part --------------
=== modified file 'ImportBzrlibTest.java'
--- a/ImportBzrlibTest.java	2007-03-30 16:37:43 +0000
+++ b/ImportBzrlibTest.java	2007-03-30 16:53:51 +0000
@@ -10,13 +10,36 @@
     public ImportBzrlibTest() {
     }
 
+    public void load_and_enable_bzrlib() throws JepException{
+        jep.eval("import bzrlib.trace");
+        jep.eval("import bzrlib.branch");
+        jep.eval("import bzrlib.workingtree");
+        jep.eval("import sys");
+
+        // This doesn't seem to do much. It may just be that python can't
+        // access any file handles because of Java's security model? If that is
+        // the case, we may be stuck with invoking scripts, which isn't much
+        // better than invoking bzr instead of bzrlib...
+        jep.invoke("bzrlib.trace.enable_default_logging");
+    }
+
     public void run() throws Throwable {
-        System.out.println("Running");
         File pwd = new File(".");
 
         this.jep = new Jep(false, pwd.getAbsolutePath());
         try {
-            jep.runScript("test_import.py");
+            load_and_enable_bzrlib();
+            // These doesn't seem to do anything. They also don't claim to
+            // fail....
+            jep.invoke("bzrlib.trace.note", "Who are you?");
+            jep.invoke("bzrlib.trace.note", "And what have you done with: %s",
+                        "me");
+
+            Object a_branch =
+                jep.invoke("bzrlib.workingtree.WorkingTree.open_containing",
+                           "/");
+
+            System.out.println("a_branch: " + a_branch);
         } finally {
             if (jep != null)
                 jep.close();
@@ -24,8 +47,6 @@
     }
 
     public static void main(String args[]) throws Throwable {
-        System.out.println("Hello World");
-
         ImportBzrlibTest test = new ImportBzrlibTest();
         test.run();
     }

=== modified file 'Makefile'
--- a/Makefile	2007-03-30 16:37:43 +0000
+++ b/Makefile	2007-03-30 16:53:51 +0000
@@ -1,11 +1,12 @@
 JEP_SRC=$(HOME)/dev/other/jepp/jep/src
+BZRLIB_PATH=$(HOME)/dev/bzr/bzr.dev
 
 .PHONY: all test
 
 all: ImportBzrlibTest.class
 
 test: ImportBzrlibTest.class
-	PYTHONPATH=$(HOME)/dev/bzr/bzr.dev java -classpath .:$(JEP_SRC) ImportBzrlibTest
+	PYTHONPATH=$(BZRLIB_PATH) java -classpath .:$(JEP_SRC) ImportBzrlibTest
 
 %.class: %.java
 	javac -sourcepath $(JEP_SRC) $?



More information about the bazaar-commits mailing list