예제 #1
0
    def __init__(self, engine,localOptions):
        Mgr.__init__(self, engine)
        self.gameStarted = False
        self.winnerIndex = -1
        self.lapsTillWin = localOptions.lapsTillWin
        self.textTint = (0.0,0.0,0.0)
        self.initialCountdownTime = 4
        self.numRaces = 0
        self.allPlayersReady = False

        # create all neccessary overlay panels
        self.mainMenu = Overlay(name = "MainMenu", pos = (0,150), size = (950,950), material = "MainMenu")
        self.finishPanel = Overlay(name = "ExitPanel", pos = (250,100), size = (500,500))
        self.messagePanel = Overlay(name = "MessPanel", pos = (0,0), size = (1000,1000),material = None)

        # initialize values for finish panel
        self.finishPanel.addText("RACE OVER",130,30,30)
        self.finishPanel.addHorizontalDivider(60)
        self.finishPanel.addText("You Placed:",90,80,30)
        self.finalPlacement = self.finishPanel.addText(str(0),350,80,30)
        self.finishPanel.addText("Final Time:",70,120,30)
        self.finalTime = self.finishPanel.addText(str(0),320,120,30)
        self.finishPanel.addText("Press Enter to Play Again",50,380,20)
        self.finishPanel.addText("Press Escape or 'Q' to Exit",50,420,20)
        self.finishPanel.hideAll()

        #initialize values for message panel
        self.countdownText = self.messagePanel.addText(" ", 400,20,40)
        self.noServer = self.messagePanel.addText("No server found, looking...", 125,600,40,(1.0,1.0,1.0),(1.0,0.0,0.0))
        self.waitingText = self.messagePanel.addText("Waiting for Players...", 200,400,40,(1.0,1.0,1.0),(1.0,0.0,0.0))
        self.waitingText.hide()
        self.noServer.hide()
예제 #2
0
    def test_accept_empty_values(capture_stdout, tmp_file, obj):
        assert Mgr(selector=obj)(['create']) == 0
        assert Mgr(selector=obj)(['add', '--key', 'empty', '--value', '']) == 0
        with capture_stdout(tmp_file):
            assert Mgr(selector=obj)(['decode', '--key', 'empty']) == 0

        with open(tmp_file) as output_file:
            assert output_file.read() == ''
예제 #3
0
    def test_decoded_value_is_correct(capture_stdout, tmp_file, obj, key):
        assert Mgr(selector=obj)(['create']) == 0
        assert Mgr(selector=obj)(['add', '--key', key, '--value', 'john']) == 0
        with capture_stdout(tmp_file):
            assert Mgr(selector=obj)(['decode', '--key', key]) == 0

        with open(tmp_file) as output_file:
            assert output_file.read() == 'john'
예제 #4
0
    def test_accept_from_empty_files(capture_stdout, tmp_file, obj):
        open(tmp_file, 'w+').close()
        assert Mgr(selector=obj)(['create']) == 0
        assert Mgr(selector=obj)(['add', '--key', 'empty', '--from',
                                  tmp_file]) == 0
        with capture_stdout(tmp_file):
            assert Mgr(selector=obj)(['decode', '--key', 'empty']) == 0

        with open(tmp_file) as output_file:
            assert output_file.read() == ''
예제 #5
0
 def __init__(self, engine,localOptions):
     Mgr.__init__(self, engine)
     self.engine = engine
     self.networkingEnabled = localOptions.enableNetworking
     if self.networkingEnabled:
         self.server = localOptions.server
     else:
         self.server = False
     self.ip = localOptions.ip
     self.remainingIDs = []
     self.timeToWaitForPlayers = 10
예제 #6
0
    def __init__(self, engine):
        Mgr.__init__(self, engine)
        print "starting ent mgr"

        self.ents = {}
        self.nEnts = 0
        self.selectedEntIndex = 0
        self.selectedEnt = None
        import ent
        self.entTypes = [
            ent.CUBE, ent.ENEMY, ent.PLANE, ent.SHIELD, ent.HIDDEN, ent.END
        ]
