Exemplo n.º 1
0
def start():
    LOG_DEBUG('start')
    if OfflineMode.onStartup():
        LOG_DEBUG('OfflineMode')
        return
    elif LightingGenerationMode.onStartup():
        LOG_DEBUG('LightingGenerationMode')
        return
    else:
        ServiceLocator.connectionMgr.onConnected += onConnected
        ServiceLocator.connectionMgr.onDisconnected += onDisconnected
        if len(sys.argv) > 2:
            if sys.argv[1] == 'scriptedTest':
                try:
                    scriptName = sys.argv[2]
                    if scriptName[-3:] == '.py':
                        scriptName = scriptName[:-3]
                    try:
                        __import__(scriptName)
                    except ImportError:
                        try:
                            __import__('tests.' + scriptName)
                        except ImportError:
                            __import__('Cat.' + scriptName)

                    ServiceLocator.gameplay.start()
                except Exception:
                    LOG_CURRENT_EXCEPTION()
                    BigWorld.wg_writeToStdOut(
                        'Failed to run scripted test, Python exception was thrown, see python.log'
                    )
                    BigWorld.quit()

            elif sys.argv[1] == 'offlineTest':
                try:
                    from Cat.Tasks.TestArena2 import TestArena2Object
                    LOG_DEBUG(sys.argv)
                    LOG_DEBUG('starting offline test: %s', sys.argv[2])
                    if len(sys.argv) > 3:
                        TestArena2Object.startOffline(sys.argv[2], sys.argv[3])
                    else:
                        TestArena2Object.startOffline(sys.argv[2])
                except Exception:
                    LOG_DEBUG('Game start FAILED with:')
                    LOG_CURRENT_EXCEPTION()

            elif sys.argv[1] == 'spinTest':
                try:
                    from Cat.Tasks.TestArena2 import TestArena2Object
                    LOG_DEBUG(sys.argv)
                    targetDirectory = sys.argv[4] if len(
                        sys.argv) > 4 else 'SpinTestResult'
                    LOG_DEBUG('starting offline test: %s %s %s', sys.argv[2],
                              sys.argv[3], targetDirectory)
                    TestArena2Object.startOffline(
                        sys.argv[2],
                        mapName=sys.argv[3],
                        targetDirectory=targetDirectory)
                except Exception:
                    LOG_DEBUG('Game start FAILED with:')
                    LOG_CURRENT_EXCEPTION()

            elif sys.argv[1] == 'hangarOverride':
                try:
                    LOG_DEBUG(sys.argv)
                    from Tests.auto.HangarOverride import HangarOverride
                    HangarOverride.setHangar('spaces/' + sys.argv[2])
                    if len(sys.argv) > 3 and sys.argv[3] is not None:
                        LOG_DEBUG(
                            'Setting default client inactivity timeout: %s' %
                            sys.argv[3])
                        constants.CLIENT_INACTIVITY_TIMEOUT = int(sys.argv[3])
                except Exception:
                    LOG_DEBUG('Game start FAILED with:')
                    LOG_CURRENT_EXCEPTION()

                ServiceLocator.gameplay.start()
            elif sys.argv[1] == 'replayTimeout':
                try:
                    g_replayCtrl.replayTimeout = float(sys.argv[2])
                except Exception:
                    LOG_DEBUG('Game start FAILED with:')
                    LOG_CURRENT_EXCEPTION()

                ServiceLocator.gameplay.start()
            elif sys.argv[1] == 'botExecute':
                ServiceLocator.gameplay.start()
                botLoginName = sys.argv[3]
                scenarioPath = sys.argv[2]
                LOG_DEBUG(
                    'BOTNET: Start playing scenario {} with bot {}...'.format(
                        scenarioPath, botLoginName))
                initBotNet().initializeBots(loginName=botLoginName,
                                            scenarioPath=scenarioPath)
            else:
                ServiceLocator.gameplay.start()
        else:
            ServiceLocator.gameplay.start()
        try:
            import Vibroeffects
            Vibroeffects.VibroManager.g_instance.start()
        except Exception:
            LOG_CURRENT_EXCEPTION()

        try:
            from LightFx import LightManager
            if LightManager.g_instance is not None:
                LightManager.g_instance.start()
            from AuxiliaryFx import g_instance
            if g_instance is not None:
                g_instance.start()
        except Exception:
            LOG_CURRENT_EXCEPTION()

        WebBrowser.initExternalCache()
        return
Exemplo n.º 2
0
def start():
    LOG_DEBUG('start')
    if OfflineMode.onStartup():
        LOG_DEBUG('OfflineMode')
        return
    else:
        connectionManager.onConnected += onConnected
        connectionManager.onDisconnected += onDisconnected
        if len(sys.argv) > 2:
            if sys.argv[1] == 'scriptedTest':
                try:
                    scriptName = sys.argv[2]
                    if scriptName[-3:] == '.py':
                        scriptName = scriptName[:-3]
                    try:
                        __import__(scriptName)
                    except ImportError:
                        try:
                            __import__('tests.' + scriptName)
                        except ImportError:
                            __import__('cat.' + scriptName)

                except:
                    LOG_CURRENT_EXCEPTION()
                    BigWorld.wg_writeToStdOut(
                        'Failed to run scripted test, Python exception was thrown, see python.log'
                    )
                    BigWorld.quit()

            elif sys.argv[1] == 'offlineTest':
                try:
                    from cat.tasks.TestArena2 import TestArena2Object
                    LOG_DEBUG(sys.argv)
                    LOG_DEBUG('starting offline test: %s', sys.argv[2])
                    if len(sys.argv) > 3:
                        TestArena2Object.startOffline(sys.argv[2], sys.argv[3])
                    else:
                        TestArena2Object.startOffline(sys.argv[2])
                except:
                    LOG_DEBUG('Game start FAILED with:')
                    LOG_CURRENT_EXCEPTION()

            elif sys.argv[1] == 'spinTest':
                try:
                    from cat.tasks.TestArena2 import TestArena2Object
                    LOG_DEBUG(sys.argv)
                    targetDirectory = sys.argv[4] if len(
                        sys.argv) > 4 else 'SpinTestResult'
                    LOG_DEBUG('starting offline test: %s %s %s', sys.argv[2],
                              sys.argv[3], targetDirectory)
                    TestArena2Object.startOffline(
                        sys.argv[2],
                        mapName=sys.argv[3],
                        targetDirectory=targetDirectory)
                except:
                    LOG_DEBUG('Game start FAILED with:')
                    LOG_CURRENT_EXCEPTION()

            elif sys.argv[1] == 'hangarOverride':
                try:
                    LOG_DEBUG(sys.argv)
                    from tests.auto.HangarOverride import HangarOverride
                    HangarOverride.setHangar('spaces/' + sys.argv[2])
                except:
                    LOG_DEBUG('Game start FAILED with:')
                    LOG_CURRENT_EXCEPTION()

                gui_personality.start()
            elif sys.argv[1] == 'replayTimeout':
                try:
                    g_replayCtrl.replayTimeout = float(sys.argv[2])
                except:
                    LOG_DEBUG('Game start FAILED with:')
                    LOG_CURRENT_EXCEPTION()

                gui_personality.start()
            elif sys.argv[1] == 'botInit' or sys.argv[1] == 'botExecute':
                gui_personality.start()
                try:
                    LOG_DEBUG(
                        'BOTNET: Playing scenario "%s" with bot "%s"...' %
                        (sys.argv[2], sys.argv[3]))
                    if sys.argv[1] == 'botInit':
                        scenarioPlayer().initBot(sys.argv[3], sys.argv[2])
                    elif sys.argv[1] == 'botExecute':
                        scenarioPlayer().execute(sys.argv[3], sys.argv[2])
                except:
                    LOG_DEBUG('BOTNET: Failed to start the client with:')
                    LOG_CURRENT_EXCEPTION()

            else:
                gui_personality.start()
        else:
            gui_personality.start()
        try:
            import Vibroeffects
            Vibroeffects.VibroManager.g_instance.start()
        except:
            LOG_CURRENT_EXCEPTION()

        try:
            from LightFx import LightManager
            if LightManager.g_instance is not None:
                LightManager.g_instance.start()
            from AuxiliaryFx import g_instance
            if g_instance is not None:
                g_instance.start()
        except:
            LOG_CURRENT_EXCEPTION()

        return
