Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
silkaj
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
silkaj
Commits
0057ce00
Commit
0057ce00
authored
3 years ago
by
matograine
Browse files
Options
Downloads
Patches
Plain Diff
[mod]
#344
use pendulum in silkaj.commands
parent
99664f3b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
silkaj/commands.py
+16
-13
16 additions, 13 deletions
silkaj/commands.py
with
16 additions
and
13 deletions
silkaj/commands.py
+
16
−
13
View file @
0057ce00
...
@@ -15,15 +15,16 @@ You should have received a copy of the GNU Affero General Public License
...
@@ -15,15 +15,16 @@ You should have received a copy of the GNU Affero General Public License
along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
"""
"""
import
aiohttp
import
pendulum
import
jsonschema
from
click
import
command
,
option
,
argument
,
IntRange
from
click
import
command
,
option
,
argument
,
IntRange
from
os
import
system
from
os
import
system
from
collections
import
OrderedDict
from
collections
import
OrderedDict
from
tabulate
import
tabulate
from
tabulate
import
tabulate
from
operator
import
itemgetter
from
operator
import
itemgetter
from
asyncio
import
sleep
from
asyncio
import
sleep
import
aiohttp
from
_socket
import
gaierror
from
_socket
import
gaierror
import
jsonschema
from
duniterpy.api
import
bma
from
duniterpy.api
import
bma
...
@@ -36,8 +37,7 @@ from silkaj.network_tools import (
...
@@ -36,8 +37,7 @@ from silkaj.network_tools import (
)
)
from
silkaj.blockchain_tools
import
HeadBlock
from
silkaj.blockchain_tools
import
HeadBlock
from
silkaj.tools
import
CurrencySymbol
from
silkaj.tools
import
CurrencySymbol
from
silkaj.tui
import
convert_time
from
silkaj.constants
import
ASYNC_SLEEP
,
ALL
,
DATE
,
HOUR
from
silkaj.constants
import
ASYNC_SLEEP
@command
(
"
info
"
,
help
=
"
Display information about currency
"
)
@command
(
"
info
"
,
help
=
"
Display information about currency
"
)
...
@@ -45,6 +45,7 @@ from silkaj.constants import ASYNC_SLEEP
...
@@ -45,6 +45,7 @@ from silkaj.constants import ASYNC_SLEEP
async
def
currency_info
():
async
def
currency_info
():
head_block
=
await
HeadBlock
().
head_block
head_block
=
await
HeadBlock
().
head_block
ep
=
EndPoint
().
ep
ep
=
EndPoint
().
ep
difference_time
=
head_block
[
"
time
"
]
-
head_block
[
"
medianTime
"
]
print
(
print
(
"
Connected to node:
"
,
"
Connected to node:
"
,
ep
[
best_endpoint_address
(
ep
,
False
)],
ep
[
best_endpoint_address
(
ep
,
False
)],
...
@@ -58,11 +59,11 @@ async def currency_info():
...
@@ -58,11 +59,11 @@ async def currency_info():
"
\n
Minimal Proof-of-Work:
"
,
"
\n
Minimal Proof-of-Work:
"
,
head_block
[
"
powMin
"
],
head_block
[
"
powMin
"
],
"
\n
Current time:
"
,
"
\n
Current time:
"
,
convert_time
(
head_block
[
"
time
"
]
,
"
all
"
),
pendulum
.
from_timestamp
(
head_block
[
"
time
"
]
).
format
(
ALL
),
"
\n
Median time:
"
,
"
\n
Median time:
"
,
convert_time
(
head_block
[
"
medianTime
"
]
,
"
all
"
),
pendulum
.
from_timestamp
(
head_block
[
"
medianTime
"
]
).
format
(
ALL
),
"
\n
Difference time:
"
,
"
\n
Difference time:
"
,
convert_time
(
head_block
[
"
time
"
]
-
head_block
[
"
medianTime
"
],
"
hour
"
),
pendulum
.
from_timestamp
(
difference_time
).
format
(
HOUR
),
)
)
client
=
ClientInstance
().
client
client
=
ClientInstance
().
client
await
client
.
close
()
await
client
.
close
()
...
@@ -129,7 +130,7 @@ def display_diffi(current, diffi):
...
@@ -129,7 +130,7 @@ def display_diffi(current, diffi):
Generation of next block n°{2} possible by at least {3}/{4} members
\n\
Generation of next block n°{2} possible by at least {3}/{4} members
\n\
Common Proof-of-Work difficulty level: {5}, hash starting with `{6}`
\n
{7}
"
.
format
(
Common Proof-of-Work difficulty level: {5}, hash starting with `{6}`
\n
{7}
"
.
format
(
current
[
"
number
"
],
current
[
"
number
"
],
convert_time
(
current
[
"
time
"
]
,
"
all
"
),
pendulum
.
from_timestamp
(
current
[
"
time
"
]
).
format
(
ALL
),
diffi
[
"
block
"
],
diffi
[
"
block
"
],
issuers
,
issuers
,
len
(
diffi
[
"
levels
"
]),
len
(
diffi
[
"
levels
"
]),
...
@@ -165,8 +166,9 @@ async def list_blocks(number, detailed):
...
@@ -165,8 +166,9 @@ async def list_blocks(number, detailed):
issuer
[
"
pubkey
"
]
=
block
[
"
issuer
"
]
issuer
[
"
pubkey
"
]
=
block
[
"
issuer
"
]
if
detailed
or
number
<=
30
:
if
detailed
or
number
<=
30
:
issuer
[
"
block
"
]
=
block
[
"
number
"
]
issuer
[
"
block
"
]
=
block
[
"
number
"
]
issuer
[
"
gentime
"
]
=
convert_time
(
block
[
"
time
"
],
"
all
"
)
issuer
[
"
gentime
"
]
=
pendulum
.
from_timestamp
(
block
[
"
time
"
]).
format
(
ALL
)
issuer
[
"
mediantime
"
]
=
convert_time
(
block
[
"
medianTime
"
],
"
all
"
)
mediantime
=
block
[
"
medianTime
"
]
issuer
[
"
mediantime
"
]
=
pendulum
.
from_timestamp
(
mediantime
).
format
(
ALL
)
issuer
[
"
hash
"
]
=
block
[
"
hash
"
][:
10
]
issuer
[
"
hash
"
]
=
block
[
"
hash
"
][:
10
]
issuer
[
"
powMin
"
]
=
block
[
"
powMin
"
]
issuer
[
"
powMin
"
]
=
block
[
"
powMin
"
]
issuers_dict
[
issuer
[
"
pubkey
"
]]
=
issuer
issuers_dict
[
issuer
[
"
pubkey
"
]]
=
issuer
...
@@ -242,6 +244,7 @@ async def argos_info():
...
@@ -242,6 +244,7 @@ async def argos_info():
href
=
"
href=https://%s/
"
%
(
endpoint_address
)
href
=
"
href=https://%s/
"
%
(
endpoint_address
)
else
:
else
:
href
=
"
href=http://%s:%s/
"
%
(
endpoint_address
,
ep
[
"
port
"
])
href
=
"
href=http://%s:%s/
"
%
(
endpoint_address
,
ep
[
"
port
"
])
difference_time
=
head_block
[
"
time
"
]
-
head_block
[
"
medianTime
"
]
print
(
print
(
"
Connected to node:
"
,
"
Connected to node:
"
,
ep
[
best_endpoint_address
(
ep
,
False
)],
ep
[
best_endpoint_address
(
ep
,
False
)],
...
@@ -257,11 +260,11 @@ async def argos_info():
...
@@ -257,11 +260,11 @@ async def argos_info():
"
\n
Minimal Proof-of-Work:
"
,
"
\n
Minimal Proof-of-Work:
"
,
head_block
[
"
powMin
"
],
head_block
[
"
powMin
"
],
"
\n
Current time:
"
,
"
\n
Current time:
"
,
convert_time
(
head_block
[
"
time
"
]
,
"
all
"
),
pendulum
.
from_timestamp
(
head_block
[
"
time
"
]
).
format
(
ALL
),
"
\n
Median time:
"
,
"
\n
Median time:
"
,
convert_time
(
head_block
[
"
medianTime
"
]
,
"
all
"
),
pendulum
.
from_timestamp
(
head_block
[
"
medianTime
"
]
).
format
(
ALL
),
"
\n
Difference time:
"
,
"
\n
Difference time:
"
,
convert_time
(
head_block
[
"
time
"
]
-
head_block
[
"
medianTime
"
],
"
hour
"
),
pendulum
.
from_timestamp
(
difference_time
).
format
(
HOUR
),
)
)
client
=
ClientInstance
().
client
client
=
ClientInstance
().
client
await
client
.
close
()
await
client
.
close
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment