Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lendingbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,21 @@
# allow existing the main bot loop
raise
except Exception as ex:
log.log_error(str(ex))
log.log_error(ex.message)
log.persistStatus()
if 'Invalid API key' in str(ex):
if 'Invalid API key' in ex.message:
print "!!! Troubleshooting !!!"
print "Are your API keys correct? No quotation. Just plain keys."
exit(1)
elif 'Nonce must be greater' in str(ex):
elif 'Nonce must be greater' in ex.message:
print "!!! Troubleshooting !!!"
print "Are you reusing the API key in multiple applications? Use a unique key for every application."
exit(1)
elif 'Permission denied' in str(ex):
elif 'Permission denied' in ex.message:
print "!!! Troubleshooting !!!"
print "Are you using IP filter on the key? Maybe your IP changed?"
exit(1)
elif 'timed out' in str(ex):
elif 'timed out' in ex.message:
print "Timed out, will retry in " + str(Lending.get_sleep_time()) + "sec"
else:
print traceback.format_exc()
Expand Down
16 changes: 10 additions & 6 deletions modules/Configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def init(file_location, data=None):
raw_input("Press Enter to acknowledge and exit...")
exit(1)
except Exception as ex:
print "Failed to automatically copy config. Please do so manually. Error: " + str(ex)
ex.message = ex.message if ex.message else str(ex)
print("Failed to automatically copy config. Please do so manually. Error: {0}".format(ex.message))
exit(1)
return config

Expand Down Expand Up @@ -71,7 +72,8 @@ def get_coin_cfg():
maxtolend=Decimal(cur[3]), maxpercenttolend=(Decimal(cur[4])) / 100,
maxtolendrate=(Decimal(cur[5])) / 100)
except Exception as ex:
print "Coinconfig parsed incorrectly, please refer to the documentation. Error: " + str(ex)
ex.message = ex.message if ex.message else str(ex)
print("Coinconfig parsed incorrectly, please refer to the documentation. Error: {0}".format(ex.message))
else:
for cur in FULL_LIST:
if config.has_section(cur):
Expand All @@ -83,8 +85,9 @@ def get_coin_cfg():
coin_cfg[cur]['maxpercenttolend'] = (Decimal(config.get(cur, 'maxpercenttolend'))) / 100
coin_cfg[cur]['maxtolendrate'] = (Decimal(config.get(cur, 'maxtolendrate'))) / 100
except Exception as ex:
print "Coinconfig for " + cur + " parsed incorrectly, please refer to the documentation. " + \
"Error: " + str(ex)
ex.message = ex.message if ex.message else str(ex)
print("Coinconfig for " + cur + " parsed incorrectly, please refer to the documentation. "
"Error: {0}".format(ex.message))
# Need to raise this exception otherwise the bot will continue if you configured one cur correctly
raise
return coin_cfg
Expand All @@ -97,8 +100,9 @@ def get_min_loan_sizes():
try:
min_loan_sizes[cur] = Decimal(get(cur, 'minloansize', lower_limit=0.01))
except Exception as ex:
print "minloansize for " + cur + " parsed incorrectly, please refer to the documentation. " + \
"Error: " + str(ex)
ex.message = ex.message if ex.message else str(ex)
print("minloansize for " + cur + " parsed incorrectly, please refer to the documentation. "
"Error: {0}".format(ex.message))
# Bomb out if something isn't configured correctly
raise
return min_loan_sizes
Expand Down
7 changes: 4 additions & 3 deletions modules/Data.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ def get_max_duration(end_date, context):
return diff_days # Order needs int
if context == "status":
return " - Days Remaining: " + str(diff_days) # Status needs string
except Exception as Ex:
print "ERROR: There is something wrong with your endDate option. Error: " + str(Ex)
except Exception as ex:
ex.message = ex.message if ex.message else str(ex)
print("ERROR: There is something wrong with your endDate option. Error: {0}".format(ex.message))
exit(1)


Expand Down Expand Up @@ -138,4 +139,4 @@ def truncate(f, n):
if 'e' in s or 'E' in s:
return float('{0:.{1}f}'.format(f, n))
i, p, d = s.partition('.')
return float('.'.join([i, (d + '0' * n)[:n]]))
return float('.'.join([i, (d + '0' * n)[:n]]))
5 changes: 3 additions & 2 deletions modules/Lending.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ def cancel_all():
try:
msg = api.cancel_loan_offer(CUR, offer['id'])
log.cancelOrders(CUR, msg)
except Exception as Ex:
log.log("Error canceling loan offer: " + str(Ex))
except Exception as ex:
ex.message = ex.message if ex.message else str(ex)
log.log("Error canceling loan offer: {0}".format(ex.message))
else:
print "Not enough " + CUR + " to lend if bot canceled open orders. Not cancelling."

Expand Down
5 changes: 3 additions & 2 deletions modules/MarketAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
import numpy
use_numpy = True
except ImportError as ex:
print "WARN: Module Numpy not found, using manual percentile method instead. " \
"It is recommended to install Numpy. Error: " + str(ex)
ex.message = ex.message if ex.message else str(ex)
print("WARN: Module Numpy not found, using manual percentile method instead. "
"It is recommended to install Numpy. Error: {0}".format(ex.message))
use_numpy = False

currencies_to_analyse = []
Expand Down
7 changes: 3 additions & 4 deletions modules/Poloniex.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ def _read_response(resp):
json_ret = _read_response(ret)
return post_process(json_ret)
except Exception as ex:
# add command information to exception
# (this isn't compatible with python 3)
import sys
raise type(ex), type(ex)(ex.message + ' Requesting %s' % command), sys.exc_info()[2]
ex.message = ex.message if ex.message else str(ex)
ex.message = "{0} Requesting {1}".format(ex.message, command)
raise

def return_ticker(self):
return self.api_query("returnTicker")
Expand Down
8 changes: 5 additions & 3 deletions modules/WebServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ def translate_path(self, path):
serving_msg += ", http://{0}:{1}/lendingbot.html".format(host, port)
print 'Started WebServer, lendingbot status available at {0}'.format(serving_msg)
server.serve_forever()
except Exception as Ex:
print 'Failed to start WebServer' + str(Ex)
except Exception as ex:
ex.message = ex.message if ex.message else str(ex)
print('Failed to start WebServer: {0}'.format(ex.message))


def stop_web_server():
try:
print "Stopping WebServer"
server.shutdown()
except Exception as ex:
print 'Failed to stop WebServer' + str(ex)
ex.message = ex.message if ex.message else str(ex)
print("Failed to stop WebServer: {0}".format(ex.message))