From 694980121ff52366c6921cf0fab27bba00e9d28a Mon Sep 17 00:00:00 2001 From: Matteo Parrucci Date: Wed, 11 Oct 2017 09:10:24 +0200 Subject: [PATCH] fixed sell url calculation --- src/investhor/scripts/invest_secondary.py | 1 - src/investhor/scripts/sell.py | 4 ---- src/investhor/utils.py | 15 +++++++++------ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/investhor/scripts/invest_secondary.py b/src/investhor/scripts/invest_secondary.py index 3e5abd0..2a953e1 100755 --- a/src/investhor/scripts/invest_secondary.py +++ b/src/investhor/scripts/invest_secondary.py @@ -78,4 +78,3 @@ def main(): if __name__ == "__main__": # execute only if run as a script main() - diff --git a/src/investhor/scripts/sell.py b/src/investhor/scripts/sell.py index 752ea8d..ecbeee1 100755 --- a/src/investhor/scripts/sell.py +++ b/src/investhor/scripts/sell.py @@ -45,10 +45,6 @@ def sell_items(secondary_api, results, on_sale, discount): for chunk in chunks: cancel_req = SecondMarketCancelRequest(to_cancel) results = secondary_api.second_market_cancel_multiple(cancel_req) - for res in results.payload: - msg = "Cancelling %s" % (get_investment_url(res)) - logger.info(msg) - messages.append(msg) time.sleep(3) if to_sell: diff --git a/src/investhor/utils.py b/src/investhor/utils.py index 72be7f0..e64d265 100644 --- a/src/investhor/utils.py +++ b/src/investhor/utils.py @@ -1,8 +1,6 @@ from datetime import datetime from datetime import timedelta from email.message import EmailMessage -from email.mime.text import MIMEText -from email.utils import make_msgid import json import logging import math @@ -11,7 +9,6 @@ import sys from bondora_api import configuration as bondora_configuration -from oauthlib.oauth2 import BackendApplicationClient from requests_oauthlib import OAuth2Session OAUTH_CONFIG_FILE = "oauth2.json" @@ -30,9 +27,15 @@ def get_logger(): def get_investment_url(res): - base_url = "https://www.bondora.com/en/investments?search=search&InvestmentSearch.InvestmentNumberOnly=" - investment_number = "%d-%d" % (res.auction_number, res.auction_bid_number) - return base_url + investment_number + host = "https://www.bondora.com" + path = "/en/investments" + args = "?search=search&InvestmentSearch.InvestmentNumberOnly=%s" + investment_number = getattr(res, "loan_part_id", None) + if not investment_number: + investment_number = "%d-%d" % (res.auction_number, + res.auction_bid_number) + return host + path + args % investment_number + def send_mail(subject, text): params = load_config_file(EMAIL_CONFIG_FILE)