Debian Codegraph @

src/scripts/srvarv

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #!/usr/bin/env python
2
3 import argparse
4 import os
5
6 try:
7 import http.server as httpserver
8 import socketserver
9 except:
10 import SimpleHTTPServer as httpserver
11 import SocketServer as socketserver
12
13
14 if __name__ == '__main__':
15
16 parser = argparse.ArgumentParser(
17 description='srvarv: serve an instance of the ataqv web results viewer'
18 )
19 parser.add_argument('-p', '--port', type=int, default=8000, help="""The TCP port on which to serve the viewer (default: 8000).""")
20 parser.add_argument('instance', nargs='?', default='.', help="""The directory containing the viewer instance (default: current directory).""")
21 args = parser.parse_args()
22
23 socketserver.TCPServer.allow_reuse_address = True
24
25 handler = httpserver.SimpleHTTPRequestHandler
26 httpd = socketserver.TCPServer(('', args.port), handler)
27
28 instance = os.path.abspath(args.instance)
29 os.chdir(args.instance)
30
31 print('Serving ataqv web viewer instance from {} at http://localhost:{}'.format(instance, args.port))
32 try:
33 httpd.serve_forever()
34 except KeyboardInterrupt:
35 httpd.shutdown()
36 print('Shutting down.')