Skip to content

Commit 7cf76ab

Browse files
author
Sajjad
committed
Merge branch 'active-nodes-tool'
commond line tool using activeNodes.py module
2 parents 5f54da3 + b8a8938 commit 7cf76ab

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

activenodes/activeNodesTool.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@
99

1010
from activeNodes import ActiveNodes
1111

12-
start = sys.argv[1]
13-
end = sys.argv[2]
14-
15-
if 'log' in sys.argv:
16-
log = True
12+
log = True if 'log' in sys.argv else False
1713

14+
ipre = r'\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b'
1815
for arg in sys.argv:
1916
if re.search(r'threads:([0-9])\d+', arg):
20-
threads = arg.split(':')[1]
17+
threads = int(arg.split(':')[1])
18+
19+
if re.search(ipre + r':' + ipre, arg):
20+
start, end = arg.split(':')
2121

22-
ant = ActiveNodes(start, end, threads=512, log=log).active()
22+
try:
23+
ant = ActiveNodes(start, end, threads=threads, log=log)
24+
print('\nActive Node : {0}\n'.format(ant.active()))
25+
except expression as identifier:
26+
raise identifier from None

0 commit comments

Comments
 (0)