From 74b933e831fe2cdce7c35be557aeece592b3d043 Mon Sep 17 00:00:00 2001 From: Harm Aarts Date: Sat, 4 Jul 2015 02:07:31 +0200 Subject: [PATCH] Prevents startup/testnet spam to log. --- yield-generator.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/yield-generator.py b/yield-generator.py index 908526ce..ca7e73fd 100644 --- a/yield-generator.py +++ b/yield-generator.py @@ -30,6 +30,7 @@ #spent from utxos that try to make the highest balance even higher # so try to keep coins concentrated in one mixing depth class YieldGenerator(Maker): + statement_file = os.path.join('logs', 'yigen-statement.csv') def __init__(self, msgchan, wallet): Maker.__init__(self, msgchan, wallet) @@ -39,17 +40,22 @@ def __init__(self, msgchan, wallet): self.tx_unconfirm_timestamp = {} def log_statement(self, data): + if common.get_network() == 'testnet': + return + data = [str(d) for d in data] - self.income_statement = open(os.path.join('logs', - 'yigen-statement.csv'), 'aw') + self.income_statement = open(statement_file, 'a') self.income_statement.write(','.join(data) + '\n') self.income_statement.close() def on_welcome(self): Maker.on_welcome(self) - self.log_statement(['timestamp', 'cj amount/satoshi', 'my input count', - 'my input value/satoshi', 'cjfee/satoshi', - 'earned/satoshi', 'confirm time/min', 'notes']) + if not os.path.isfile(statement_file): + self.log_statement( + ['timestamp', 'cj amount/satoshi', 'my input count', + 'my input value/satoshi', 'cjfee/satoshi', 'earned/satoshi', + 'confirm time/min', 'notes']) + timestamp = datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S") self.log_statement([timestamp, '', '', '', '', '', '', 'Connected'])