예제 #7
0
    def __init__(self, engine):
        Mgr.__init__(self, engine)
        self.invalid = []
        self.enemies = []
        self.items = []
        self.points = 500
        self.time = 0
        self.hidden = 0
        self.lives = 2
        self.win = False
        print "starting Game mgr"

        pass
예제 #8
0
    def test_no_hang(osvc_path_tests, mock_sysname, sysname):
        import socket

        h2_sock = os.path.join(str(osvc_path_tests), 'var', 'lsnr', 'h2.sock')
        assert not os.path.exists(h2_sock)

        sockuxh2 = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
        sockuxh2.bind(h2_sock)
        sockuxh2.close()
        assert os.path.exists(h2_sock)

        Mgr(selector=sysname)(['create', '--debug'])

        assert Mgr(selector=sysname)(['start', '--debug', '--local']) == 0
예제 #9
0
 def __init__(self, engine):
     Mgr.__init__(self, engine)
     OIS.KeyListener.__init__(self)
     OIS.MouseListener.__init__(self)
     OIS.JoyStickListener.__init__(self)
     self.move = 250
     self.rotate = 0.01
     self.yawRot = 0.0
     self.pitchRot = 0.0
     self.transVector = ogre.Vector3(0, 0, 0)
     self.toggle = 0.1
     self.distanceSquaredThreshold = 10000
     self.leftShiftDown = False
     pass
예제 #10
0
 def __init__(self, engine):
     Mgr.__init__(self, engine)
     OIS.KeyListener.__init__(self)
     OIS.MouseListener.__init__(self)
     OIS.JoyStickListener.__init__(self)
     self.move = 250
     self.rotate = 0.01
     self.yawRot = 0.0
     self.pitchRot = 0.0
     self.transVector = ogre.Vector3(0, 0, 0)
     self.toggle = 0.1
     self.distanceSquaredThreshold = 10000
     self.leftShiftDown = False;
     pass
예제 #11
0
    def test_create_service_with_fs_flag_then_verify_config(
            tmp_file, capture_stdout, mock_sysname, sysname):
        mock_sysname(sysname)

        assert Mgr(selector=sysname)(['create', '--kw', 'fs#1.type=flag']) == 0

        assert Mgr(selector=sysname)(['set', '--kw', 'fs#2.type=flag']) == 0

        with capture_stdout(tmp_file):
            assert Mgr(selector=sysname)(
                ['print', 'config', '--format', 'json']) == 0
        with open(tmp_file) as config_file:
            config = json.load(config_file)
        assert config["fs#1"] == {'type': 'flag'}
        assert config["fs#2"] == {'type': 'flag'}
예제 #12
0
 def assert_keys(cfg_object, keys):
     with capture_stdout(tmp_file):
         assert Mgr(selector=cfg_object)(['keys']) == 0
     with open(tmp_file) as result_file:
         read_keys = result_file.read().split()
     for key in keys:
         assert key in read_keys
예제 #13
0
파일: test_mgr.py 프로젝트: sghf/opensvc
    def test_set_fs_flag_not_added_when_not_supported_on_os(
            fake_svc, mock_argv, tmp_file, capture_stdout, mock_sysname,
            sysname):
        mock_argv(['mgr', 'set', '--kw', 'fs#1.type=flag'])
        mock_sysname(sysname)

        assert Mgr(selector='fake-svc')() == 1
예제 #14
0
    def test_create_call_node_create_service(mocker, mock_sysname, sysname):
        mock_sysname(sysname)
        node_create_service = mocker.patch.object(Node,
                                                  'create_service',
                                                  return_value=None)

        assert Mgr(selector='svc1', node=Node())(["create"]) == 0
        assert node_create_service.call_count == 1
