From 087d5debe62820c9997e6a6da5ff4f50d963617b Mon Sep 17 00:00:00 2001 From: poka Date: Wed, 30 Jun 2021 04:34:15 +0200 Subject: [PATCH] Fix null balance --- .env.template | 14 +++++++++----- lib/gvaBalance.py | 5 ++++- lib/gvaHistory.py | 8 ++++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.env.template b/.env.template index b664c12..462b319 100755 --- a/.env.template +++ b/.env.template @@ -1,6 +1,10 @@ -DUNIKEY="" # Chemin de la clé privé Ḡ1 de l'émetteur, au format PubSec -#POD="https://g1.data.duniter.fr" # Adresse du pod Cesium ou Gchange à utiliser -POD="https://g1.data.le-sou.org" # Adresse du pod Cesium de secours -#POD="https://data.gchange.fr" # Adresse du pod ḠChange à utiliser +# Chemin de la clé privé Ḡ1 de l'émetteur, au format PubSec +DUNIKEY= -NODE="https://g1.librelois.fr/gva" # Noeud Duniter +# Noeud Duniter +NODE=https://g1.librelois.fr/gva + +# Adresse du pod Cesium ou Gchange à utiliser +POD=https://g1.data.le-sou.org +#POD=https://g1.data.duniter.fr +#POD=https://data.gchange.fr diff --git a/lib/gvaBalance.py b/lib/gvaBalance.py index f610049..1a20ea2 100755 --- a/lib/gvaBalance.py +++ b/lib/gvaBalance.py @@ -44,7 +44,10 @@ class Balance: message = ast.literal_eval(str(e))["message"] sys.stderr.write("Echec de récupération du solde:\n" + message + "\n") sys.exit(1) + + if (balanceResult['balance'] == None): balanceValue = 'null' + else: + balanceValue = balanceResult['balance']['amount']/100 - balanceValue = balanceResult['balance']['amount']/100 # print(balanceValue) return balanceValue diff --git a/lib/gvaHistory.py b/lib/gvaHistory.py index be61e48..39563a7 100755 --- a/lib/gvaHistory.py +++ b/lib/gvaHistory.py @@ -178,8 +178,12 @@ class History: def printHistory(self, trans, noColors): # Get balance - balance = self.historyDoc['balance']['amount']/100 - balanceUD = round(balance/self.UD, 2) + if (self.historyDoc['balance'] == None): + balance = balanceUD = 'null' + else: + + balance = self.historyDoc['balance']['amount']/100 + balanceUD = round(balance/self.UD, 2) # Get currency currency = self.historyDoc['node']['peer']['currency']