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
78c57e2d
Commit
78c57e2d
authored
6 years ago
by
Moul
Browse files
Options
Downloads
Patches
Plain Diff
[fix]
#154
: use os independent method to retrieve terminal width
- variable renamed, height not necessary, int type as output
parent
cb39403e
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
+7
-8
7 additions, 8 deletions
silkaj/commands.py
with
7 additions
and
8 deletions
silkaj/commands.py
+
7
−
8
View file @
78c57e2d
...
@@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License
...
@@ -15,7 +15,7 @@ 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/>.
"""
"""
from
click
import
command
,
option
,
argument
,
IntRange
from
click
import
command
,
option
,
argument
,
IntRange
,
get_terminal_size
from
datetime
import
datetime
from
datetime
import
datetime
from
time
import
sleep
from
time
import
sleep
from
os
import
system
,
popen
from
os
import
system
,
popen
...
@@ -150,10 +150,9 @@ def get_network_sort_key(endpoint):
...
@@ -150,10 +150,9 @@ def get_network_sort_key(endpoint):
async
def
network_info
(
discover
,
sort
):
async
def
network_info
(
discover
,
sort
):
global
network_sort_keys
global
network_sort_keys
network_sort_keys
=
sort
.
split
(
"
,
"
)
network_sort_keys
=
sort
.
split
(
"
,
"
)
rows
,
columns
=
popen
(
"
stty size
"
,
"
r
"
).
read
().
split
()
width
=
get_terminal_size
()[
0
]
wide
=
int
(
columns
)
if
width
<
146
:
if
wide
<
146
:
message_exit
(
"
Wide screen need to be larger than 146. Current width:
"
+
width
)
message_exit
(
"
Wide screen need to be larger than 146. Current wide:
"
+
wide
)
# discover peers
# discover peers
# and make sure fields are always ordered the same
# and make sure fields are always ordered the same
endpoints
=
[
endpoints
=
[
...
@@ -200,11 +199,11 @@ async def network_info(discover, sort):
...
@@ -200,11 +199,11 @@ async def network_info(discover, sort):
current_blk
=
await
sub_client
(
blockchain
.
current
)
current_blk
=
await
sub_client
(
blockchain
.
current
)
if
current_blk
is
not
None
:
if
current_blk
is
not
None
:
endpoints
[
i
][
"
gen_time
"
]
=
convert_time
(
current_blk
[
"
time
"
],
"
hour
"
)
endpoints
[
i
][
"
gen_time
"
]
=
convert_time
(
current_blk
[
"
time
"
],
"
hour
"
)
if
wid
e
>
171
:
if
wid
th
>
171
:
endpoints
[
i
][
"
mediantime
"
]
=
convert_time
(
endpoints
[
i
][
"
mediantime
"
]
=
convert_time
(
current_blk
[
"
medianTime
"
],
"
hour
"
current_blk
[
"
medianTime
"
],
"
hour
"
)
)
if
wid
e
>
185
:
if
wid
th
>
185
:
endpoints
[
i
][
"
difftime
"
]
=
convert_time
(
endpoints
[
i
][
"
difftime
"
]
=
convert_time
(
current_blk
[
"
time
"
]
-
current_blk
[
"
medianTime
"
],
"
hour
"
current_blk
[
"
time
"
]
-
current_blk
[
"
medianTime
"
],
"
hour
"
)
)
...
@@ -216,7 +215,7 @@ async def network_info(discover, sort):
...
@@ -216,7 +215,7 @@ async def network_info(discover, sort):
if
endpoints
[
i
].
get
(
"
domain
"
)
is
not
None
and
len
(
endpoints
[
i
][
"
domain
"
])
>
20
:
if
endpoints
[
i
].
get
(
"
domain
"
)
is
not
None
and
len
(
endpoints
[
i
][
"
domain
"
])
>
20
:
endpoints
[
i
][
"
domain
"
]
=
"
…
"
+
endpoints
[
i
][
"
domain
"
][
-
20
:]
endpoints
[
i
][
"
domain
"
]
=
"
…
"
+
endpoints
[
i
][
"
domain
"
][
-
20
:]
if
endpoints
[
i
].
get
(
"
ip6
"
)
is
not
None
:
if
endpoints
[
i
].
get
(
"
ip6
"
)
is
not
None
:
if
wid
e
<
156
:
if
wid
th
<
156
:
endpoints
[
i
].
pop
(
"
ip6
"
)
endpoints
[
i
].
pop
(
"
ip6
"
)
else
:
else
:
endpoints
[
i
][
"
ip6
"
]
=
endpoints
[
i
][
"
ip6
"
][:
8
]
+
"
…
"
endpoints
[
i
][
"
ip6
"
]
=
endpoints
[
i
][
"
ip6
"
][:
8
]
+
"
…
"
...
...
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