#!/usr/bin/python2

# $Id: readyexecd.py,v 1.4 2002/10/08 02:49:11 ftobin Exp $

import os
import sys
import readyexec
import getopt

debug = False

def usage():
    sys.stderr.write("usage: %s [-d] socket_path callable_object\n"
                     % sys.argv[0])
    sys.exit(1)

(options, args) = getopt.getopt(sys.argv[1:], 'd')
for (o, v) in options:
    if o == '-d':
        debug = True

if len(args) != 2:
    usage()

(sock_path, call_obj)= args[0:2]

server = readyexec.ReadyExec(call_obj, sock_path, debug=debug)
try:
    server.serve_forever()
finally:
    server.server_close()
