def command():
    usage = "%prog [--help] [-d DIR] [-l [HOST][:PORT]] [-p GLOB[,GLOB...]]"
    parser = OptionParser(usage=usage, version="static 0.3.6")
    parser.add_option("-d", "--dir", dest="rootdir", default=".",
        help="Root directory to serve. Defaults to '.' .", metavar="DIR")
    parser.add_option("-l", "--listen", dest="listen", default="127.0.0.1:8888",
        help="Listen on this interface (given by its hostname or IP) and port."+
             " HOST defaults to 127.0.0.1. PORT defaults to 8888. "+
             "Leave HOST empty to listen on all interfaces (INSECURE!).",
             metavar="[HOST][:PORT]")
    parser.add_option("-p", "--puttable", dest="puttable", default="",
             help="Comma or space-separated list of request paths for which to"+
                  " permit PUT requests. Each path is a glob pattern that may "+
                  "contain wildcard characters '*' and/or '?'. "+
                  "'*' matches any sequence of characters, including the empty"+
                  " string. '?' matches exactly 1 arbitrary character. "+
                  "NOTE: Both '*' and '?' match slashes and dots. "+
                  "I.e. --puttable=* makes every file under DIR writable!",
                  metavar="GLOB[,GLOB...]")
    parser.add_option("--validate", dest="validate", action="store_true",
                  default=False,
                  help="Enable HTTP validation. You don't need this unless "+
                       "you're developing static.py itself.")

    options, args = parser.parse_args()
    if len(args) > 0:
        parser.print_help(sys.stderr)
        sys.exit(1)

    parts = options.listen.split(":")
    if len(parts) == 1:
        try: # if the the listen argument consists only of a port number
            port = int(parts[0])
            host = None
        except: # could not parse as port number => must be a host IP or name
            host = parts[0]
            port = None
    elif len(parts) == 2:
        host, port = parts
    else:
        sys.exit("Invalid host:port specification.")

    if not host:
        host = '0.0.0.0'
    if not port:
        port = 8888
    try:
        port = int(port)
        if port <= 0 or port > 65535: raise ValueError
    except:
        sys.exit("Invalid host:port specification.")

    puttable = set(path.abspath(p) for p in
                                     options.puttable.replace(","," ").split())
    if puttable and host not in ('127.0.0.1', 'localhost'):
        print("Permitting PUT access for non-localhost connections may be unwise.")

    options.rootdir = path.abspath(options.rootdir)

    for p in puttable:
        if not p.startswith(options.rootdir):
            sys.exit("puttable path '%s' not under root '%s'" % (p, options.rootdir))

    # cut off root prefix from puttable paths
    puttable = set(p[len(options.rootdir):] for p in puttable)

    app = Cling(options.rootdir, puttable=puttable)

    if options.validate:
        app = validator(app)

    try:
        print "Serving %s to http://%s:%d" % (options.rootdir, host, port)
        if puttable:
            print("The following paths (relative to server root) may be "+
                  "OVERWRITTEN via HTTP PUT.")
            for p in puttable:
                print p
        make_server(host, port, app).serve_forever()
    except __HOLE__, ki:
        print "Ciao, baby!"
    except:
        sys.exit("Problem initializing server: %s" % sys.exc_info()[1])
dataset/ETHPy150Open cloudera/hue/tools/ace-editor/static.py/command