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

Value Error on line 224of install.py #13

Closed
fremenusul opened this issue Nov 24, 2013 · 40 comments
Closed

Value Error on line 224of install.py #13

fremenusul opened this issue Nov 24, 2013 · 40 comments

Comments

@fremenusul
Copy link

Traceback (most recent call last):
File "./install.py", line 224, in
redirect_stderr=true''')
ValueError: I/O operation on closed file

@danslimmon
Copy link
Owner

Not a SyntaxError, but a ValueError. Anyway I'll fix it snappy

@danslimmon
Copy link
Owner

Resolved by 11a8fdb

@fremenusul
Copy link
Author

ok after fetch, I am still getting same error.

git is already the newest version.
supervisor is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Traceback (most recent call last):
File "./install.py", line 224, in
redirect_stderr=true''')
ValueError: I/O operation on closed file

@fremenusul
Copy link
Author

Will reopen a new bug I guess?

@danslimmon
Copy link
Owner

You mean "git pull"? Fetch just requests the latest objects from the origin; pull will update your working copy.

@fremenusul
Copy link
Author

Whoops. I am pretty new to this. git pull fixed that issue and now a new one. ;)

Restarted supervisord

############################################################

Done! Your new grocery list can be found at:

Traceback (most recent call last):
File "./install.py", line 234, in
print ' {0}'.format(grocery_board_url)

@danslimmon
Copy link
Owner

Thanks for helping me find all these bugs! I've fixed the grocery board URL in install.py, but you should be all set now to start using Oscar. You can find your grocery list by just going into the Trello web UI and looking for the "Groceries" board.

As the rest of the message would have said:

print 'If everything worked, then you should be able to start scanning'
print 'barcodes with oscar. Check out the logs of the scanner process and'
print 'the web app, respectively, at'
print
print '    /var/lib/supervisor/log/oscar_scan.log'
print '    /var/lib/supervisor/log/oscar_web.log'
print
print 'And report any bugs at https://github.com/danslimmon/oscar/issues.'
print
print 'To add new product description keywords, the current method is to'
print 'edit the oscar_db board directly. This should change soon with #5.'
print
print 'Enjoy!'

@fremenusul
Copy link
Author

I thought that might be the case, I ran python /var/oscar/scan.py

I am not sure if this is a digit-eyes error or not.

To confirm, the APP K code should have the //xyzabc (the two slashes) when you run it?

Waiting for scanner data
Scanned barcode '021130240302'
Traceback (most recent call last):
File "/var/oscar/scan.py", line 177, in
desc = u.get_description(barcode)
File "/var/oscar/scan.py", line 57, in get_description
json_blob = urllib2.urlopen(url).read()
File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 407, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 520, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 445, in error
return self._call_chain(_args)
File "/usr/lib/python2.7/urllib2.py", line 379, in _call_chain
result = func(_args)
File "/usr/lib/python2.7/urllib2.py", line 528, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 401: Valid signature required

@danslimmon
Copy link
Owner

The app key should begin and end with a slash. There shouldn't be two slashes in a row. Did your config file end up with an app key with two slashes in a row? If so, I'd be interested to see your original input, since that would indicate another bug in install.py.

@fremenusul
Copy link
Author

in the oscar.yaml it shows as you said eg: /abcxyz/

In the digit-eyes site it shows //abcxyz

I ran another git pull and did the install.py (WORKED!!!!)

I scanned an nothing happened so then I ran the python /var/oscar/scan.py again.

Getting the exact same error as above.

@danslimmon
Copy link
Owner

Interesting. Perhaps it's only my key in particular that starts and ends with a slash. Have you tried replacing the code in /etc/oscar.yaml with exactly what is specified under your Digit-Eyes account?

@fremenusul
Copy link
Author

Ok, that is what did it. I formatted it the way mine was setup and works fine.

So a new issue. :)

