This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtest-webui.tac
65 lines (54 loc) · 2.23 KB
/
test-webui.tac
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
# -*- python -*-
from twisted.application import service, internet
from nevow import appserver
from ldaptor import config
from ldaptor.apps.webui import main, i18n
application = service.Application("ldaptor-webui")
myService = service.IServiceCollection(application)
cp = config.loadConfig(configFiles=[])
cp.add_section('webui')
cp.set('webui', 'search-field 1 Name',
'(|(cn=%(input)s)(uid=%(input)s))')
cp.add_section('ldap')
cp.set('ldap', 'base',
'dc=example,dc=com')
cfg = config.LDAPConfig(serviceLocationOverrides={
'dc=example,dc=com': ('localhost', 38942),
})
resource = main.getResource(cfg)
site = appserver.NevowSite(resource)
myServer = internet.TCPServer(38980, site)
myServer.setServiceParent(myService)
############################################################################
import sys, trace
class Coverage(service.Service):
def startService(self):
# begin monkey patch ---------------------------
def find_executable_linenos(filename):
"""Return dict where keys are line numbers in the line number table."""
#assert filename.endswith('.py') # YOU BASTARDS
try:
prog = open(filename).read()
prog = '\n'.join(prog.splitlines()) + '\n'
except IOError, err:
sys.stderr.write("Not printing coverage data for %r: %s\n" % (filename, err))
sys.stderr.flush()
return {}
code = compile(prog, filename, "exec")
strs = trace.find_strings(filename)
return trace.find_lines(code, strs)
trace.find_executable_linenos = find_executable_linenos
# end monkey patch ------------------------------
service.Service.startService(self)
self.tracer = trace.Trace(count=1, trace=0)
sys.settrace(self.tracer.globaltrace)
def stopService(self):
sys.settrace(None)
results = self.tracer.results()
results.write_results(show_missing=1,
summary=False,
coverdir='coverage')
service.Service.stopService(self)
svc = Coverage()
svc.setServiceParent(application)
############################################################################