tommeagher / heroku_ebooks

An archive of a script to generate Markov chains and to post to an _ebooks account on Twitter using Heroku. No longer actively supported.
264 stars 163 forks source link

API undefined #38

Closed Jessssuhh closed 6 years ago

Jessssuhh commented 6 years ago

Hi! I'm quite new to this, so I apologise if this is a very obvious and fixable thing to people with python experience, but: I keep getting an error that api is not defined. I can see in ebooks.py that it is defined. As I understand it, it should handle so long as I have pip and python-twitter installed (which I do). Am I missing something?

Full error Traceback (most recent call last): File "ebooks.py", line 143, in status = api.PostUpdate(ebook_tweet) NameError: name 'api' is not defined

Some other relevant information may be that I intend to run this completely static

Jessssuhh commented 6 years ago

I tried recopying in local settings and ebooks to see if I had one of these "hidden symbols" you mentioned in a few places. Also the script does work in debug.

tommeagher commented 6 years ago

@Jessssuhh You're running this with STATIC_TEST set to True in your local_settings.py?

Are you running this on your local machine or on Heroku?

I haven't had a chance to test this yet, but I think I know what's happening. There should be an api = connect() added under the STATIC_TEST if statement around line 78.

I'll try to test and push a fix in the next few days. Thanks for flagging this!

Jessssuhh commented 6 years ago

Now we're cooking with gas! Yes, I added that to the top line of the if statement from line 75. It now throws the below error, but still tweets, so that doesn't bother me so much. Most likely due to my entire corpus being in unicode (you can have a look at why - @phaseA_Ingelic on twitter). Although calling it corpora is a bit of a laugh since its only a few hundred words long.

Traceback (most recent call last): File "ebooks.py", line 145, in print(status.text.encode(utf-8)) AttributeError: 'list' object has no attribute 'text'

Speaking of line 145, the if statement around there has api.PostUpdate. Should be api.PostUpdates according to the python-twitter wiki. Dunno if they're interchangable in this case, but I changed it anyway while trying (and largely failing) to figure this out myself

Jessssuhh commented 6 years ago

Oh and for your questions - yes: static_test is true & yes: Heroku

tommeagher commented 6 years ago

Closed by #41 which will be merged into master soon.