Bloodevil / sony_camera_api

sony camera remote api
http://developer.sony.com/develop/cameras/
MIT License
245 stars 60 forks source link

Examples do not work #25

Open crubier opened 8 years ago

crubier commented 8 years ago

I cannot make this work on my HX90V:

$ python src/example/scan_for_cameras.py 

Available cameras [('HTTP/1.1 200 OK\r\nCACHE-CONTROL: max-age=1800\r\nEXT: \r\nLOCATION: http://192.168.122.1:61000/scalarwebapi_dd.xml\r\nSERVER: UPnP/1.0 MINT-X/1.8.1\r\nST: urn:schemas-sony-com:service:ScalarWebAPI:1\r\nUSN: uuid:000000001000-1010-8000-02AEFA7863EA::urn:schemas-sony-com:service:ScalarWebAPI:1\r\n\r\n', ('192.168.122.1', 48385))]

Checking Camera : ('HTTP/1.1 200 OK\r\nCACHE-CONTROL: max-age=1800\r\nEXT: \r\nLOCATION: http://192.168.122.1:61000/scalarwebapi_dd.xml\r\nSERVER: UPnP/1.0 MINT-X/1.8.1\r\nST: urn:schemas-sony-com:service:ScalarWebAPI:1\r\nUSN: uuid:000000001000-1010-8000-02AEFA7863EA::urn:schemas-sony-com:service:ScalarWebAPI:1\r\n\r\n', ('192.168.122.1', 48385))
[ERROR] camera doesn't workcan only concatenate tuple (not "str") to tuple

This seems to be related to a bug on Line 285 in https://github.com/Bloodevil/sony_camera_api/blob/master/src/pysony.py

Bloodevil commented 8 years ago

it's not a bug on line 285. after "~ doesn't work" string is error message of on try block.

it means the first of data(Checking Camera) should be a tuple not a string. so on the example code. ''' print "Available cameras", cameras

for x in cameras: print "Checking Camera", ":", x camera = pysony.SonyAPI(QX_ADDR=x) <-- this x should be '192.168.122.1' but first of data is string so have error. '''

cameras = [('HTTP/1.1 200 OK\r\nCACHE-CONTROL: max-age=1800\r\nEXT: \r\nLOCATION: http://192.168.122.1:61000/scalarwebapi_dd.xml\r\nSERVER: UPnP/1.0 MINT-X/1.8.1\r\nST: urn:schemas-sony-com:service:ScalarWebAPI:1\r\nUSN: uuid:000000001000-1010-8000-02AEFA7863EA::urn:schemas-sony-com:service:ScalarWebAPI:1\r\n\r\n', ('192.168.122.1', 48385))]

then you should not use the first data. I should check the discover method. but if you check like below it works.

pysony.SonyAPI(QX_ADDR='http://'+x[1][0]+':'+x[1][1]) it means pysony.SonyAPI(QX_ADDR='http://192.168.122.1:48385')

it's a new pattern I didn't seen.before...

krisrok commented 8 years ago

i had the same problem.

so i thought i'd dive into the code (had cloned the repo) to investigate further. just to find out my changes to pysony.py are never called because the setup.py install call (as well as pip install pysony) builds a distributable version and puts it somewhere global for python programs to find it. (yes, i'm new to python)

i got rid of this distributable version by pip uninstall pysony (had to run it twice to get rid of it completely). then i modifed scan_for_cameras.py to use the pysony.py in it's parent folder by adding the following lines before import pysony

import sys
sys.path.insert(0, "..")

after that it just magically worked (and with the other examples too), i did not even have to modify the pysony.py source but the way it gets imported.

so i guess something may be wrong with the setup.py thing?

edit: just found out you don't even have to pip uninstall anything, as long as the sys.path.insert(0, "..") is in place python just grabs the code from there instead of it's global cache.