# 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 *
        ch.setopt(pycurl.COOKIEJAR, self.parent.IGDataPath + self.parent.username + "-cookies.dat")
        ch.setopt(pycurl.POST, True)
        ch.setopt(pycurl.POSTFIELDS, data)

        if self.parent.proxy:
            ch.setopt(pycurl.PROXY, self.parent.proxyHost)
            if self.parent.proxyAuth:
                ch.setopt(pycurl.PROXYUSERPWD, self.parent.proxyAuth)

        ch.perform()
        resp = buffer.getvalue()
        header_len = ch.getinfo(pycurl.HEADER_SIZE)

        header = resp[0: header_len]
        upload = UploadPhotoResponse(json.loads(resp[header_len:]))

        ch.close()

        if not upload.isOk():
            raise InstagramException(upload.getMessage())

        if self.parent.debug:
            print('RESPONSE: ' + resp[header_len:] + "\n")

        if reel_flag:
            configure = self.parent.configureToReel(upload.getUploadId(), photo)
        else:
            configure = self.parent.configure(upload.getUploadId(), photo, caption, location, filter_)

        if not configure.isOk():

# 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 *

        ch.setopt(pycurl.COOKIEJAR, self.parent.IGDataPath + self.parent.username + "-cookies.dat")
        ch.setopt(pycurl.POST, True)
        ch.setopt(pycurl.POSTFIELDS, data)

        if self.parent.proxy:
            ch.setopt(pycurl.PROXY, self.parent.proxyHost)
            if self.parent.proxyAuth:
                ch.setopt(pycurl.PROXYUSERPWD, self.parent.proxyAuth)

        ch.perform()
        resp = buffer.getvalue()
        header_len = ch.getinfo(pycurl.HEADER_SIZE)

        header = resp[0: header_len]
        upload = UploadPhotoResponse(json.loads(resp[header_len:]))

        ch.close()

        if not upload.isOk():
            raise InstagramException(upload.getMessage())

        if self.parent.debug:
            print('RESPONSE: ' + resp[header_len:] + "\n")

        if reel_flag:
            configure = self.parent.configureToReel(upload.getUploadId(), photo)
        else:
            configure = self.parent.configure(upload.getUploadId(), photo, caption, location, filter_)

        if not configure.isOk():

            raise InstagramException(configure.getMessage())