예제 #1
0
class Sandbox:
    def __init__(self):
        window = OpenGLWindow(600, 300, "Sandbox")
        self.game_manager = Application(60, window)

    def start(self):
        self.game_manager.run()
예제 #2
0
def train(mode):

    global trainingCurrentStep
    trainingCurrentStep = 0

    if mode == settings.NEAT_IP_KEY:
        trainMode('../config_files/config_neat_ip',
                  settings.NEAT_IP_EVOLVING_STEPS, eval_genomes_neat_ip)
    elif mode == settings.NEAT_DYCICLE_KEY:
        trainMode('../config_files/config_neat_dycicle',
                  settings.NEAT_DYCICLE_EVOLVING_STEPS,
                  eval_genomes_neat_dycicle)
    elif mode == settings.NEAT_DIP_KEY:
        node_names = {
            -1: 'a1',
            -2: 'a*1',
            -3: 'a2',
            -4: 'a*2',
            -5: 'a0',
            -6: 'a*0',
            0: 'u'
        }
        trainMode('../config_files/config_neat_dip',
                  settings.NEAT_DIP_EVOLVING_STEPS, eval_genomes_neat_dip,
                  node_names)
    elif mode == settings.NEAT_TIP_KEY:
        trainMode('../config_files/config_neat_tip',
                  settings.NEAT_TIP_EVOLVING_STEPS, eval_genomes_neat_tip)
    elif mode == settings.NEAT_WALKER_KEY:
        trainMode('../config_files/config_neat_walker',
                  settings.NEAT_WALKER_EVOLVING_STEPS,
                  eval_genomes_neat_walker)
    app = Application()
    app.play()
예제 #3
0
def main():

    parser = argparse.ArgumentParser(description='Run the program')
    parser.add_argument("--trainMode", help="Mode of training")

    args = parser.parse_args()

    settings.TRAIN_CALLBACK = train

    if args.trainMode:
        train(args.trainMode)
    else:
        app = Application()
        app.play()
예제 #4
0
 def __init__(self):
     Application.__init__(self)
     self.redir_port = Settings["main_app"]["redir_port"]
     self.redir_app = tornado.web.Application([(r"/(.*)", RedirHandler)])
     self.main_app = tornado.web.Application(
         get_url_specs(),
         # Server settings
         static_path=os.path.join(os.path.dirname(__file__), "static"),
         template_path=os.path.join(os.path.dirname(__file__), "templates"),
         gzip=True,
         login_url="/login",
         cookie_secret=Settings["cookie_secret"],
         ui_modules=ui_modules,
         autoescape=None,
     )
예제 #5
0
 def __init__(self):
     Application.__init__(self)
     self.redir_port = Settings['main_app']['redir_port']
     self.redir_app = tornado.web.Application([
         (r'/(.*)', RedirHandler),
     ], )
     self.main_app = tornado.web.Application(
         get_url_specs(),
         # Server settings
         static_path=os.path.join(os.path.dirname(__file__), "static"),
         template_path=os.path.join(os.path.dirname(__file__), "templates"),
         gzip=True,
         login_url="/login",
         cookie_secret=Settings['cookie_secret'],
         ui_modules=ui_modules,
         autoescape=None,
     )
예제 #6
0
from http.server import HTTPServer

from adapters.http_handler import ServerRequestHandler
from core.adapters import InMemoryPlaylistRepository, InMemoryPlaylistVideoRepository, InMemoryVideoRepository
from core.application import Application

if __name__ == '__main__':

    server = HTTPServer(('0.0.0.0', 8000), ServerRequestHandler)
    server.app = Application(InMemoryPlaylistRepository({}),
                             InMemoryPlaylistVideoRepository({}),
                             InMemoryVideoRepository({}))
    server.serve_forever()
예제 #7
0
def eval_genomes_neat_ip(genomes, config):
    idx, genomes = zip(*genomes)
    app = Application()
    global trainingCurrentStep
    trainingCurrentStep += 1
    app.trainNeatIP(genomes, config, trainingCurrentStep)
예제 #8
0
import sys

#sys.path.append('Q:/_sandbox_python/_platform/websockets-7.0/src')
#sys.path.append('Q:/_sandbox_python/_platform/paho-mqtt-1.4.0/src')
sys.path.append(
    '.')  # Permet les includes depuis le repertoire courant, pas terrible

from core.application import Application
from modules.property.PropertyModule import PropertyModule
from modules.admin.AdminModule import AdminModule
from modules.loto.LotoModule import LotoModule
#from modules.homie.HomieModule       import HomieModule

if __name__ == "__main__":
    application = Application('data/application.db')
    application.addModule(AdminModule())
    application.addModule(PropertyModule())
    application.addModule(LotoModule())
    application.run('localhost', 6789)
예제 #9
0
from core.application import Application

if __name__ == "__main__":
    app = Application("client", {
        "device": {
            "class": "core.devices.tun.TUNDevice"
        },
        "link": {
            "class": "core.links.tcp.TCPLink",
            "port": 20121,
            "host": "184.82.229.13",
        },
        "addons": [
            {
                "class": "core.addons.nameserver_override.NameserversEditor",
                "nameservers": [
                    "8.8.4.4",
                    "208.67.222.222",
                ]
            }
        ],
        "set_default_gateway":  True
        })
    app.run()
예제 #10
0
파일: main.py 프로젝트: hiraq/typhoon
        # based on unknown environment name
        settings = build.settings(yaml)

        # merge with session settings, session should be registered
        # at tornado global settings, so it can be parsed by session mixin
        # component.
        settings.update(session = session.settings())

        logger.debug('Settings: %s', settings)
        logger.info('Running IOLoop...')
        logger.info('Listening port: {}'.format(options.port))
        logger.info('Listening to address: {}'.format(options.addr))

        # Initialize Typhoon engine
        # register root_path and motor as object property
        typhoon = Typhoon(apps.get_routes(), **settings)
        setattr(typhoon, 'root_path', root_path)
        setattr(typhoon, 'motor', mongo.settings())

        typhoon.listen(options.port, options.addr)
        IOLoop.current().start()

    except DotenvNotAvailableError, exc:
        """
        Should be happened when core builder cannot load default dotenv file
        """
        print exc.message
        sys.exit()

    except UnknownEnvError, exc:
        """
예제 #11
0
 def __init__(self):
     window = OpenGLWindow(600, 300, "Sandbox")
     self.game_manager = Application(60, window)
예제 #12
0
파일: main.py 프로젝트: labs127/typhoon
        # based on unknown environment name
        settings = build.settings(yaml)

        # merge with session settings, session should be registered
        # at tornado global settings, so it can be parsed by session mixin
        # component.
        settings.update(session=session.settings())

        logger.debug('Settings: %s', settings)
        logger.info('Running IOLoop...')
        logger.info('Listening port: {}'.format(options.port))
        logger.info('Listening to address: {}'.format(options.addr))

        # Initialize Typhoon engine
        # register root_path and motor as object property
        typhoon = Typhoon(apps.get_routes(), **settings)
        setattr(typhoon, 'root_path', root_path)
        setattr(typhoon, 'motor', mongo.settings())

        typhoon.listen(options.port, options.addr)
        IOLoop.current().start()

    except DotenvNotAvailableError, exc:
        """
        Should be happened when core builder cannot load default dotenv file
        """
        print exc.message
        sys.exit()

    except UnknownEnvError, exc:
        """
예제 #13
0
from adapters.sql_video import SqlVideoRepository
from core.application import Application


class ForkingHTTPServer(ForkingMixIn, HTTPServer):
    pass


if __name__ == '__main__':
    import mysql.connector
    config = {
        'user': '******',
        'password': '******',
        'host': 'db',
        'port': '3306',
        'database': 'playlist'
    }

    def connect():
        return mysql.connector.connect(**config)

    print('Starting...')
    connection = LazyConnection(connect)
    server = ForkingHTTPServer(('0.0.0.0', 8000), ServerRequestHandler)
    playlist_repository = SqlPlaylistRepository(connection)
    playlist_video_repository = SqlPlaylistVideoRepository(connection)
    video_repository = SqlVideoRepository(connection)
    server.app = Application(playlist_repository, playlist_video_repository,
                             video_repository)
    server.serve_forever()
def app_instance(custom_args):
    """Single application instance to be reused by all fixtures."""
    runtime_args = defaultargs.copy()
    runtime_args.update(custom_args)
    return Application(**runtime_args)
예제 #15
0
파일: server.py 프로젝트: sahwar/attachix
import core.instrument

