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

Examples do not work #25

Open
crubier opened this issue Apr 13, 2016 · 2 comments
Open

Examples do not work #25

crubier opened this issue Apr 13, 2016 · 2 comments

Comments

@crubier
Copy link

crubier commented Apr 13, 2016

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
Copy link
Owner

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
Copy link

krisrok commented May 22, 2016

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.

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

No branches or pull requests

3 participants