Skip to content

Commit 17a629e

Browse files
author
iamsajjad
committed
add timeToDone and change result display style using click.echo() method
1 parent a5e61c5 commit 17a629e

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

cli/cLI.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
executable python file of quickping as command-line tools
55
"""
66

7+
import time
78
import click
89
from quickping import Quickping
910

@@ -13,24 +14,33 @@
1314
@click.option('-t', '--threads', default=512, type=int, help='number of threads')
1415
@click.option('-l', '--log', default=False, type=bool, help='display logging')
1516
def cLI(start, end, threads, log):
16-
17+
18+
"""
19+
run python cLI.py --help
20+
"""
21+
22+
stimer = time.time()
1723
try:
1824
testRange = Quickping(start=start, end=end, ignore=[], threads=threads, log=log)
1925
testRange.active()
2026
except expression as identifier:
2127
raise identifier from None
28+
etimer = time.time()
2229

23-
print('\nActive Addresses\n')
30+
click.echo("\nActive Addresses\n")
2431
for aa in testRange.activeAddresses:
25-
print(aa)
26-
27-
informations = """\nStart at : {}\nEnd at : {}\nTotal Addresses : {}\nActive Addresses : {}\nNumber of Threads : {}""".format(
28-
testRange.start,
29-
testRange.end,
30-
len(testRange.addresses),
31-
len(testRange.activeAddresses),
32-
testRange.threads)
33-
click.echo(informations)
32+
click.echo(aa)
33+
34+
# time take to process
35+
timeToDone = time.strftime("%H:%M:%S", time.gmtime(etimer - stimer))
36+
click.echo("")
37+
click.echo("Start @ : {}".format(testRange.start))
38+
click.echo("End @ : {}".format(testRange.end))
39+
click.echo("Total Addresses : {}".format(len(testRange.addresses)))
40+
click.echo("Active Addresses : {}".format(len(testRange.activeAddresses)))
41+
click.echo("Number of Threads : {}".format(testRange.threads))
42+
click.echo("Time take to Done : {}".format(timeToDone))
43+
click.echo("")
3444

3545
if __name__ == "__main__":
3646
cLI()

0 commit comments

Comments
 (0)