예제 #15
0
    def __init__(self, engine):
        Mgr.__init__(self, engine)
        print "starting ent mgr"

        self.ents = {}
        self.nEnts = 0
        self.selectedEntIndex = 0
        self.selectedEnt = None
        self.selectedEnt2 = None
        import ent
        self.entTypes = [ent.ALIENSHIP]
	self.entTypes0 = [ent.ALIENSHIP2]
        self.entTypes2 = [ent.BOX1,ent.BOX2, ent.BOMB1]
        self.entTypes4 = [ent.BUOY1]
        self.entTypes5 = [ent.RANDSHIP]
        self.entTypes6 = [ent.BOX3]
        self.entTypes7 = [ent.BOMB1]
예제 #16
0
    def __init__(self, engine):
        Mgr.__init__(self, engine)
        print "starting ent mgr"

        self.ents = {}
        self.nEnts = 0
        self.selectedEntIndex = 0
        self.selectedEnt = None
        self.selectedEnt2 = None
        import ent
        self.entTypes = [ent.ALIENSHIP]
        self.entTypes0 = [ent.ALIENSHIP2]
        self.entTypes2 = [ent.BOX1, ent.BOX2, ent.BOMB1]
        self.entTypes4 = [ent.BUOY1]
        self.entTypes5 = [ent.RANDSHIP]
        self.entTypes6 = [ent.BOX3]
        self.entTypes7 = [ent.BOMB1]
예제 #17
0
파일: test_mgr.py 프로젝트: sghf/opensvc
    def test_print_config_json(fake_svc, tmp_file, capture_stdout, mock_argv,
                               mock_sysname, sysname):
        mock_argv(['mgr', "print", "config", '--format', 'json'])
        mock_sysname(sysname)

        with capture_stdout(tmp_file):
            assert Mgr(selector='fake-svc')() == 0
        with open(tmp_file) as json_file:
            config = json.load(json_file)
        assert config['DEFAULT']['id']
예제 #18
0
    def test_print_config(fake_svc, tmp_file, capture_stdout, mock_sysname,
                          sysname):
        mock_sysname(sysname)

        with capture_stdout(tmp_file):
            assert Mgr(selector='fake-svc')(["print", "config"]) == 0
        with open(tmp_file) as f:
            config_text = f.read()
        assert '[DEFAULT]' in config_text
        assert 'id =' in config_text
예제 #19
0
    def test_create_then_start_then_verify_flag_file_exists(
            tmp_path, mocker, mock_sysname, sysname):
        mock_sysname(sysname)
        base_flag_d = str(tmp_path)
        mocker.patch(
            'resFsFlag' + sysname + '.Fs.base_flag_d',
            new_callable=mocker.PropertyMock(return_value=base_flag_d))

        expected_flag_file = os.path.join(base_flag_d, 'svc', sysname,
                                          'fs#1.flag')

        assert not os.path.exists(expected_flag_file)

        Mgr(selector=sysname)(['create', '--kw', 'fs#1.type=flag', '--debug'])

        assert not os.path.exists(expected_flag_file)

        assert Mgr(selector=sysname)(['start', '--debug', '--local']) == 0

        assert os.path.exists(expected_flag_file)
예제 #20
0
 def test_no_call_to_main_and_exit_1(mocker, mock_sysname, sysname):
     mocker.patch('rcUtilities.os.geteuid', return_value=66)
     mock_sysname(sysname)
     sys_exit = mocker.patch.object(sys,
                                    'exit',
                                    side_effect=Exception("exit"))
     _main = mocker.patch.object(Mgr, '_main')
     with pytest.raises(Exception, match="exit"):
         Mgr(selector='svc1')(['create'])
     sys_exit.assert_called_once_with(1)
     assert _main.call_count == 0
예제 #21
0
    def test_add_from(capture_stdout, tmp_file, tmp_path, scenario,
                      expected_key_values):
        config_dir = str(os.path.join(str(tmp_path), 'src'))
        os.makedirs(config_dir)
        for file_name in ['f1', '.f2']:
            path = os.path.join(config_dir, file_name)
            with open(path, 'w+') as new_file:
                new_file.write(file_name + '--')
        sub_dir = os.path.join(config_dir, 'sub')
        os.makedirs(sub_dir)
        sub_path_file = os.path.join(sub_dir, 'f3')
        with open(sub_path_file, 'w+') as new_file:
            new_file.write('sub/f3--')

        def assert_decode(cfg_object, key, value):
            with capture_stdout(tmp_file):
                assert Mgr(selector=cfg_object)(['decode', '--key', key]) == 0
            with open(tmp_file) as result_file:
                assert result_file.read() == value

        def assert_keys(cfg_object, keys):
            with capture_stdout(tmp_file):
                assert Mgr(selector=cfg_object)(['keys']) == 0
            with open(tmp_file) as result_file:
                read_keys = result_file.read().split()
            for key in keys:
                assert key in read_keys

        if scenario.startswith('/'):
            from_dir = config_dir
        else:
            os.chdir(str(tmp_path))
            if scenario.startswith('.'):
                from_dir = os.path.join('.', 'src')
            else:
                from_dir = 'src'

        if scenario.split()[0].endswith('/*'):
            from_dir += '/*'
        elif scenario.split()[0].endswith('/'):
            from_dir += '/'
        elif scenario.split()[0].endswith('/f1'):
            from_dir += '/f1'

        obj = 'cfg/cfg1'
        if '--key foo' in scenario:
            args = ['add', '--key', 'foo', '--from', from_dir, '--debug']
        else:
            args = ['add', '--from', from_dir, '--debug']
        assert Mgr(selector=obj)(args) == 0
        assert_keys(obj, expected_key_values.keys())
        for key_name, decoded_value in expected_key_values.items():
            assert_decode(obj, key_name, decoded_value)
예제 #22
0
파일: test_mgr.py 프로젝트: sghf/opensvc
    def test_wrong_action_exit_1(fake_svc, mock_argv, mock_sysname, sysname):
        mock_argv(['mgr', "wrong-action"])
        mock_sysname(sysname)

        assert Mgr(selector='fake-svc')() == 1
예제 #23
0
 def __init__(self, engine):
     Mgr.__init__(self, engine)
     self.x = 0
예제 #24
0
 def __init__(self, engine):
     Mgr.__init__(self, engine)
     self.entities = []
     self.playerIndex = -1
     self.nextPos = ogre.Vector3(const.INNER_RADIUS + 100,50,0)
예제 #25
0
파일: test_mgr.py 프로젝트: sghf/opensvc
def fake_svc(osvc_path_tests, has_privs, mocker):
    mocker.patch.object(sys, 'argv', ['mgr', "create", '--debug'])
    Mgr(selector='fake-svc')()
예제 #26
0
 def __init__(self, engine):
     Mgr.__init__(self, engine)
     pass
예제 #27
0
    def __init__(self, engine):
        Mgr.__init__(self, engine)
        self.toggle = 0.15
        print "starting Game mgr"

        pass
예제 #28
0
 def __init__(self, engine):
     Mgr.__init__(self, engine)
     pass
예제 #29
0
 def __init__(self, engine):
     Mgr.__init__(self, engine)
     self.shipsInCollision = []
예제 #30
0
 def assert_decode(cfg_object, key, value):
     with capture_stdout(tmp_file):
         assert Mgr(selector=cfg_object)(['decode', '--key', key]) == 0
     with open(tmp_file) as result_file:
         assert result_file.read() == value
예제 #31
0
 def __init__(self, engine):
     Mgr.__init__(self, engine)
     self.move = 250
     self.rotate = 0.13
     pass
