-
Notifications
You must be signed in to change notification settings - Fork 29
/
setup.py
116 lines (111 loc) · 4.03 KB
/
setup.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env python
import os
import sys
from subprocess import call
from subprocess import PIPE
from setuptools import setup
from setuptools.command.install import install as _install
dirs = ['w3af_web' + root.replace('/', '.')[3:]
for root, dirs, files in os.walk('src/', topdown=False)
if '.svn' not in root]
system_depends = [
'w3af_console -h',
]
py_depends = {
'simplejson':'In Debian based systems just install python-simplejson',
'lxml':'In Debian based systems just install python-lxml',
'ghettoq':'You can install it from PyPI by easy_install ghettoq',
'celery':'You can install it from PyPI by easy_install celery',
'django_extensions':'You can install it from PyPI by easy_install django-extensions',
'south':'You can install it from PyPI by easy_install south',
'djcelery':'You can install it from PyPI by easy_install django-celery',
'djkombu':'You can install it from PyPI by easy_install django-kombu',
'MySQLdb':'In Debian based systems just install python-mysqldb',
#'qsstats':
# 'You can install it from PyPI by easy_install django-qsstats-magic',
}
py_version_depends = {
'django': '1.4',
}
def check_py_dependencies():
result = True
for depend in py_depends:
print 'check require %s....' % depend
try:
__import__(depend)
print 'OK'
except ImportError, e:
print e, py_depends[depend]
result = False
return result
def check_version_dependencies():
result = True
for depend, version in py_version_depends.items():
print 'check require %s version %s....' % (depend, version)
try:
import_module = __import__(depend)
cur_version = import_module.get_version()
if (version not in cur_version):
print '%s %s was found but %s %s required' % (
depend,
cur_version,
depend,
version,
)
print 'Can not find %s %s' % (depend, version)
result = False
else:
print 'OK'
except ImportError, e:
print e
result = False
return result
def check_system_dependencies():
result = True
for depend in system_depends:
print 'check require %s....' % depend
try:
retcode = call(depend, shell=True, stdout=PIPE)
if retcode < 0:
print "%s was terminated by signal %d" % (
depend, -retcode
)
else:
print 'OK'
except OSError, e:
print "Execution failed:", e
result=False
return result
class install(_install):
def run(self):
if (not check_system_dependencies() or
not check_version_dependencies() or
not check_py_dependencies()):
print 'Can not find all requires'
#raise EnvironmentError
_install.run(self)
setup(
cmdclass={'install': install},
name = "w3af_web",
version = "1.0",
url = 'http://w3af.org',
license = 'GPLv2',
description = "Web interface for w3af.",
author = 'Svetlana Popova',
author_email = 'svetleo@yandex-team.ru',
packages = dirs,
package_dir = {'w3af_web': 'src'},
package_data = {'w3af_web.w3af_webui':
['templates/*.html',
'templates/admin/*.html',
'templates/admin/auth/*.html',
'templates/admin/w3af_webui/*.html',
'templates/admin/w3af_webui/target/*.html',
'locale/ru/LC_MESSAGES/*',
'static/w3af_webui/flot/*',
'static/w3af_webui/images/*',
'static/w3af_webui/icons/*',
'static/w3af_webui/css/*',
]
},
)