if config.get('debug') == True:
    logger.setLevel(logging.DEBUG)
    signal.signal(signal.SIGUSR1, core.instrument.dumpOnSignal)
else:
    logger.setLevel(config.get('logLevel', logging.INFO))

if config.has_key('profile') and config['profile'].get('enabled') == True:
    core.instrument.enableProfiler(signal.SIGPROF, config['profile'])

if config.has_key('pool'):
    gevent.pool.Pool(config['pool'])

# [ Prepare the application ]
Application.setup(config)


# [ Define the dispatcher ]
def Dispatcher(env, start_response):
    request = Request(env, start_response)
    Application.run(request)

    return request.getResponseBody()


# [Create Servers] #
servers = []
serverLog = 'default'
if not config.get('logRequests', True):
    serverLog = None
예제 #16
0
파일: server.py 프로젝트: sahwar/attachix
def Dispatcher(env, start_response):
    request = Request(env, start_response)
    Application.run(request)

    return request.getResponseBody()
예제 #17
0
import sys
from pyvirtualdisplay import Display

from core.application import Application
from core.reporter import Reporter

if __name__ == '__main__' and len(sys.argv) > 1:
    settings = {}

    if sys.argv[1] == 'ufbm':
        from tasks.ufbm import collect_settings
        from tasks.ufbm import unban_facebook_blocked_members

        collect_settings(settings)

        if not int(settings['application.visible']):
            display = Display(backend='xvfb')
            display.start()

        app = Application(settings)
        reporter = Reporter('ufbm', settings)
        reporter.attach(app)

        unban_facebook_blocked_members(app)
        exit(app.start())

exit(-1)
예제 #18
0
파일: server.py 프로젝트: slaff/attachix
import core.instrument

if config.get('debug')==True:
    logger.setLevel(logging.DEBUG)
    signal.signal(signal.SIGUSR1, core.instrument.dumpOnSignal)
else:
    logger.setLevel(config.get('logLevel', logging.INFO))

if config.has_key('profile') and config['profile'].get('enabled')==True:
    core.instrument.enableProfiler(signal.SIGPROF, config['profile'])

if config.has_key('pool'):
    gevent.pool.Pool(config['pool'])

# [ Prepare the application ]
Application.setup(config)

# [ Define the dispatcher ]
def Dispatcher(env, start_response):
    request = Request(env, start_response)
    Application.run(request)

    return request.getResponseBody()

# [Create Servers] #
servers = []
serverLog = 'default'
if not config.get('logRequests', True):
    serverLog = None
for ip, ports in Application.vhosts.items():
    for port, vhosts in ports.items():
예제 #19
0
파일: server.py 프로젝트: slaff/attachix
def Dispatcher(env, start_response):
    request = Request(env, start_response)
    Application.run(request)

    return request.getResponseBody()
예제 #20
0

def signal_handler(signum, frame):
    if app:
        app.exit(-1)


signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)

if __name__ == '__main__' and len(sys.argv) > 1:
    if sys.argv[1] == 'ufbm':
        from tasks.ufbm import collect_settings
        from tasks.ufbm import unban_facebook_blocked_members

        collect_settings(settings)

        #if not int(settings['application.visible']):
        #    from pyvirtualdisplay import Display
        #    display = Display(backend='xvfb')
        #    display.start()

        app = Application('ufbm', settings)
        reporter = Reporter('ufbm', settings)
        reporter.attach(app)

        unban_facebook_blocked_members(app)
        exit(app.start())

exit(-1)
예제 #21
0
import asyncio
from logging import basicConfig, DEBUG, INFO # pylint:disable=unused-import
import os
from signal import SIGINT, SIGTERM

from core.application import Application

basicConfig(level=DEBUG)

loop = asyncio.get_event_loop()
try:
    base_dir = os.path.dirname(os.path.abspath(__file__))
    app = Application(loop, base_dir)
    try:
        loop.add_signal_handler(SIGINT, app.shutdown)
        loop.add_signal_handler(SIGTERM, app.shutdown)

        loop.run_until_complete(app.startup())
    finally:
        loop.run_until_complete(app.close())

    # wait all tasks
    loop.run_until_complete(asyncio.gather(*asyncio.Task.all_tasks()))
finally:
    loop.close()