Commit f99e1781 authored by TonyFord's avatar TonyFord
Browse files

change path

parent 3318a1e7
Pipeline #1015 passed with stage
in 4 seconds
......@@ -9,11 +9,12 @@ rpc_user=os.environ['rpcuser']
rpc_password=os.environ['rpcpassword']
rpc_connect=os.environ['rpcconnect']
rpc_port=os.environ['rpcport']
script_path=os.path.dirname(os.path.abspath(__file__))
rpc_connection = AuthServiceProxy("http://%s:%s@%s:%s"%(rpc_user, rpc_password, rpc_connect, rpc_port ))
# check datafiles blockcount
fn='../data/txs.info.json'
fn=script_path+'/../data/txs.info.json'
if not os.path.isfile(fn):
file = open(fn,'w')
file.write(json.dumps({ 'blockhash' : 'beed44fa5e96150d95d56ebd5d2625781825a9407a5215dd7eda723373a0a1d7', 'timestamp' : int( datetime.datetime.now().timestamp() ), 'lastblocks' : [] }))
......@@ -33,7 +34,7 @@ block_hash=txs_info['blockhash']
last_blocks=txs_info['lastblocks']
# update time
fn='../data/txs.info.json'
fn=script_path+'/../data/txs.info.json'
file = open(fn,'w')
file.write(json.dumps({ 'blockhash' : block_hash, 'timestamp' : int( datetime.datetime.now().timestamp() ), 'lastblocks' : txs_info['lastblocks'] }))
file.close()
......@@ -41,8 +42,8 @@ file.close()
commands = [ [ "getblock", block_hash ] ]
block = rpc_connection.batch_(commands)[0]
if not os.path.exists('../data/tx'):
os.makedirs('../data/tx')
if not os.path.exists(script_path+'/../data/tx'):
os.makedirs(script_path+'/../data/tx')
while 'nextblockhash' in block:
block_hash=block['nextblockhash']
......@@ -50,10 +51,10 @@ while 'nextblockhash' in block:
block = rpc_connection.batch_(commands)[0]
year = datetime.datetime.fromtimestamp(block['time']).isoformat()[0:4]
if not os.path.exists('../data/tx/' + year ):
os.makedirs('../data/tx/' + year )
if not os.path.exists(script_path+'/../data/tx/' + year ):
os.makedirs(script_path+'/../data/tx/' + year )
fn='../data/tx/' + year + '/' + datetime.datetime.fromtimestamp(block['time']).isoformat()[0:10]+'.yml'
fn=script_path+'/../data/tx/' + year + '/' + datetime.datetime.fromtimestamp(block['time']).isoformat()[0:10]+'.yml'
file = open(fn,'a')
file.write( '- ' + str( len( block['tx'] ) ) + '\n' );
file.close()
......@@ -62,7 +63,7 @@ while 'nextblockhash' in block:
if len( txs_info['lastblocks'] ) > 480:
txs_info['lastblocks'].pop(0)
fn='../data/txs.info.json'
fn=script_path+'/../data/txs.info.json'
file = open(fn,'w')
file.write(json.dumps({ 'blockhash' : block_hash, 'timestamp' : int( datetime.datetime.now().timestamp() ), 'lastblocks' : txs_info['lastblocks'] }))
file.close()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment