blob: 2903f80baa3d79d5e3bc446b2c7034fe4caf6c5e [file] [log] [blame]
Holger Hans Peter Freytherd0288072012-07-28 15:30:09 +02001#!/usr/bin/env python
2
3"""
4Start the process and dump the documentation to the doc dir. This is
5copied from the BTS directory and a fix might need to be applied there
6too.
7"""
8
9import socket, subprocess, time,os
10
11
12def dump_doc(end, port, filename):
13 sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
14 sck.setblocking(1)
15 sck.connect(("localhost", port))
16 sck.recv(4096)
17
18 # Now send the command
19 sck.send("show online-help\r")
20 xml = ""
21 while True:
22 data = sck.recv(4096)
23 xml = "%s%s" % (xml, data)
24 if data.endswith(end):
25 break
26
27 # Now write everything until the end to the file
28 out = open(filename, 'w')
Holger Hans Peter Freytherdf49a982012-08-14 00:14:36 +020029 out.write(xml[18:len(end)*-1])
Holger Hans Peter Freytherd0288072012-07-28 15:30:09 +020030 out.close()
31
32
33apps = [
34 # The same could be done with an empty config file but this way
35 # the example files are properly tested.
36 (4242, "src/osmo-nitb/osmo-nitb", "doc/examples/osmo-nitb/nanobts/openbsc.cfg", "OpenBSC", "nitb"),
37 (4242, "src/osmo-bsc/osmo-bsc", "doc/examples/osmo-bsc/osmo-bsc.cfg", "OsmoBSC", "bsc"),
38 (4243, "src/osmo-bsc_mgcp/osmo-bsc_mgcp", "doc/examples/osmo-bsc_mgcp/mgcp.cfg", "OpenBSC MGCP", "mgcp"),
39 (4244, "src/osmo-bsc_nat/osmo-bsc_nat", "doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg", "OsmoBSCNAT", "nat"),
40 (4246, "src/gprs/osmo-gbproxy", "doc/examples/osmo-gbproxy/osmo-gbproxy.cfg", "OsmoGbProxy", "gbproxy"),
41]
42
43# Dump the config of all our apps
44for app in apps:
45 print "Starting app for %s" % app[4]
46
47 cmd = [app[1], "-c", app[2]]
48 proc = subprocess.Popen(cmd, stdin=None, stdout=None)
49 time.sleep(1)
50 try:
51 dump_doc('\r\n%s> ' % app[3], app[0], 'doc/%s_vty_reference.xml' % app[4])
52 finally:
53 # Clean-up
54 proc.kill()
55 proc.wait()
56