Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FairCoin.Co
pulse.faircoin.co
Commits
cf4db285
Commit
cf4db285
authored
Jun 25, 2020
by
TonyFord
Browse files
fix wrong path
parent
fa29f61a
Pipeline
#1022
passed with stage
in 3 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
script/getdata.py
View file @
cf4db285
...
...
@@ -11,19 +11,14 @@ rpc_connect=os.environ['rpcconnect']
rpc_port
=
os
.
environ
[
'rpcport'
]
script_path
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
print
(
script_path
)
rpc_connection
=
AuthServiceProxy
(
"http://%s:%s@%s:%s"
%
(
rpc_user
,
rpc_password
,
rpc_connect
,
rpc_port
))
# check datafiles blockcount
fn
=
script_path
+
'/../data/txs.info.json'
print
(
fn
)
fn
=
script_path
+
'/../_data/faircoin/txs.info.json'
if
not
os
.
path
.
isfile
(
fn
):
print
(
'NOT EX'
)
file
=
open
(
fn
,
'w'
)
file
.
write
(
json
.
dumps
({
'blockhash'
:
'beed44fa5e96150d95d56ebd5d2625781825a9407a5215dd7eda723373a0a1d7'
,
'timestamp'
:
int
(
datetime
.
datetime
.
now
().
timestamp
()
),
'lastblocks'
:
[]
}))
file
.
close
()
print
(
'OK'
)
file
=
open
(
fn
,
'r'
)
txs_info
=
json
.
loads
(
file
.
read
()
)
...
...
@@ -39,7 +34,7 @@ block_hash=txs_info['blockhash']
last_blocks
=
txs_info
[
'lastblocks'
]
# update time
fn
=
script_path
+
'/../data/txs.info.json'
fn
=
script_path
+
'/../
_
data/
faircoin/
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
()
...
...
@@ -47,8 +42,8 @@ file.close()
commands
=
[
[
"getblock"
,
block_hash
]
]
block
=
rpc_connection
.
batch_
(
commands
)[
0
]
if
not
os
.
path
.
exists
(
script_path
+
'/../data/tx'
):
os
.
makedirs
(
script_path
+
'/../data/tx'
)
if
not
os
.
path
.
exists
(
script_path
+
'/../
_
data/
faircoin/
tx'
):
os
.
makedirs
(
script_path
+
'/../
_
data/
faircoin/
tx'
)
while
'nextblockhash'
in
block
:
block_hash
=
block
[
'nextblockhash'
]
...
...
@@ -56,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
(
script_path
+
'/../data/tx/'
+
year
):
os
.
makedirs
(
script_path
+
'/../data/tx/'
+
year
)
if
not
os
.
path
.
exists
(
script_path
+
'/../
_
data/
faircoin/
tx/'
+
year
):
os
.
makedirs
(
script_path
+
'/../
_
data/
faircoin/
tx/'
+
year
)
fn
=
script_path
+
'/../data/tx/'
+
year
+
'/'
+
datetime
.
datetime
.
fromtimestamp
(
block
[
'time'
]).
isoformat
()[
0
:
10
]
+
'.yml'
fn
=
script_path
+
'/../
_
data/
faircoin/
tx/'
+
year
+
'/'
+
datetime
.
datetime
.
fromtimestamp
(
block
[
'time'
]).
isoformat
()[
0
:
10
]
+
'.yml'
file
=
open
(
fn
,
'a'
)
file
.
write
(
'- '
+
str
(
len
(
block
[
'tx'
]
)
)
+
'
\n
'
);
file
.
close
()
...
...
@@ -68,7 +63,7 @@ while 'nextblockhash' in block:
if
len
(
txs_info
[
'lastblocks'
]
)
>
480
:
txs_info
[
'lastblocks'
].
pop
(
0
)
fn
=
script_path
+
'/../data/txs.info.json'
fn
=
script_path
+
'/../
_
data/
faircoin/
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
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment