Ejemplo n.º 1
0
def main(configurationDirectory):
    pjoin = os.path.join
    abspath = os.path.abspath
    psplit = os.path.split
    pexists = os.path.exists
    pisdir = os.path.isdir

    app_conf = load(file(os.path.join(configurationDirectory,
                                    "..\\settings\\app_config.yaml"), u'r'),
                                    Loader=Loader)

    view_server_info={}

    print
    print "Confero Track Started. "

    if app_conf.get('view_server',{}).get('address').lower() in [None, 'auto', 'bonjour']:
        view_server_info = findConferoViewServer()
        print "Found Confero Server via Bonjour:", view_server_info['ip'], view_server_info['port']
        print
        app_conf.get('view_server')['address'] = view_server_info['ip']
        app_conf.get('view_server')['port'] = view_server_info['port']
    else:
        view_server_info['ip'] = app_conf.get('view_server')['address']
        view_server_info['port'] = app_conf.get('view_server')['port']
        print "Using app_config settings for Confero Server connection:", view_server_info['ip'], view_server_info['port']
        print

    DataCollectionRuntime.view_server_ip = view_server_info['ip']

    DataCollectionRuntime.results_root_folder = \
                                    app_conf.get('results_root_folder')
    if not (pexists(DataCollectionRuntime.results_root_folder)
            and pisdir(DataCollectionRuntime.results_root_folder)):
        DataCollectionRuntime.results_root_folder = abspath(pjoin(
            DataCollectionRuntime.script_dir,
            DataCollectionRuntime.results_root_folder))
    util.createPath(DataCollectionRuntime.results_root_folder)

    try:
        ws = createWebsocketInterface(app_conf)
    except socket.error, e:
        if e.errno == 10035:
            pass
        elif e.errno in [10054,10061]:
            print('WebSocket could not be connected to feedback server. '
                  'Is the server program running?')
            return 'EXIT_PROGRAM'
        else:
            raise e
Ejemplo n.º 2
0
Created on Thu Feb 20 23:43:45 2014

@author: Sol
"""
from register_server import ConferoBonjourService
from webserver import ControlFeedbackServer
from psychopy.iohub import Loader, load
from findserver import findConferoViewServer
import os
if __name__ == "__main__":
    app_config = load(file(os.path.abspath(r'..\settings\app_config.yaml'), 'r'),
                        Loader=Loader)

    print
    print "Confero Server Starting... "
    bonsvc = None
    server_ip = app_config.get('http_address',None)
    if server_ip.lower() in [None, 'default', 'auto', 'bonjour']:
        bonsvc = ConferoBonjourService()
        view_server_info = findConferoViewServer()

        app_config['http_address'] = view_server_info['ip']
        app_config['http_port'] = view_server_info['port']

        print "Registered Confero Server with Bonjour for ip", app_config['http_address'],' : ',app_config['http_port']
        print
    else:
        print " Confero Server being started with app_config IP settings:", app_config['http_address'],' : ',app_config['http_port']
        print
    server = ControlFeedbackServer(app_config, bonsvc)
    server.serveForever()