kurozael / twitter-contest-bot

Will poll for Retweet Contests and retweet them. Inspired by http://www.hscott.net/twitter-contest-winning-as-a-service/
236 stars 107 forks source link

KeyError: 'resources' #12

Closed bruvv closed 6 years ago

bruvv commented 8 years ago

I am running Pyhton 3.4 and getting the following error:

2015-12-12 13:01:19,924 - INFO - [2015-12-12 13:01:19.924021] - added last task at 2015-12-13 10:53:50.751188
Traceback (most recent call last):
  File "/home/ubuntu/workspace/main.py", line 435, in <module>
    CheckRateLimit()
  File "/home/ubuntu/workspace/main.py", line 182, in CheckRateLimit
    for res_family in r['resources']:
KeyError: 'resources'

It adds task and then at the last task it fails.

bruvv commented 8 years ago

When running it with python 2.7 I get the same:

2015-12-12 13:06:20,478 - INFO - [2015-12-12 13:06:20.478143] - added last task at 2015-12-13 11:03:11.263036
Traceback (most recent call last):
  File "/home/ubuntu/workspace/main.py", line 435, in <module>
    CheckRateLimit()
  File "/home/ubuntu/workspace/main.py", line 182, in CheckRateLimit
    for res_family in r['resources']:
KeyError: 'resources'
Asundawn commented 8 years ago

got the same error

AuxProc commented 8 years ago

kurozael hasnt worked on this in a while. You can try mine in the meantime if you would like: https://github.com/ModusVivendi/twitter-contest

Asundawn commented 8 years ago

thanks, well i already have your's one and a another one here to try after this. And as your project is forked from this one, main.py file from here has TabError: inconsistent use of tabs and spaces in indentation in python3 as Python3 disallows mixing the use of tabs and spaces for indentation but not in python2. Does your source code also has this inconsistency in indentation as your requirement is to run it in Python3.

AuxProc commented 8 years ago

If run in Python 3.+ you should not have that issue.

Asundawn commented 8 years ago

got the same error in your code also

Asundawn commented 8 years ago

its working now. i have a question for how much time should i run it continuously.

Asundawn commented 8 years ago

And i think you should also add "#Giveaway" and "entered to win" in search queries also. And could i do this manually in main.py

ghost commented 8 years ago

@Asundawn how did you fix the CheckRatelimit & resources error?

ghost commented 8 years ago

nvm i fixed it

jprissi commented 8 years ago

This error happens when r['resources'] returns null. You should add a basic test if 'resources' in r: and indent the block. It's how i fixed it. The part of the code : r = api.request('application/rate_limit_status').json() if 'resources' in r: for res_family in r['resources']: for res in r['resources'][res_family]:

pbartett commented 8 years ago

sorry do you have the code with the correct indents?

jprissi commented 8 years ago

I added a pull request with all the correct indents.

pbartett commented 8 years ago

Thanks

I'm now seeing these errors. I have checked my tokens and they are fine

`Loading ignore list === SCANNING FOR NEW CONTESTS === Getting new results for: RT to win 752063002623537152 in ignore list 752296560168284160 in ignore list Could not connect to TwitterAPI - are your credentials correct? Traceback (most recent call last): File "main.py", line 244, in ScanForContests() File "main.py", line 236, in ScanForContests print("Exception: " + e) TypeError: cannot concatenate 'str' and 'exceptions.UnboundLocalError' objects Exception in thread Thread-2 (most likely raised during interpreter shutdown):Exception in thread Thread-1 (most likely raised during interpreter shutdown): Traceback (most recent call last):

Traceback (most recent call last): File "/usr/local/lib/python2.7/threading.py", line 810, in __bootstrap_inner File "/usr/local/lib/python2.7/threading.py", line 810, in __bootstrap_inner File "/usr/local/lib/python2.7/threading.py", line 1082, in run File "main.py", line 57, in CheckRateLimit File "/usr/local/lib/python2.7/threading.py", line 1082, in run <type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'Timer'

File "main.py", line 157, in ScanForContests <type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'Timer'`

jprissi commented 8 years ago

I see two main errors :

-A problem with the twitter API. I got it too and fixed it by hardcoding the different value from config.json file into the script -A problem at line 236 : replace print("Exception:"+e) with : print("Exception:") print(e) This should solve the concatenation issue.

I believe that the error

'NoneType' object has no attribute 'Timer'

is a consequence of the previous errors

pbartett commented 8 years ago

Thanks

that fixed everything but still getting the TwitterAPI errors

=== SCANNING FOR NEW CONTESTS ===
Getting new results for: RT to win
752063002623537152 in ignore list
752296560168284160 in ignore list
Could not connect to TwitterAPI - are your credentials correct?
Exception:
local variable 'original_screen_name' referenced before assignment
Getting new results for: Retweet and win
Could not connect to TwitterAPI - are your credentials correct?
Exception:
local variable 'original_screen_name' referenced before assignment
=== CHECKING RETWEET QUEUE ===
Queue length: 0
natterstefan commented 7 years ago

@pbartett I get the same error. Were you able to solve it?