def main(argv=None):
    host = HOST
    port = PORT
    pidfile = PIDFILE
    maxchildren = MAXCHILDREN
    maxrequests = MAXREQUESTS
    minspare = MINSPARE
    maxspare = MAXSPARE
    
    if argv is None:
        argv = sys.argv
    try:
        try:
            opts, args = getopt.getopt(argv[1:], "h", ["host=", "port=", 'pidfile=', 'maxchildren=', 
                                                      'maxrequests=', 'minspare=', 'maxspare=', 'help'])
        except getopt.error, msg:
            raise Usage(msg)
        # option processing
        for option, value in opts:
            if option in ("-h", "--help"):
                raise Usage(HELP_MESSAGE)
            elif "--host" == option:
                host = value
            elif "--port" == option:
                port = int(value)
            elif "--pidfile" == option:
                pidfile = value
            elif "--maxchildren" == option:
                maxchildren = int(value)
            elif "--maxrequests" == option:
                maxrequests = int(value)
            elif "--minspare" == option:
                minspare = int(value)
            elif "--maxspare" == option:
                maxspare = int(value)
    except Usage, err:
        print >> sys.stderr, sys.argv[0].split("/")[-1] + ": " + str(err.msg)
        print >> sys.stderr, "\t for help use --help"
        return -2
    
    try:
        f = open(pidfile, 'w')
        f.write(str(os.getpid()) + '\n')
        f.close()
    except __HOLE__, e:
        print "!! Error writing to pid file, check pid file path: %s" % pidfile
        return -1
    
    try:
        WSGIServer(gserve, bindAddress=(host, port), minSpare=minspare, maxSpare=maxspare, maxChildren=maxchildren, maxRequests=maxrequests).run()
    except Exception, e:
        print "!! WSGIServer raised exception" 
        print e
dataset/ETHPy150Open b1tr0t/Google-Analytics-for-Mobile--python-/ga_mobile_server.py/main