wrap log methods

Jean-Francois Dockes Jean-Francois Dockes 2017-10-21

added samples/openhome.py
changed samples/events.py
changed upnpp.i
copied samples/tryit.py -> samples/cooked.py
samples/openhome.py Diff Switch to side-by-side view
Loading...
samples/events.py Diff Switch to side-by-side view
Loading...
upnpp.i Diff Switch to side-by-side view
Loading...
samples/tryit.py to samples/cooked.py
--- a/samples/tryit.py
+++ b/samples/cooked.py
@@ -1,5 +1,6 @@
 #!/usr/bin/python
-
+'''Using the discovery service and the avtransport classes instead of
+findTypedService(), and the string-based interface'''
 from __future__ import print_function
 
 import sys
@@ -9,32 +10,17 @@
 def debug(x):
    print("%s" % x, file = sys.stderr)
 
-srv = upnpp.findTypedService("UpMpd-bureau", "avtransport", True)
+if len(sys.argv) != 2:
+   usage()
+def usage():
+   debug("Usage: getmedinfo.py devname")
+   sys.exit(1)
+if len(sys.argv) != 2:
+   usage()
+fname = sys.argv[1]
 
-if not srv:
-   debug("findTypedService failed")
-   sys.exit(1)
-   
-args = ["0", "http://192.168.4.4:9790/minimserver/*/mp3/variete/billy_joel/the_stranger/01*20-*20Movin*27*20Out*20(Anthony*27s*20Song).mp3", ""]
-# retdata = upnpp.runaction(srv, "SetAVTransportURI", args)
-
-# Instanceid speed
-# retdata = upnpp.runaction(srv, "Play", ["0", "1"])
-
-def seekloop():
-   for i in range(0,3):
-      # InstanceId, Unit, target
-      retdata = upnpp.runaction(srv, "Seek", ["0", "REL_TIME", "0:0:30"])
-      retdata = upnpp.runaction(srv, "GetMediaInfo", ["0"])
-      time.sleep(2)
-
-#retdata = upnpp.runaction(srv, "Seek", ["0", "REL_TIME", "0:20:30"])
-
-
-retdata = upnpp.runaction(srv, "GetPositionInfo", ["0"])
-
-retdata = upnpp.runaction(srv, "Stop", ["0"])
-
+log = upnpp.Logger_getTheLog("stderr")
+log.setLogLevel(2)
 
 # Get in touch with discovery service
 dir = upnpp.UPnPDeviceDirectory_getTheDir()
@@ -46,7 +32,6 @@
 # pointer to an allocated object (can't return a pointer to the
 # original object because locking etc.). This avoid allocating a copy
 # inside getDev...(), and deciding who is responsible for the memory.
-fname = "UpMpd-bureau"
 description = upnpp.UPnPDeviceDesc()
 if not dir.getDevByFName(fname, description):
    debug("%s not found" % fname)
@@ -59,7 +44,6 @@
 # in the .i file, instead of 1 per class if we were using the static
 # methods. Another approach would be to have static methods in the
 # C++, just taking an UDN or friendlyname, and returning an object.
-# rdr = RenderingControlFindAllocate(friendlyname)
 rdrc = upnpp.RenderingControl()
 status = rdrc.initFromDescription(description)
 if status:
@@ -75,5 +59,5 @@
 if status:
    posinf = upnpp.AVTPositionInfo()
    status = upnpp.AVTGetPositionInfo(avt, posinf)
-   print("\nAVTRansport ok: PositionInfo: trackuri: %s" % posinf.trackuri)
-   
+   print("PositionInfo: duration %d S, trackuri: %s" %
+         (posinf.trackduration, posinf.trackuri))