-
Notifications
You must be signed in to change notification settings - Fork 16
/
swarm.py
executable file
·46 lines (39 loc) · 1.21 KB
/
swarm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
from lib.parse.configfile import configfile_parse
from lib.parse.cli import cli_parse
from lib.core.module import get_modules
from lib.core.logger import LOG
from lib.core.logger import init_logger
from lib.core.mswarm import MSwarm
from lib.core.exception import SwarmBaseException
from lib.utils.banner import begin_banner
from lib.utils.banner import end_banner
def main():
args=argparse.Namespace()
try:
# get all available modules
args.modules=get_modules()
# parse args from cli and configuration file
# arguments parsed from cli will cover origin arguments in configuration file
configfile_parse(args)
cli_parse(args)
begin_banner()
init_logger(args.logfile,args.verbose,args.disable_col)
except SwarmBaseException as e:
print str(e)
end_banner()
return
# now use logger instead of simple print
try:
m=MSwarm(args)
# wake slaves up now
m.waken_swarm()
m.parse_distribute_task()
except SwarmBaseException as e:
LOG.critical(str(e))
finally:
end_banner()
if __name__ == '__main__':
main()