From f6a67abd4ffb3d3b69ed2292254c8d94a492d7e0 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Wed, 2 Feb 2022 14:40:17 +0000 Subject: [PATCH] Fix dist function --- handler/agora.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/handler/agora.py b/handler/agora.py index fb2e9f0..e6a1346 100644 --- a/handler/agora.py +++ b/handler/agora.py @@ -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": - log.error("API error: {code}", code=rtrn["response"]["error"]["error_code"]) - return False + 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.