2020-11-24 07:26:02 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import sys, argparse, os
|
|
|
|
from os.path import join, dirname
|
|
|
|
from shutil import copyfile
|
|
|
|
from dotenv import load_dotenv
|
2020-11-24 07:41:23 +01:00
|
|
|
from lib.historylib import History
|
2020-11-24 07:26:02 +01:00
|
|
|
|
2020-11-28 06:26:32 +01:00
|
|
|
VERSION = 0.1
|
|
|
|
|
2020-11-24 07:26:02 +01:00
|
|
|
# Get variables environment
|
|
|
|
if not os.path.isfile('.env'):
|
|
|
|
copyfile(".env.template", ".env")
|
|
|
|
dotenv_path = join(dirname(__file__), '.env')
|
|
|
|
load_dotenv(dotenv_path)
|
|
|
|
|
|
|
|
dunikey = os.getenv('DUNIKEY')
|
|
|
|
node = os.getenv('NODE')
|
2020-11-28 06:26:32 +01:00
|
|
|
# referential = os.getenv('REFERENTIAL')
|
2020-11-24 07:26:02 +01:00
|
|
|
if not node:
|
|
|
|
sys.stderr.write("Please fill a Duniter node in .env file\n")
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
# Parse arguments
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument('-p', '--pubkey', help="Clé publique du compte visé")
|
2020-11-25 05:06:57 +01:00
|
|
|
parser.add_argument('-n', '--node', help="Sélection d'un noeud Duniter à utiliser")
|
|
|
|
parser.add_argument('-k', '--key', help="Chemin vers notre fichier de trousseau (PubSec)")
|
2020-11-28 06:26:32 +01:00
|
|
|
parser.add_argument('-j', '--json', action='store_true', help="Affiche le résultat en format JSON")
|
|
|
|
parser.add_argument('--nocolors', action='store_true', help="Affiche le résultat en noir et blanc")
|
|
|
|
parser.add_argument('--version', action='store_true', help="Affiche la version actuelle du programme")
|
2020-11-24 07:26:02 +01:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
2020-11-25 05:06:57 +01:00
|
|
|
if args.node: node = args.node
|
|
|
|
if args.key: dunikey = args.key
|
|
|
|
|
2020-11-24 07:26:02 +01:00
|
|
|
# Create transaction and send it
|
2020-11-28 06:26:32 +01:00
|
|
|
hist = History(dunikey, node, args.pubkey)
|
|
|
|
hist.history(args.json, args.nocolors)
|
2020-12-03 07:35:52 +01:00
|
|
|
|
|
|
|
#test git
|