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

Strange errors when using via rpyc #235

Open
Konubinix opened this issue Sep 2, 2016 · 3 comments
Open

Strange errors when using via rpyc #235

Konubinix opened this issue Sep 2, 2016 · 3 comments

Comments

@Konubinix
Copy link

Konubinix commented Sep 2, 2016

My description just got lost in some stange github bug...

In brief, I can deploy an android application with buildozer and a main.py containing

String = autoclass("java.lang.String")
aaa = String("aaaaa")
acp = [0, 0, 0, 0]
aaa.getBytes(0,4,acp,0)
print(acp)

I will see the result [97, 97, 97, 97]

If I try to do the same via rpyc, I get the "No methods matching your arguments" error, like in the bug #58.
'''python
import rpyc_classic
rpyc_classic.ClassicServer.run()
'''
And from an ipython session, in my desktop, with the soo nice completion, syntax coloring etc.

import rpyc
conn = rpyc.classic.connect("deviceip")
autoclass = conn.modules.jnius.autoclass
const = autoclass('android.hardware.usb.UsbConstants')
const.USB_DIR_IN # this works, indicating that rpyc manages to correctly control the device from my computer
String = autoclass("java.lang.String")
aaa = String("aaaaa")
acp = [0, 0, 0, 0]
aaa.getBytes(0,4,acp,0)
print(acp) # this fails with the No method error

I would gladly suggest a PR, but don't know yet where to start searching to investigate the problem.

Except from that kind of bug, it is very nice to be able to play with my the android API of my phone with the comfort of an ipython session in my computer. Thank you for jnius :-).

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/37533184-strange-errors-when-using-via-rpyc?utm_campaign=plugin&utm_content=tracker%2F77133&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F77133&utm_medium=issues&utm_source=github).
@Konubinix Konubinix changed the title Strange errors w Strange errors when using via rpyc Sep 2, 2016
@inclement
Copy link
Member

I'm afraid I don't know what would cause this, probably you have to dig into the pyjnius code. It might be worth checking if there are any general limitations with rpyc, e.g. with cython code which pyjnius will be using (maybe there's nothing like this, I haven't tried it).

This is a very interesting idea though, I'd be very interested if you're able to get it working.

@Konubinix
Copy link
Author

Thank you for answering.

Actually, I have thought of something. rpyc use an in-house proxying mechanism
called netref to allow transparent use of objects. I think that when confronted
with netref objects, pyjnius does not see the underlying object and try to
convert a netref object into java instead of the underlying object.

I will try converting the rpyc object into a builtin copy (i.e. converting
<netref (list)> into a ) and see if that fixes the problem.

I will try to feed this issue with the result of my quest.

If, in the main time, someone could tell me how to see the types pyjnius
actually sees when trying to call a java method, that could help me a lot.

@Konubinix
Copy link
Author

Thanks a lot to myself of the past. I totally forgot about the netref mechanism and spent a whole day trying to figure out why I could not communicate with my arduino board.

Indeed, performing the work in the android stack did the trick!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants