# Path: InstagramAPI/src/InstagramException.py
# class InstagramException(Exception):
#     def __init__(self, *args, **kwargs):
#         Exception.__init__(self, *args, **kwargs)


import hmac
import json
import locale
import math
import pycurl
import time
from collections import OrderedDict
    from io import BytesIO
    from StringIO import StringIO as BytesIO
from InstagramAPI.src.InstagramException import InstagramException
from InstagramAPI.src.Constants import Constants
from InstagramAPI.src.Utils import *
from InstagramAPI.src.http.Response import *
            if post:
                print(Utils.colouredString('POST:  ', 'light_blue') + endpoint)
            else:
                print(Utils.colouredString('GET:  ', 'light_blue') + endpoint)

            if post is not None:
                if not isinstance(post, list):
                    print('DATA: ' + compat_urllib_parse.unquote_plus(post))

            bytes = Utils.formatBytes(ch.getinfo(pycurl.SIZE_DOWNLOAD))
            httpCode = ch.getinfo(pycurl.HTTP_CODE)
            print(Utils.colouredString("← " + str(httpCode) + " \t " + bytes, 'green'))

            if self.parent.truncatedDebug and len(body) > 1000:
                print(Utils.colouredString('RESPONSE: ', 'cyan') + body[0:1000] + "...\n")
            else:
                print(Utils.colouredString('RESPONSE: ', 'cyan') + body + "\n")

        ch.close()
        return [header, json.loads(body)]

    def uploadPhoto(self, photo, caption=None, upload_id=None, customPreview=None, location=None, filter_=None,
                    reel_flag=False):

        endpoint = Constants.API_URL + 'upload/photo/'
        boundary = self.parent.uuid

        if upload_id is not None and customPreview is None:
            fileToUpload = Utils.createVideoIcon(photo)
        elif customPreview is not None:

# Path: InstagramAPI/src/InstagramException.py
# class InstagramException(Exception):
#     def __init__(self, *args, **kwargs):
#         Exception.__init__(self, *args, **kwargs)


# Path: InstagramAPI/src/http/HttpInterface.py
import hmac
import json
import locale
import math
import pycurl
import time
from collections import OrderedDict
    from io import BytesIO
    from StringIO import StringIO as BytesIO
from InstagramAPI.src.InstagramException import InstagramException
from InstagramAPI.src.Constants import Constants
from InstagramAPI.src.Utils import *
from InstagramAPI.src.http.Response import *

            if post:
                print(Utils.colouredString('POST:  ', 'light_blue') + endpoint)
            else:
                print(Utils.colouredString('GET:  ', 'light_blue') + endpoint)

            if post is not None:
                if not isinstance(post, list):
                    print('DATA: ' + compat_urllib_parse.unquote_plus(post))

            bytes = Utils.formatBytes(ch.getinfo(pycurl.SIZE_DOWNLOAD))
            httpCode = ch.getinfo(pycurl.HTTP_CODE)
            print(Utils.colouredString("← " + str(httpCode) + " \t " + bytes, 'green'))

            if self.parent.truncatedDebug and len(body) > 1000:
                print(Utils.colouredString('RESPONSE: ', 'cyan') + body[0:1000] + "...\n")
            else:
                print(Utils.colouredString('RESPONSE: ', 'cyan') + body + "\n")

        ch.close()
        return [header, json.loads(body)]

    def uploadPhoto(self, photo, caption=None, upload_id=None, customPreview=None, location=None, filter_=None,
                    reel_flag=False):

        endpoint = Constants.API_URL + 'upload/photo/'
        boundary = self.parent.uuid

        if upload_id is not None and customPreview is None:
            fileToUpload = Utils.createVideoIcon(photo)
        elif customPreview is not None:

            fileToUpload = file_get_contents(customPreview)