change prints to logging

This commit is contained in:
hroff-1902 2019-05-30 09:54:58 +03:00
parent f463817c88
commit 11f535e79f

View File

@ -36,7 +36,7 @@ config: Dict[str, Any] = {}
if args.config:
# Now expecting a list of config filenames here, not a string
for path in args.config:
print(f"Using config: {path}...")
logger.info(f"Using config: {path}...")
# Merge config options, overwriting old values
config = deep_merge_dicts(configuration._load_config_file(path), config)
@ -78,7 +78,7 @@ dl_path = Path(config['datadir'])
pairs_file = Path(args.pairs_file) if args.pairs_file else dl_path.joinpath('pairs.json')
if not pairs or args.pairs_file:
print(f'Reading pairs file "{pairs_file}".')
logger.info(f'Reading pairs file "{pairs_file}".')
# Download pairs from the pairs file if no config is specified
# or if pairs file is specified explicitely
if not pairs_file.exists():
@ -94,7 +94,7 @@ if args.days:
time_since = arrow.utcnow().shift(days=-args.days).strftime("%Y%m%d")
timerange = arguments.parse_timerange(f'{time_since}-')
print(f'About to download pairs: {pairs}, intervals: {timeframes} to {dl_path}')
logger.info(f'About to download pairs: {pairs}, intervals: {timeframes} to {dl_path}')
pairs_not_available = []
@ -105,17 +105,17 @@ try:
for pair in pairs:
if pair not in exchange._api.markets:
pairs_not_available.append(pair)
print(f"skipping pair {pair}")
logger.info(f"skipping pair {pair}")
continue
for ticker_interval in timeframes:
pair_print = pair.replace('/', '_')
filename = f'{pair_print}-{ticker_interval}.json'
dl_file = dl_path.joinpath(filename)
if args.erase and dl_file.exists():
print(f'Deleting existing data for pair {pair}, interval {ticker_interval}')
logger.info(f'Deleting existing data for pair {pair}, interval {ticker_interval}')
dl_file.unlink()
print(f'downloading pair {pair}, interval {ticker_interval}')
logger.info(f'downloading pair {pair}, interval {ticker_interval}')
download_pair_history(datadir=dl_path, exchange=exchange,
pair=pair, ticker_interval=ticker_interval,
timerange=timerange)
@ -125,4 +125,4 @@ except KeyboardInterrupt:
finally:
if pairs_not_available:
print(f"Pairs [{','.join(pairs_not_available)}] not availble.")
logger.info(f"Pairs [{','.join(pairs_not_available)}] not availble.")