2020-05-08 08:37:26 -03:00
2020-05-06 16:34:55 -03:00
import os
import time as t
2020-05-08 08:37:26 -03:00
from art import *
2020-05-06 16:34:55 -03:00
2020-05-08 08:37:26 -03:00
def getblock ( ) : # get access to bitcoin-cli with the command getblockchaininfo
2020-05-07 10:59:47 -03:00
bitcoincli = " getblockchaininfo "
os . system ( path + bitcoincli )
2020-05-08 08:37:26 -03:00
def getblockcount ( ) : # get access to bitcoin-cli with the command getblockcount
2020-05-07 10:59:47 -03:00
bitcoincli = " getblockcount "
2020-05-06 17:04:20 -03:00
os . system ( path + bitcoincli )
2020-05-08 08:37:26 -03:00
def clear ( ) : # clear the screen
2020-05-06 16:34:55 -03:00
os . system ( ' cls ' if os . name == ' nt ' else ' clear ' )
2020-05-06 17:04:20 -03:00
clear ( )
2020-05-08 08:37:26 -03:00
tprint ( " BlockClock " , font = " rnd-large " )
print ( " Welcome to Python BlockClock \n \n " )
path = input ( " Insert the Path to Bitcoin-Cli: " ) # path to the bitcoin-cli
a = input ( " Do you want to see just Block height? ' Yes ' , for just Block Height. ' No ' , for full blockchain data. Y/n: " ) # select if block height or just ful\
lblockchain information
custom = input ( " Do you want random designs? Y/n: " )
2020-05-06 17:04:20 -03:00
2020-05-07 10:59:47 -03:00
2020-05-08 08:37:26 -03:00
while True : # Loop
clear ( ) # call clear function that clears the screen
bitcoinclient = path + " getblockcount "
block = os . popen ( str ( bitcoinclient ) ) . read ( ) # 'getblockcount' convert to string
b = block # copy the result in the variable 'b'
2020-05-07 10:59:47 -03:00
if a == " y " or a == " Y " :
2020-05-08 08:37:26 -03:00
if custom == " y " or custom == " Y " :
tprint ( b , font = " rnd-large " ) # use the art collection and print the result in a nice ASCII result
else :
getblockcount ( )
2020-05-07 10:59:47 -03:00
else :
getblock ( )
2020-05-08 08:37:26 -03:00
t . sleep ( 3 ) # pause the loop for 3 seconds
2020-05-07 10:59:47 -03:00