1
2 """
3 A Python childHandler bootstrapper
4
5 Starts a PyCmdExecutor instance, which is a running python interpreter whose stdin/stdout/stderr
6 are hooked up to a subprocess.POpen() object that is running in a PyCmdDispatcher somewhere.
7 """
8
9
10
11
12
13
14 import sys
15 from optparse import OptionParser
16 import os
17 import logging
18
19 apiPath = '%s/api/python' % os.environ.get('QBDIR',
20 {'linux2': '/usr/local/pfx/qube',
21 'darwin': '/Applications/pfx/qube',
22 'win32': 'C:/Program Files/pfx/qube'}[sys.platform])
23 sys.path.insert(0, apiPath)
24 import qb.backend.pythonChildHandler
25
26
28 parser = OptionParser()
29 parser.set_defaults(debug=False, kind='generic')
30
31 parser.add_option('-p', '--port',
32 type=int,
33 help='port on which a PFXSimpleServer is running')
34
35 parser.add_option('-k', '--kind',
36 help='short name of the application to be started, used for building the '
37 'python prompt')
38
39 parser.add_option('-d', '--debug',
40 action='store_true')
41
42 (opts, args) = parser.parse_args()
43
44 return opts
45
46
48
49 logging.debug('childboot_strapper - port: %s' % opts.port)
50
51 executor = qb.backend.pythonChildHandler.PyCmdExecutor(opts.port, promptType=opts.kind, debug=opts.debug)
52 exit_code = executor.mainloop()
53
54 del executor
55
56 sys.stdout.write('child_bootstrapper: child process quit, exit code = %s\n' % exit_code)
57
58 return exit_code
59
60
61 logging.basicConfig(level=logging.INFO)
62
63 opts = parse_args()
64 exit_code = main(opts)
65 sys.exit(exit_code)
66