forked from ossec/ossec-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pavement.py
112 lines (91 loc) · 2.58 KB
/
pavement.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
from paver.easy import *
import paver.doctools
import os
import sys
sys.path.append("./")
options(
incoming=Bunch(
jrossi="http://bitbucket.org/jrossi/ossec-rules",
ddpbsd="http://bitbucket.org/ddpbsd/ossec-rules",
oscar="http://bitbucket.org/oscarschneider/ossec-rules",
xeno="http://bitbucket.org/XenoPhage/ossec-rules",
),
tests=Bunch(
tdir="./tests/",
),
sphinx=Bunch(
builddir="_build",
sourcedir=".",
destdir = path("docs") / "docs"
),
ossec=Bunch(
base="/var/ossec",
version="2.7.1",
)
)
@task
def auto():
"""Auto load the ossec config if installed and readable"""
p = path("/etc/ossec-init.conf")
try:
data = p.open().read()
except IOError:
return
@task
def incoming():
"""Check for incoming changes from known bitbucket forks"""
for i in options.incoming.keys():
results = sh("hg incoming %s"%(options.incoming[i]),ignore_error=True,capture=True)
if "no changes found" in results:
info("%s -> no changes found"%(i))
else:
error("%s -> changes found: \n %s"%(i,
"\n".join(["\t%s"%(x) for x in results.split("\n")])))
@task
@cmdopts([("xunit", 'x', 'Create XUnit output files')])
def tests():
"""Run all tests on all rules that have them"""
if options.xunit:
sh("nosetests --with-xunit or_utils.runtests")
else:
sh("nosetests or_utils.runtests")
@task
def fetch():
"""Pull updates from public repo"""
sh("hg pull")
sh("hg update")
@task
def rules2rst():
"""Convert all rules in to rst pages to act as documations"""
from or_utils import rules2rst
pass
@task
@needs('paver.doctools.html')
def docs():
pass
@task
@needs('clean_docs', 'rules2rst', 'paver.doctools.html')
def html():
"""Generate Publishable HTML docs using sphinx"""
try:
if not os.path.exists("./docs/docs"):
print "mkdir"
os.mkdir(path("docs") / "docs")
except:
print "WTF"
builtdocs = path("docs") / options.sphinx.builddir / "html"
builtdocs.move(options.sphinx.destdir)
@task
def clean_docs():
"""Clean up and remove all gerenated files"""
if os.path.exists(path("docs") / "docs"):
options.sphinx.destdir.rmtree()
@task
def clean_tests():
"""Clean up and remove all temp files created during tests runs"""
path("nosetests.xml").unlink()
@task
@needs('clean_docs', 'clean_tests')
def clean():
"""Clean up and remove all build and other non required files"""
pass