|
|
@ -30,8 +30,10 @@ def handle_exceptions(func):
|
|
|
|
if "message" in rtrn:
|
|
|
|
if "message" in rtrn:
|
|
|
|
if not rtrn["success"] and rtrn["message"] == "API ERROR":
|
|
|
|
if not rtrn["success"] and rtrn["message"] == "API ERROR":
|
|
|
|
if "error_code" in rtrn["response"]["error"]:
|
|
|
|
if "error_code" in rtrn["response"]["error"]:
|
|
|
|
log.error("API error: {code}", code=rtrn["response"]["error"]["error_code"])
|
|
|
|
code = rtrn["response"]["error"]["error_code"]
|
|
|
|
return False
|
|
|
|
if not code == 136:
|
|
|
|
|
|
|
|
log.error("API error: {code}", code=code)
|
|
|
|
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
log.error("API error: {code}", code=rtrn["response"]["error"])
|
|
|
|
log.error("API error: {code}", code=rtrn["response"]["error"])
|
|
|
|
return False
|
|
|
|
return False
|
|
|
@ -643,7 +645,7 @@ class Agora(object):
|
|
|
|
ad = self.agora.ad_create(**form)
|
|
|
|
ad = self.agora.ad_create(**form)
|
|
|
|
return ad
|
|
|
|
return ad
|
|
|
|
|
|
|
|
|
|
|
|
def create_distribution_list(self):
|
|
|
|
def create_distribution_list(self, filter_asset=None):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Create a list for distribution of ads.
|
|
|
|
Create a list for distribution of ads.
|
|
|
|
:return: generator of asset, countrycode, currency, provider
|
|
|
|
:return: generator of asset, countrycode, currency, provider
|
|
|
@ -655,16 +657,18 @@ class Agora(object):
|
|
|
|
for asset in loads(settings.Agora.AssetList):
|
|
|
|
for asset in loads(settings.Agora.AssetList):
|
|
|
|
# Iterate pairs of currency and country like EUR, GB
|
|
|
|
# Iterate pairs of currency and country like EUR, GB
|
|
|
|
for currency, countrycode in loads(settings.Agora.DistList):
|
|
|
|
for currency, countrycode in loads(settings.Agora.DistList):
|
|
|
|
yield (asset, countrycode, currency, provider)
|
|
|
|
if filter_asset:
|
|
|
|
|
|
|
|
if asset == filter_asset:
|
|
|
|
|
|
|
|
yield (asset, countrycode, currency, provider)
|
|
|
|
|
|
|
|
|
|
|
|
def dist_countries(self):
|
|
|
|
def dist_countries(self, filter_asset=None):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Distribute our advert into all countries and providers listed in the config.
|
|
|
|
Distribute our advert into all countries and providers listed in the config.
|
|
|
|
Exits on errors.
|
|
|
|
Exits on errors.
|
|
|
|
:return: False or dict with response
|
|
|
|
:return: False or dict with response
|
|
|
|
:rtype: bool or dict
|
|
|
|
:rtype: bool or dict
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
dist_list = list(self.create_distribution_list())
|
|
|
|
dist_list = list(self.create_distribution_list(filter_asset))
|
|
|
|
our_ads = self.enum_ads()
|
|
|
|
our_ads = self.enum_ads()
|
|
|
|
# Let's get rid of the ad IDs and make it a tuple like dist_list
|
|
|
|
# Let's get rid of the ad IDs and make it a tuple like dist_list
|
|
|
|
our_ads = [(x[0], x[2], x[3], x[4]) for x in our_ads]
|
|
|
|
our_ads = [(x[0], x[2], x[3], x[4]) for x in our_ads]
|
|
|
|