예제 #32
0
    def __init__(self, engine):
        Mgr.__init__(self, engine)
        self.toggle = 0.15
        print "starting Game mgr"

        pass
예제 #33
0
    def test_provision_service_with_config(has_service_with_vol_and_cfg):
        expected_voldir = os.path.join(str(has_service_with_vol_and_cfg),
                                       'var', 'pool', 'directory',
                                       'vol-test.root.vol.default')

        assert Mgr(selector='svc')(
            ['provision', '--local', '--leader', '--debug']) == 0

        def assert_file_contain(file, expected_value):
            with open(os.path.join(expected_voldir, file)) as file:
                assert file.read() == expected_value

        assert_file_contain('simple_dest', 'cfg content of key simple')
        assert_file_contain('simple_b', 'cfg content of key /simpleb')
        assert_file_contain('baR', 'cfg content of key camelCase/Foo/baR')
        assert_file_contain('double-star-to-only-one',
                            'cfg content of key i/j/k/only-one')

        assert_file_contain(os.path.join('star-to-dir', 'b', 'c'),
                            'cfg content of key a/b/c')
        assert_file_contain(os.path.join('star-to-dir', 'e', 'f1'),
                            'cfg content of key a/e/f1')
        assert_file_contain(os.path.join('star-to-dir', 'e', 'f2'),
                            'cfg content of key a/e/f2')
        assert_file_contain(os.path.join('star-to-dir', 'g'),
                            'cfg content of key a/g')

        assert_file_contain(os.path.join('recursive-dir', 'b', 'c'),
                            'cfg content of key a/b/c')
        assert_file_contain(os.path.join('recursive-dir', 'e', 'f1'),
                            'cfg content of key a/e/f1')
        assert_file_contain(os.path.join('recursive-dir', 'e', 'f2'),
                            'cfg content of key a/e/f2')
        assert_file_contain(os.path.join('recursive-dir', 'g'),
                            'cfg content of key a/g')

        assert_file_contain(
            os.path.join('recursive-dir-with-os-sep', 'b', 'c'),
            'cfg content of key a/b/c')
        assert_file_contain(
            os.path.join('recursive-dir-with-os-sep', 'e', 'f1'),
            'cfg content of key a/e/f1')
        assert_file_contain(
            os.path.join('recursive-dir-with-os-sep', 'e', 'f2'),
            'cfg content of key a/e/f2')
        assert_file_contain(os.path.join('recursive-dir-with-os-sep', 'g'),
                            'cfg content of key a/g')

        assert_file_contain(
            os.path.join('recursive-dir-with-os-sep_2', 'a', 'b', 'c'),
            'cfg content of key a/b/c')
        assert_file_contain(
            os.path.join('recursive-dir-with-os-sep_2', 'a', 'e', 'f1'),
            'cfg content of key a/e/f1')
        assert_file_contain(
            os.path.join('recursive-dir-with-os-sep_2', 'a', 'e', 'f2'),
            'cfg content of key a/e/f2')
        assert_file_contain(
            os.path.join('recursive-dir-with-os-sep_2', 'a', 'g'),
            'cfg content of key a/g')

        assert_file_contain(os.path.join('os-sep-d', 'f'),
                            'cfg content of key /e/f')

        assert_file_contain(os.path.join('all-cfg1', 'simple'),
                            'cfg content of key simple')
        assert_file_contain(os.path.join('all-cfg1', 'simpleb'),
                            'cfg content of key /simpleb')
        assert_file_contain(os.path.join('all-cfg1', 'a', 'g'),
                            'cfg content of key a/g')
        assert_file_contain(os.path.join('all-cfg1', 'e', 'f'),
                            'cfg content of key /e/f')
예제 #34
0
    def test_wrong_action_exit_1(fake_svc, mock_sysname, sysname):
        mock_sysname(sysname)

        assert Mgr(selector='fake-svc')(["wrong-action"]) == 1