Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions python/fotolia_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
THUMB_SIZE_MEDIUM = 160
THUMB_SIZE_LARGE = 400

import os, sys, inspect
# realpath() will make your script run, even if you symlink it :)
cmd_folder = os.path.realpath(os.path.abspath(os.path.split(inspect.getfile( inspect.currentframe() ))[0]))
if cmd_folder not in sys.path:
sys.path.insert(0, cmd_folder)


import rest as _rest
import error as _error

Expand Down
10 changes: 5 additions & 5 deletions python/fotolia_api/rest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import pycurl
import json
import StringIO
import urllib
import time
import os

from io import BytesIO

import fotolia_api

class Rest:
Expand Down Expand Up @@ -605,13 +606,12 @@ def _api(self, method, args = {}, auto_refresh_token = True):
uri = self._get_full_uri(method, query)
curl = self._get_curl(uri, post_data, auto_refresh_token)

buf = StringIO.StringIO()
buf = BytesIO()
curl.setopt(pycurl.WRITEFUNCTION, buf.write)

curl.perform()
http_code = curl.getinfo(pycurl.HTTP_CODE)

res = json.loads(buf.getvalue())
res = json.loads(buf.getvalue().decode('utf-8'))

if 'error' in res or http_code != 200:
error_code = 0
Expand Down Expand Up @@ -786,7 +786,7 @@ def recursion(d, base=None):
else:
new_pair = None
if base:
new_pair = "%s%%5B%s%%5D=%s" % (base, urllib.quote(str(key)), urllib.quote(str(value)))
new_pair = "%s%%5B%s%%5D=%s" % (base, urllib.parse.quote(str(key)), urllib.parse.quote(str(value)))
pairs.append(new_pair)
else:
if type(value).__name__ == 'list':
Expand Down