bbolli / tumblr-utils

Utilities for dealing with Tumblr blogs, Tumblr backup
GNU General Public License v3.0
667 stars 124 forks source link

AttributeError: 'URLError' object has no attribute 'code' #230

Closed khaygiel closed 3 years ago

khaygiel commented 3 years ago

I'm using commit be22b8c of tumblr-utils. I haven't really used a program like this before. The command I typed to start the program was this:

C:\Users\Username\Downloads\bbolli-tumblr-utils-be22b8c\bbolli-tumblr-utils-be22b 8c>tumblr_backup.py [tumblrusername]

It got to 1,101 posts before showing me this and then stopping:

Traceback (most recent call last): File "C:\Users[Username]\Downloads\bbolli-tumblr-utils-be22b8c\bbolli-tumblr-uti ls-be22b8c\tumblr_backup.py", line 1236, in tb.backup(account) File "C:\Users[Username]\Downloads\bbolli-tumblr-utils-be22b8c\bbolli-tumblr-uti ls-be22b8c\tumblr_backup.py", line 597, in backup soup = apiparse(base, MAX_POSTS, i) File "C:\Users[Username]\Downloads\bbolli-tumblr-utils-be22b8c\bbolli-tumblr-uti ls-be22b8c\tumblr_backup.py", line 208, in apiparse if e.code == 429: AttributeError: 'URLError' object has no attribute 'code'

Thank you!

cebtenzzre commented 3 years ago

@khaygiel Looks like the most recent commit introduced a regression. You could try the previous commit, or my fork (which provides a --resume option that would avoid downloading those 1k posts again).

https://github.com/bbolli/tumblr-utils/blob/be22b8cfa60d547868694d6c8ce80265009fb896/tumblr_backup.py#L207-L208 @bbolli urllib2.URLError is a subclass of EnvironmentError but has no code attribute. This if statement should check isinstance(e, HTTPError) before it tries to read e.code.