Help on wrong parameters (GUPnP)



Hi all,

I'm tring to dialog using Python with the ContentDirectory service of a
uPnp device.
When executing, I get this exception coming from the send_action_hash
method :

TypeError: send_action_hash() takes exactly 4 arguments (5 given)

Here is my short code :


#/usr/bin/python2
# -*- coding: utf-8 -*-
from gi.repository import GLib, GUPnP

def device_available (cp, proxy):
    print ("Found " + proxy.get_friendly_name())
    content_dir =
proxy.get_service("urn:schemas-upnp-org:service:ContentDirectory")
    if content_dir is not None:
        in_data = {
            "ObjectID": "0",
            "BrowseFlag": "BrowseMetadata",
            "Filter": "*",
            "StartingIndex": "0",
            "RequestCount": "0",
            "SortCriteria": ""
        }
        out_data = {
            "Result": "",
            "NumberReturned": "",
            "TotalMatches": "",
            "UpdateID": ""
        }
        b, result = content_dir.send_action_hash("Browse", None,
in_data, out_data)

ctx = GUPnP.Context.new(None, None, 0)
cp = GUPnP.ControlPoint.new(ctx, "upnp:rootdevice")
cp.set_active(True)
cp.connect("device-proxy-available", device_available)

GLib.MainLoop().run()


Putting a breakpoint just before the instruction, I can display the
docstring of the send_action_hash method. From the docstring, it takes 5
arguments and I pass 5 arguments too (of course, I count the service
proxy instance which is hidden but passed by Python).

$ python2 sync_camera.py
Found Seixas

/home/franck/panoware/python/SonySyncCamera/sony_sync_camera.py(26)device_available()
-> b, resultat = content_dir.send_action_hash("Browse", None, in_data,
out_data)
(Pdb) type(content_dir)
<class 'gi.repository.GUPnP.ServiceProxy'>
(Pdb) content_dir.send_action_hash.__doc__
'send_action_hash(self, action:str, error:error=None, in_hash:dict,
out_hash:dict) -> bool, out_hash:dict'
(Pdb) p GUPnP
<gi.module.DynamicModule 'GUPnP' from
'/usr/lib/girepository-1.0/GUPnP-1.0.typelib'>

I've spent many hours on this without success. Does somebody can give me
a hand on calling the methods with the right parameters ?

I've read many docs about object introspection, I've found these very
interesting docs. From the first one, what I'm doing is correct :

https://lazka.github.io/pgi-docs/GUPnP-1.0/classes/ServiceProxy.html#GUPnP.ServiceProxy.send_action_hash
https://wiki.gnome.org/action/show/Projects/PyGObject/IntrospectionPorting?action=show&redirect=PyGObject%2FIntrospectionPorting

I'm on Arch Linux, I use Python2 (2.7.9). Here are the versions of the
relevant packages :

gobject-introspection 1.42.0-1
pygobject-devel 3.14.0-2
pygobject2-devel 2.28.6-11
python-gobject 3.14.0-2
python-gobject2 2.28.6-11
python2-gobject 3.14.0-2
python2-gobject2 2.28.6-11
gupnp 0.20.12-1
gupnp-av 0.12.6-1
gupnp-tools 0.8.9-1

I've checked the /usr/share/gir-1.0/GUPnP-1.0.gir file.

Thanks.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]