Пример #1
0
def main():
    global cachedir
    import argv
    opts, args = argv.parse(sys.argv[1:], "--cachedir=")
    for o, a in opts:
        if o=="--cachedir":
            cachedir = a
        
    from mwlib.async import slave
    
    slave.main(commands, numgreenlets=32, argv=args)
Пример #2
0
def main():
    from gevent import pywsgi as wsgi
    # from gevent import wsgi

    WSGIServer = wsgi.WSGIServer
    WSGIHandler = wsgi.WSGIHandler

    WSGIHandler.log_request = lambda *args, **kwargs: None

    import argv
    opts,  args = argv.parse(sys.argv[1:], "--qserve= --port=")
    qs = []
    port = 8899
    for o,a in opts:
        if o=="--port":
            port = int(a)
        elif o=="--qserve":
            qs.append(a)

    if not qs:
        qs.append("localhost:14311")

    _parse_qs(qs)
            
    cachedir = "cache"
    cachedir = utils.ensure_dir(cachedir)
    for i in range(0x100, 0x200):
        p = os.path.join(cachedir, hex(i)[3:])
        if not os.path.isdir(p):
            os.mkdir(p)

    def app(*args, **kwargs):
        return Application(cachedir)(*args, **kwargs)
    
    address = "0.0.0.0", port
    server = WSGIServer(address, app)

    for x in qs:
        worker.Worker.spawn(wait_idle, x, busy).set_max_rate((5, 0))
    
    try:
        print "listening on %s:%d" % address
        server.serve_forever()
    except KeyboardInterrupt:
        server.stop()
        print "bye."
Пример #3
0
def main():
    global cachedir, cacheurl
    numgreenlets = 10
    import argv
    opts, args = argv.parse(sys.argv[1:], "--cachedir= --url= --numprocs=")
    for o, a in opts:
        if o=="--cachedir":
            cachedir = a
        if o=="--url":
            cacheurl = a
        if o=="--numprocs":
            numgreenlets = int(a)

    if not cacheurl:
        sys.exit("--url option missing")
        
        
        
    from mwlib.async import slave
    slave.main(commands, numgreenlets=numgreenlets, argv=args)
from src.pathsOfMaze import findPath, canFindSolutionFromPaths
from src.genetics import fitness, evolutionAlgo
import src.savePaths as savePaths
from src.shortestPath import shortestPath
import argv

from random import random
#from time import clock
import os, pickle, sys
import os.path as path

mazeFile = 'data.bin'
folderInitialPop = 'initial'
folderFinalPop = 'final'

options = argv.parse(sys.argv)

help_message = "usage: " + ' '.join(options['_']) + " [option] " + """\n
options:
GLOBAL DEFINED:
  -F --folder=name           (mandatory) folder to save the results
     --dim=n,m               * dimensions of the maze (default: 60,70)
  -d --wallsToDel=float      * percent of the walls to delete (default: 0.10)
  -m --mutationPercent=float percent of mutation, probability of mutate in a
                             determined cycle (iteration) (default: 0.10)

  -t --totalPopulation=num   maximum size of the population (default: 50)
  -i --totalIterations=num   number of iterations (default: 200)
  -b --badIndividuals=num    number of `bad' individuals, they have the worst
                             fitness value (default: 10)
  -V --initPopInvulnrb=bool  make Initial Population Invulnerable (default: 1)
Пример #5
0
                (this must be string, or it will fail) (override `-p`)

 examples:
    testing_interpreter.py -f examples/factorial.lambda
    testing_interpreter.py -nf examples/factorial.lambda
    testing_interpreter.py -vnf examples/beer.lambda
"""

lexer = lex.lex(module=src.tokrules)
parser = yacc.yacc()

if __name__ == "__main__":
    import argv, sys
    #sys.setrecursionlimit(40)

    arguments = argv.parse(sys.argv)

    if 'f' not in arguments:
        print(help_message)
        exit(1)

    myPrint = nothing if 'n' in arguments else print

    prelude = open('prelude.code', 'r').read()
    filecode = open(arguments['f'], 'r').read()
    declarations = parser.parse(prelude +" "+ filecode)

    if not 'main' in declarations:
        print("must be an 'main' simbol/declaration in the source code")
        exit(1)