Holger Hans Peter Freyther | 2e699a5 | 2012-07-28 15:30:09 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | """ |
| 4 | Start the process and dump the documentation to the doc dir. This is |
| 5 | copied from the BTS directory and a fix might need to be applied there |
| 6 | too. |
| 7 | """ |
| 8 | |
| 9 | import socket, subprocess, time,os |
| 10 | |
| 11 | |
| 12 | def 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 Freyther | bff7c1b | 2012-08-14 00:14:36 +0200 | [diff] [blame^] | 29 | out.write(xml[18:len(end)*-1]) |
Holger Hans Peter Freyther | 2e699a5 | 2012-07-28 15:30:09 +0200 | [diff] [blame] | 30 | out.close() |
| 31 | |
| 32 | |
| 33 | apps = [ |
| 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 |
| 44 | for 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 | |