Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

flickrapi.auth.OAuthFlickrInterface error during upload #115

Open
rodmur opened this issue Aug 7, 2018 · 2 comments
Open

flickrapi.auth.OAuthFlickrInterface error during upload #115

rodmur opened this issue Aug 7, 2018 · 2 comments

Comments

@rodmur
Copy link

rodmur commented Aug 7, 2018

I'm seeing the following issue when I try to upload, it will do several images before it craps out. Am I just handling the oauth authentication wrong? Or do I just need to add code to re-attempt the upload?

File: DSC_0267.png
No handlers could be found for logger "flickrapi.auth.OAuthFlickrInterface"
Traceback (most recent call last):
File "/Users/rodmur/bin/flickrup2.py", line 45, in
flickr.upload(filename=fname,title=tit,tags=mytags,is_public=0,callback=func)
File "/Library/Python/2.7/site-packages/flickrapi/core.py", line 494, in upload
return self._upload_to_form(self.UPLOAD_URL, filename, fileobj, timeout=timeout, **kwargs)
File "/Library/Python/2.7/site-packages/flickrapi/core.py", line 544, in _upload_to_form
filename, form_url, kwargs, fileobj, timeout=timeout)
File "/Library/Python/2.7/site-packages/flickrapi/core.py", line 399, in _wrap_in_parser
data = wrapped_method(*args, **kwargs)
File "/Library/Python/2.7/site-packages/flickrapi/auth.py", line 307, in do_upload
raise exceptions.FlickrError('do_upload: Status code %s received' % req.status_code)
flickrapi.exceptions.FlickrError: do_upload: Status code 500 received

Here's the code, I won't claim it's good, but it has worked in the past:

#!/usr/bin/python
import flickrapi
import os
import sys

api_key='XXXXXXXXXXX'
api_secret='XXXXXX'

mydir = sys.argv[1]
taglist = sys.argv[2:]

mytags = " ".join(taglist)

print "tags: %s" % mytags 

flickr = flickrapi.FlickrAPI(api_key, api_secret)
flickr.authenticate_via_browser(perms='write')

def func(progress, done):
   if done:
        print "Done uploading"
    else:
        print "At %s%%" % progress

files = sorted([f for f in os.listdir(mydir) if not f.startswith('.')])
for name in files:
  fname = os.path.join(mydir, name)
   print "File: %s" % name
   tit = name.split('.')[0]
   flickr.upload(filename=fname,title=tit,tags=mytags,is_public=0,callback=func)
@oPromessa
Copy link

oPromessa commented Aug 7, 2018

Hi @rodmur, best if you present your code indented and marked with pythonkeyword like this. Check notes here!

def func(progress, done):
    if done:
        print "Done uploading"
    else:
        print "At %s%%" % progress

Now to your question, based on this link, I understand error 500 to be a server error. So I suggest to retry the operation.

You can also wrap the upload around try/except sequence to catch additional error situations.

Check this gist and
this somehow complex (I know... still cleaning it up a bit...once I have the time) example of such code here

I found situations in which Flickr refuses to accept some files due to their format (in particular some videos) or size.

@rodmur
Copy link
Author

rodmur commented Aug 7, 2018

okay, fixed the markdown, at least. I'll look into the gist, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants