From 679915d7058c68b12d6673114cf427bab4fe88f9 Mon Sep 17 00:00:00 2001 From: curly60e <55191248+curly60e@users.noreply.github.com> Date: Thu, 24 Sep 2020 21:08:56 -0300 Subject: [PATCH] Sounds per block Added beep when new block is discovered. --- PyBlock.py | 56 ++++++++++++++++++++++++++--------------------- nodeconnection.py | 27 ++++++++++++++++++----- ver.txt | 2 +- 3 files changed, 53 insertions(+), 32 deletions(-) diff --git a/PyBlock.py b/PyBlock.py index f606f8e..9be7cd1 100644 --- a/PyBlock.py +++ b/PyBlock.py @@ -29,13 +29,14 @@ from nodeconnection import * from terminal_matrix.matrix import * -version = "0.7.3" +version = "0.7.4" def sysinfo(): #Cpu and memory usage print(" \033[0;37;40m----------------------") print(" \033[3;33;40mCPU Usage: \033[1;32;40m" + str(psutil.cpu_percent()) + "%\033[0;37;40m") print(" \033[3;33;40mMemory Usage: \033[1;32;40m" "{}% \033[0;37;40m".format(int(psutil.virtual_memory().percent))) print(" \033[0;37;40m----------------------") + print("\a") def getblock(): # get access to bitcoin-cli with the command getblockchaininfo bitcoincli = " getblockchaininfo" @@ -124,35 +125,40 @@ def connected(info): # here we complete the connection to the external node menu() def artist(): # here we convert the result of the command 'getblockcount' on a random art design - custom = input("Do you want random designs? Y/n: ") - if custom in ["Y", "y"]: - while True: - try: - clear() - close() - design() - tmp() - except (KeyboardInterrupt, SystemExit): - menu() - raise - else: - while True: - try: - clear() - close() - getblockcount() - tmp() - except (KeyboardInterrupt, SystemExit): - menu() - raise + while True: + try: + clear() + close() + design() + tmp() + except (KeyboardInterrupt, SystemExit): + menu() + raise def design(): bitcoinclient = path['bitcoincli'] + " getblockcount" block = os.popen(str(bitcoinclient)).read() # 'getblockcount' convert to string b = block - print("\033[1;32;40m") - tprint(b, font="rnd-large") - print("\033[0;37;40m") + a = b + while True: + bitcoinclient = path['bitcoincli'] + " getblockcount" + block = os.popen(str(bitcoinclient)).read() # 'getblockcount' convert to string + b = block + if b > a: + print("\033[1;32;40m") + tprint(b, font="rnd-large") + print("\a\033[0;37;40m") + t.sleep(10) + break + elif b == a: + print("\033[1;32;40m") + tprint(b, font="rnd-large") + print("\033[0;37;40m") + t.sleep(10) + clear() + closed() + else: + break #--------------------------------- Hex Block Decoder Functions ------------------------------------- diff --git a/nodeconnection.py b/nodeconnection.py index 837e4a1..3fe25da 100644 --- a/nodeconnection.py +++ b/nodeconnection.py @@ -17,6 +17,8 @@ lndconnectload = {"ip_port":"", "tls":"", "macaroon":"", "ln":""} def clear(): # clear the screen os.system('cls' if os.name=='nt' else 'clear') +def closed(): + print("<<< Back Control + C.\n\n") if os.path.isfile('blndconnect.conf'): # Check if the file 'bclock.conf' is in the same folder lndconnectData= pickle.load(open("blndconnect.conf", "rb")) # Load the file 'bclock.conf' @@ -48,14 +50,27 @@ def rpc(method, params=[]): return requests.post(path['ip_port'], auth=(path['rpcuser'], path['rpcpass']), data=payload).json()['result'] def remotegetblock(): - try: + b = rpc('getblockcount') + c = str(b) + a = c + while True: b = rpc('getblockcount') c = str(b) - print("\033[1;32;40m") - tprint(c, font="rnd-large") - print("\033[0;37;40m") - except: - pass + if c > a: + print("\033[1;32;40m") + tprint(c, font="rnd-large") + print("\a\033[0;37;40m") + t.sleep(10) + break + elif c == a: + print("\033[1;32;40m") + tprint(c, font="rnd-large") + print("\033[0;37;40m") + t.sleep(10) + clear() + closed() + else: + break def remotegetblockcount(): # get access to bitcoin-cli with the command getblockcount try: diff --git a/ver.txt b/ver.txt index 76257fe..32d4961 100644 --- a/ver.txt +++ b/ver.txt @@ -1 +1 @@ -{"version":"0.7.3"} +{"version":"0.7.4"}