diff options
Diffstat (limited to 'python/intex/load_intex_collateral.py')
| -rw-r--r-- | python/intex/load_intex_collateral.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/python/intex/load_intex_collateral.py b/python/intex/load_intex_collateral.py index 1b0a7c45..2e42ead0 100644 --- a/python/intex/load_intex_collateral.py +++ b/python/intex/load_intex_collateral.py @@ -8,6 +8,8 @@ import uuid from load_indicative import upload_cusip_data, upload_deal_data import logging +logger = logging.getLogger(__name__) + fields = ['Asset Name', 'Issuer', 'Contributed Balance', 'Asset Maturity Date', 'Asset Subtype', 'Asset Type', 'Gross Coupon', 'Spread', \ 'Frequency', 'Next Paydate', 'Second Lien', 'LoanX ID', 'CUSIP', @@ -36,7 +38,7 @@ def upload_data(conn, dealnames, workdate): missingfields = set(fields).union({'Gross Margin'}) - set(dr.fieldnames) if "LoanX ID" in missingfields: msg = "{0}: LoanX ID column is missing. Probably an error in exporting from intex" - logging.warning(msg.format(dealname)) + logger.warning(msg.format(dealname)) data = {} for line in dr: for f in missingfields: @@ -49,7 +51,7 @@ def upload_data(conn, dealnames, workdate): for key, l in [('LoanX ID', 8), ('CUSIP', 9), ('Asset Subtype', 10)]: if line[key]: if len(line[key]) > l: - logging.warning("dubious {0} found: {1}".format(key, line[key])) + logger.warning("dubious {0} found: {1}".format(key, line[key])) line[key] = line[key][:l] if 'Reinvest Collat' in line and line['Reinvest Collat'].upper() == 'Y': @@ -98,7 +100,7 @@ def upload_data(conn, dealnames, workdate): currlen = c.fetchone()[0] conn.commit() if currlen != len(data): #then we delete and just reupload - logging.warning("{0} has {1} rows in the database " \ + logger.warning("{0} has {1} rows in the database " \ "and current collateral file has {2}".format(dealname, currlen, len(data))) with conn.cursor() as c: sqlstr = "DELETE FROM et_collateral where dealname = %s and updatedate = %s" @@ -119,7 +121,7 @@ def upload_data(conn, dealnames, workdate): try: c.executemany(sqlstr, [(dealname, updatedate, k) + tuple(v) for k, v in data.items()]) except (psycopg2.DataError, psycopg2.IntegrityError, TypeError) as detail: - logging.error(detail) + logger.error(detail) pdb.set_trace() conn.commit() |