python /var/oscar/scan.py
Waiting for scanner data
Scanned barcode '021130240302'
Received description 'Safeway Refreshe Water Purified Drinking' for barcode '021130240302'
Don't know what to add for product description 'Safeway Refreshe Water Purified Drinking'
Waiting for scanner data

I didnt get a text and I didnt see any changes to my trello boards (grocery or trello_db)

No errors were thrown,

I checked the twilio dashboard and it shows a SMS was sent.

I am pretty sure there might be something up with the number. I formatted the phone number '16501234567" (twilio_dest and src)

@danslimmon
Copy link
Owner

Just to be clear, you have your Twilio-given phone number as "twilio_src" and your cell phone's number as "twilio_dest", correct?

If Twilio says the text was sent, then I'm not sure how much I can help you from here...

@fremenusul
Copy link
Author

yup.

Shouldnt the trello db show the new barcode or does that get updated via the txt message?

@danslimmon
Copy link
Owner

Yes, in your oscar_db board (make sure there wasn't more than one of these created by the install script, since you ran it a few times!) there should now be an entry under "learning opportunities" with the barcode you scanned. If there's not, then oscar_scan messed that up and I'd really appreciate some help debugging that. Can you check?

As far as the text goes, it sounds like the text made it to Twilio. I wonder if you're able to send yourself a text message with this simple Python example from the Twilio docs?

from twilio.rest import TwilioRestClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "AC32a3c49700934481addd5ce1659f04d2"
auth_token  = ""
client = TwilioRestClient(account_sid, auth_token)

message = client.sms.messages.create(body="Jenny please?! I love you <3",
    to="+14159352345",    # Replace with your phone number
    from_="+14158141829") # Replace with your Twilio number
print message.sid

If that doesn't work, then I'd advise you to further debug your Twilio account settings until it does. I don't think I can help a ton with that part.

@fremenusul
Copy link
Author

Ok, I was wrong, the text never made it to twilio (I even deposited 20 bucks to double double check!) So it looks like there is a APi issue somewhere.

Should it be oscar_db? According to install script it was trello_db?

I see nothing under learning opportunities but I see the default data (beer, coffee, etc) for description rules.

I ran the example python script and it worked perfectly. (event took out 1 cent to send the example text from my account!)

@danslimmon
Copy link
Owner

The board should be called 'oscar_db' and not 'trello_db' (see 97fedac), but in the config it's referred to by its ID, so the incorrect name shouldn't have affected oscar_scan's ability to create a learning opportunity. Still, I'd recommend you rename the board to 'oscar_db' to prevent future confusion.

To begin troubleshooting the learning opportunity issue, could you go into /etc/oscar.yaml, look the trello_db_board value (excluding the quotation marks), and compare that value to the URL for your oscar_db Trello board? The latter should be of the form

https://trello.com/b/<THE FORMER>/...

@fremenusul
Copy link
Author

the data in /etc/oscar.yaml and the string in the URL are the exact same.

I renamed to oscar_db

Ran python /var/oscar/scan.py and no text and no change to oscar_db on trello

@fremenusul
Copy link
Author

Just to double check I went to account settings. The install.py defiantly worked as it has all the default data. I am not 100% sure the scan.py is working.

oscar
read and write access on all your boards, read and write access on all your organizations

Approved: Nov 23 at 2:30 PM
Never Expires

@danslimmon
Copy link
Owner

Try running this test script in /var/oscar on your Pi. Should tell us where things are going wrong:

https://gist.github.com/danslimmon/7633178

@fremenusul
Copy link
Author

Traceback (most recent call last):
File "fremenusul_test.py", line 4, in
from lib import trellodb
ImportError: No module named lib

@danslimmon
Copy link
Owner

I've updated the script at https://gist.github.com/danslimmon/7633178 to make sure that the current directory is searched for packages, and to make sure it is in /var/oscar when it tries to load trellodb. Try again?

@fremenusul
Copy link
Author

python fremenusul_test.py
sys.path:
['/home/pi/src', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/pymodules/python2.7', '.']
Before creating barcode opp, the contents of learning_opportunities is:

[]

After creating barcode opp, the contents of learning_opportunities is:
[{u'barcode': u'01234567890', u'type': u'barcode', u'created_dt': u'2013-11-24 14:37:41', u'opp_id': u'testabc123'}]

Testing notification

You should receive a text via Twilio now...

@fremenusul
Copy link
Author

I did receive a text.

@danslimmon
Copy link
Owner

And do you see that learning opportunity in your oscar_db board?

@fremenusul
Copy link
Author

Whoops. Sorry, yes

{"barcode": "01234567890", "type": "barcode", "created_dt": "2013-11-24 14:37:41", "opp_id": "testabc123"}

@danslimmon
Copy link
Owner

Very strange. So the contents of the functions that are supposed to create and publish your learning opportunity for the Safeway water seem to be working fine. But in the context of a scan.py run for some reason the API calls are failing silently.

I'm not sure what to tell you. I can't seem to reproduce your issue on my side, so the only thing I can suggest is that you dig in try to find the exact source of the breakage by modifying the application. If you're not comfortable with Python, though, maybe that's not an option...

@fremenusul
Copy link
Author

Is there supposed to be something in /var/lib/supervisor/log/oscar_scan.log and /var/lib/supervisor/log/oscar_web.log?

The dir is empty for me.

I even tried running sudo python /var/oscar/scan.py with the same results. :/

My python is pretty limited but I might try and cobble something together.

@danslimmon
Copy link
Owner

If you're running scan.py by hand from the command line, those files won't be populated. They will contain the output of scan.py and the web app if those things are running under supervisor's control. Check

superisorctl status

to see what Supervisor thinks it's running and what the states of those programs are.

@fremenusul
Copy link
Author

superisorctl status
-bash: superisorctl: command not found

(I am assuming I should run this in the terminal)

@danslimmon
Copy link
Owner

Sorry, supervisorctl -- with a 'v'.

@fremenusul
Copy link
Author

sudo apt-get install git supervisor
Reading package lists... Done
Building dependency tree
Reading state information... Done
git is already the newest version.
supervisor is already the newest version.

@fremenusul
Copy link
Author

Very interesting:

pi@keyser ~/src/oscar $ sudo supervisorctl reload
Restarted supervisord
pi@keyser ~/src/oscar $ superisorctl status
-bash: superisorctl: command not found
pi@keyser ~/src/oscar $

@danslimmon
Copy link
Owner

You're still typo-ing "supervisorctl"

@fremenusul
Copy link
Author

pi@keyser ~/src/oscar $ sudo supervisorctl status
oscar_scan RUNNING pid 10823, uptime 0:02:03
oscar_web RUNNING pid 10869, uptime 0:00:06

@danslimmon
Copy link
Owner

And the log files are still missing?

@fremenusul
Copy link
Author

Yup. the dir is still empty

@danslimmon
Copy link
Owner

That either means that supervisor is misconfigured and hasn't been told to write log files to that directory (which shouldn't be the case, but you can check /etc/supervisor/conf.d to make sure) or the scripts it's running haven't produced enough output to log yet. Supervisor (kinda annoyingly) buffers its logfile writes and only flushes those files when a certain amount of data has been written (not every N seconds or something). I'd like to find a way around that, but so far I haven't. :-/

@fremenusul
Copy link
Author

the conf's look good. Massive bummer this doesnt seem to be working. I'd be curious if you are running a clean install when you are checking.

I re-ran install.py and still having the same issue. No changes to trello, no texts, etc.

Does the supervisor run automatically?

Anyway, thanks for your help so far, I hope you had a good Sunday in spite of all my posts!

@danslimmon
Copy link
Owner

Your supervisorctl status output does indicate that supervisor is running, and that it is running the scan application automatically. With a little bit of print statement hackery you might be able to figure out exactly what the application is sending up to the server and why that's wrong.

To be fair, I haven't tested the install script on a fresh Pi. I was just sort of crossing my fingers and hoping we would eventually get all the kinks worked out.

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

2 participants