Exemplo n.º 1
0
def testRequestHandler():
    rh = RequestHandler.Instance()

    # Light query testing.
    print('LIGHT QUERY TESTING')
    for i in range(len(lightQueries)):
        q = lightQueries[i]
        e = lightQueryExpectedLengths[i]
        c = lightQueryComments[i]
        l = len(rh.lightQuery(q)['lights'])
        print(str(l == e) + c + ' (result: ' + str(l) + ')')

    # Make all the test state queries.
    print('STATE QUERY TESTING')
    for i in range(len(stateQueries)):
        q = stateQueries[i]
        e = stateQueryExpectedMessages[i]
        c = stateQueryComments[i]
        print(str(rh.stateQuery(q)['message'] == e) + c)
Exemplo n.º 2
0
	
	Returns:
		None.
		
	Preconditions:
		None.
		
	Postconditions:
		The program is running.
	"""
    # Disable normal logging so that we don't clutter up things.
    log = logging.getLogger('werkzeug')
    log.setLevel(logging.WARNING)

    # Create the request handler.
    rh = RequestHandler.Instance()

    # Try to load the components of the request handler.
    am, lm = rh.load()

    # If either fail we have to act.
    if not (am and lm):
        printInitialSetupHeader()
        if not am:
            try:
                createAliasConfigFile()
            except KeyboardInterrupt:
                print('\n\n Keyboard interrupt. Cancelling.')
                print(
                    '-------------------------------------------------------------------------------'
                )