Fix dist function

This commit is contained in:
Mark Veidemanis 2022-02-02 14:40:17 +00:00
parent 39254ef684
commit c5c3e951cf
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 13 additions and 3 deletions

View File

@ -29,8 +29,12 @@ def handle_exceptions(func):
if "success" in rtrn:
if "message" in rtrn:
if not rtrn["success"] and rtrn["message"] == "API ERROR":
if "error_code" in rtrn["response"]["error"]:
log.error("API error: {code}", code=rtrn["response"]["error"]["error_code"])
return False
else:
log.error("API error: {code}", code=rtrn["response"]["error"])
return False
return rtrn
return inner_function
@ -437,6 +441,12 @@ class Agora(object):
public_ad_dict_xmr = {}
public_ad_dict_btc = {}
rates_crypto = self.cg.get_price(ids=["monero", "bitcoin"], vs_currencies=currencies)
# NOTES:
# Get all ads for each currency, with all the payment methods.
# Create a function to, in turn, filter these so it contains only one payment method. Run autoprice on this.
# Append all results to to_update. Repeat for remaining payment methods, then call slow update.
for currency in currencies:
try:
rates_xmr = rates_crypto["monero"][currency]
@ -665,7 +675,7 @@ class Agora(object):
return (min_local, max_local)
@handle_exceptions
def create_ad(self, asset, countrycode, currency, provider, edit=True, ad_id=None):
def create_ad(self, asset, countrycode, currency, provider, edit=False, ad_id=None):
"""
Post an ad with the given asset in a country with a given currency.
Convert the min and max amounts from settings to the given currency with CurrencyRates.