Exemplo n.º 3
0
def start():
    LOG_DEBUG('start')
    if OfflineMode.onStartup():
        LOG_DEBUG('OfflineMode')
        return
    else:
        connectionManager.onConnected += onConnected
        connectionManager.onDisconnected += onDisconnected
        if len(sys.argv) > 2:
            if sys.argv[1] == 'scriptedTest':
                try:
                    scriptName = sys.argv[2]
                    if scriptName[-3:] == '.py':
                        scriptName = scriptName[:-3]
                    try:
                        __import__(scriptName)
                    except ImportError:
                        try:
                            __import__('tests.' + scriptName)
                        except ImportError:
                            __import__('cat.' + scriptName)

                except:
                    LOG_CURRENT_EXCEPTION()
                    BigWorld.wg_writeToStdOut('Failed to run scripted test, Python exception was thrown, see python.log')
                    BigWorld.quit()

            elif sys.argv[1] == 'offlineTest':
                try:
                    from cat.tasks.TestArena2 import TestArena2Object
                    LOG_DEBUG(sys.argv)
                    LOG_DEBUG('starting offline test: %s', sys.argv[2])
                    if len(sys.argv) > 3:
                        TestArena2Object.startOffline(sys.argv[2], sys.argv[3])
                    else:
                        TestArena2Object.startOffline(sys.argv[2])
                except:
                    LOG_DEBUG('Game start FAILED with:')
                    LOG_CURRENT_EXCEPTION()

            elif sys.argv[1] == 'spinTest':
                try:
                    from cat.tasks.TestArena2 import TestArena2Object
                    LOG_DEBUG(sys.argv)
                    targetDirectory = sys.argv[4] if len(sys.argv) > 4 else 'SpinTestResult'
                    LOG_DEBUG('starting offline test: %s %s %s', sys.argv[2], sys.argv[3], targetDirectory)
                    TestArena2Object.startOffline(sys.argv[2], mapName=sys.argv[3], targetDirectory=targetDirectory)
                except:
                    LOG_DEBUG('Game start FAILED with:')
                    LOG_CURRENT_EXCEPTION()

            elif sys.argv[1] == 'validationTest':
                try:
                    gui_personality.start()
                    LOG_DEBUG('starting validationTest')
                    import Cat
                    Cat.Tasks.Validation.ParamsObject.setResultFileName(sys.argv[2])
                    BigWorld.callback(10, Cat.Tasks.Validation.startAllValidationTests)
                except:
                    LOG_DEBUG('Game start FAILED with:')
                    LOG_CURRENT_EXCEPTION()

            elif sys.argv[1] == 'resourcesValidationTest':
                try:
                    gui_personality.start()
                    LOG_DEBUG('starting resourcesValidationTest')
                    import Cat
                    Cat.Tasks.Validation.ParamsObject.setResultFileName(sys.argv[2])
                    BigWorld.callback(10, Cat.Tasks.Validation.startResourcesValidationTest)
                except:
                    LOG_DEBUG('Game start FAILED with:')
                    LOG_CURRENT_EXCEPTION()

            elif sys.argv[1] == 'replayTimeout':
                try:
                    g_replayCtrl.replayTimeout = float(sys.argv[2])
                except:
                    LOG_DEBUG('Game start FAILED with:')
                    LOG_CURRENT_EXCEPTION()

                gui_personality.start()
            elif sys.argv[1] == 'botInit' or sys.argv[1] == 'botExecute':
                gui_personality.start()
                try:
                    LOG_DEBUG('BOTNET: Playing scenario "%s" with bot "%s"...' % (sys.argv[2], sys.argv[3]))
                    if sys.argv[1] == 'botInit':
                        scenarioPlayer().initBot(sys.argv[3], sys.argv[2])
                    elif sys.argv[1] == 'botExecute':
                        scenarioPlayer().execute(sys.argv[3], sys.argv[2])
                except:
                    LOG_DEBUG('BOTNET: Failed to start the client with:')
                    LOG_CURRENT_EXCEPTION()

            else:
                gui_personality.start()
        else:
            gui_personality.start()
        try:
            import Vibroeffects
            Vibroeffects.VibroManager.g_instance.start()
        except:
            LOG_CURRENT_EXCEPTION()

        try:
            from LightFx import LightManager
            if LightManager.g_instance is not None:
                LightManager.g_instance.start()
            from AuxiliaryFx import g_instance
            if g_instance is not None:
                g_instance.start()
        except:
            LOG_CURRENT_EXCEPTION()

        return