4pr0n/gonewilder

NameError: global name 'user' is not defined

Opened this issue · 2 comments

I had this error before but I never got around to testing on a clean installation. Running on debian/unstable basic setup I get user is not defined on my first run. In the existing installation it seems to come up whenever a new user makes it to the front page.

Full installation transcript:


me@host:~$ git clone https://github.com/4pr0n/gonewilder.git GW
Cloning into 'GW'...
remote: Reusing existing pack: 622, done.
remote: Total 622 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (622/622), 215.60 KiB | 0 bytes/s, done.
Resolving deltas: 100% (424/424), done.
Checking connectivity... done.
me@host:~$ cd GW/
me@host:~/GW$ cd py/
me@host:~/GW/py$ python ./Gonewild.py --reddit XXXXX  XXXXX
[2014-06-21T02:09:15Z] DB: __init__: database file (../database.db) not found, creating...
[2014-06-21T02:09:17Z] Gonewild: Added/updated reddit login credentials for user "XXXX"
me@host:~/GW/py$ python Gonewild.py --config save_thumbnails false
[2014-06-21T02:09:39Z] DB: __init__: using database file: ../database.db
[2014-06-21T02:09:39Z] Gonewild: Saved configuration: save_thumbnails = "false"
me@host:~/GW/py$ python Gonewild.py --no-friend-zone
[2014-06-21T02:10:13Z] DB: __init__: using database file: ../database.db
[2014-06-21T02:10:13Z] Gonewild: Friend-zone disabled; Will ONLY scrape user pages (not /r/friends)
me@host:~/GW/py$ python Gonewild.py --config
[2014-06-21T02:15:43Z] DB: __init__: using database file: ../database.db
[2014-06-21T02:15:43Z] Gonewild: Dumping configuration values...
[2014-06-21T02:15:43Z] Gonewild: add_top_users = "true"
[2014-06-21T02:15:43Z] Gonewild: excluded_subreddits = ""
[2014-06-21T02:15:43Z] Gonewild: friend_zone = "none"
[2014-06-21T02:15:43Z] Gonewild: last_user = ""
[2014-06-21T02:15:43Z] Gonewild: save_thumbnails = "false"
me@host:~/GW/py$ python Gonewild.py
[2014-06-21T02:16:34Z] DB: __init__: using database file: ../database.db
[2014-06-21T02:16:35Z] Reddit: logged in
[2014-06-21T02:16:35Z] Gonewild: add_top_users: loading top posts for the week from gonewild
[2014-06-21T02:16:35Z] Reddit: loading http://www.reddit.com/r/gonewild/top.json?t=week
[2014-06-21T02:16:39Z] Gonewild: add_top_users: Found new user, adding /u/Kelesyonique
Traceback (most recent call last):
  File "Gonewild.py", line 706, in <module>
    gw.infinite_loop()
  File "Gonewild.py", line 323, in infinite_loop
    self.add_top_users() # Add users from /top
  File "Gonewild.py", line 365, in add_top_users
    self.add_friend(user)
NameError: global name 'user' is not defined


Restarting the process and it begins where it left off and downloads everything for the user that gave the initial error. After this first user is finished and the script goes to parse top entries for the week it bombs out again. :


python Gonewild.py                                                                           
[2014-06-21T02:21:06Z] DB: __init__: using database file: ../database.db
[2014-06-21T02:21:07Z] Reddit: logged in
[2014-06-21T02:21:10Z] Gonewild: User /u/Kelesyonique saved as friend on reddit & DB
[2014-06-21T02:21:10Z] Gonewild: Kelesyonique: poll_user: since ""
[2014-06-21T02:21:10Z] Reddit: loading http://www.reddit.com/user/Kelesyonique.json
[2014-06-21T02:21:12Z] Reddit: loading http://www.reddit.com/user/Kelesyonique.json?after=

SNIP

[2014-06-21T02:22:56Z] Gonewild: Kelesyonique: poll_user: done
[2014-06-21T02:22:56Z] Gonewild: Kelesyonique: poll_user: setting most-recent since_id to "cibd9ir"
[2014-06-21T02:22:56Z] Gonewild: add_top_users: loading top posts for the week from gonewild
[2014-06-21T02:22:56Z] Reddit: loading http://www.reddit.com/r/gonewild/top.json?t=week
[2014-06-21T02:23:01Z] Gonewild: add_top_users: Found new user, adding /u/natural_red
Traceback (most recent call last):
  File "Gonewild.py", line 706, in <module>
    gw.infinite_loop()
  File "Gonewild.py", line 323, in infinite_loop
    self.add_top_users() # Add users from /top
  File "Gonewild.py", line 365, in add_top_users
    self.add_friend(user)
NameError: global name 'user' is not defined


At this point I have to restart the script over and over until it has added all the users found in top-week. The script will plug along just fine until a new user is encountered on the top page.

I tried again with the same setup except I do not do the --no-friend-zone. I skipped pasting the steps but it was clone, add credentials, and no thumbs.

When I start a new installation this way I get a different error:


$ python Gonewild.py --config
[2014-06-21T02:43:55Z] DB: __init__: using database file: ../database.db
[2014-06-21T02:43:55Z] Gonewild: Dumping configuration values...
[2014-06-21T02:43:55Z] Gonewild: add_top_users = "true"
[2014-06-21T02:43:55Z] Gonewild: excluded_subreddits = ""
[2014-06-21T02:43:55Z] Gonewild: friend_zone = "some"
[2014-06-21T02:43:55Z] Gonewild: last_user = ""
[2014-06-21T02:43:55Z] Gonewild: save_thumbnails = "false"
me@host:~/GW/py$ python Gonewild.py
[2014-06-21T02:44:17Z] DB: __init__: using database file: ../database.db
[2014-06-21T02:44:18Z] Reddit: logged in
[2014-06-21T02:44:18Z] Gonewild: add_top_users: loading top posts for the week from gonewild
[2014-06-21T02:44:18Z] Reddit: loading http://www.reddit.com/r/gonewild/top.json?t=week
[2014-06-21T02:44:19Z] Gonewild: add_top_users: Found new user, adding /u/Kelesyonique
[2014-06-21T02:44:19Z] Gonewild: add_top_users: Found new user, adding /u/natural_red

SNIP

[2014-06-21T02:44:24Z] Gonewild: add_top_users: Found new user, adding /u/Controlz_magic
Traceback (most recent call last):
  File "Gonewild.py", line 706, in <module>
    gw.infinite_loop()
  File "Gonewild.py", line 325, in infinite_loop
    user = users[last_index]
IndexError: list index out of range

Thanks for the report. I think I fixed the bugs with a6b9b57