forked from BishopFox/SpoofcheckSelfTest
/
selftest.py
executable file
·66 lines (52 loc) · 1.98 KB
/
selftest.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
'''
Copyright 2012 Root the Box
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
----------------------------------------------------------------------------
This file is the main starting point for the application, based on the
command line arguments it calls various components setup/start/etc.
'''
import os
import argparse
from datetime import datetime
from libs.ConsoleColors import *
__version__ = 'v0.0.1'
current_time = lambda: str(datetime.now()).split(' ')[1].split('.')[0]
def serve():
''' Starts the application '''
from handlers import start_server
print(INFO + '%s : Starting application ...' % current_time())
start_server()
def main(args):
''' Call functions in the correct order based on CLI params '''
fpath = os.path.abspath(__file__)
fdir = os.path.dirname(fpath)
if fdir != os.getcwd():
print(INFO + "Switching CWD to %s" % fdir)
os.chdir(fdir)
# Start server
if args.start_server:
serve()
# Main
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Tornado WebApp',
)
parser.add_argument('-v', '--version',
action='version',
version=__version__,
)
parser.add_argument("-s", "--start",
action='store_true',
dest='start_server',
help="start the server",
)
main(parser.parse_args())