Exemplo n.º 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()
Exemplo n.º 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() == ''
Exemplo n.º 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'
Exemplo n.º 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() == ''
Exemplo n.º 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
Exemplo n.º 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
        ]
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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'}
Exemplo n.º 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
Exemplo n.º 13
0
    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
Exemplo n.º 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
Exemplo n.º 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]
Exemplo n.º 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]
Exemplo n.º 17
0
    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']
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 22
0
    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
Exemplo n.º 23
0
 def __init__(self, engine):
     Mgr.__init__(self, engine)
     self.x = 0
Exemplo n.º 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)
Exemplo n.º 25
0
def fake_svc(osvc_path_tests, has_privs, mocker):
    mocker.patch.object(sys, 'argv', ['mgr', "create", '--debug'])
    Mgr(selector='fake-svc')()
Exemplo n.º 26
0
 def __init__(self, engine):
     Mgr.__init__(self, engine)
     pass
Exemplo n.º 27
0
    def __init__(self, engine):
        Mgr.__init__(self, engine)
        self.toggle = 0.15
        print "starting Game mgr"

        pass
Exemplo n.º 28
0
 def __init__(self, engine):
     Mgr.__init__(self, engine)
     pass
Exemplo n.º 29
0
 def __init__(self, engine):
     Mgr.__init__(self, engine)
     self.shipsInCollision = []
Exemplo n.º 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
Exemplo n.º 31
0
 def __init__(self, engine):
     Mgr.__init__(self, engine)
     self.move = 250
     self.rotate = 0.13
     pass
Exemplo n.º 32
0
    def __init__(self, engine):
        Mgr.__init__(self, engine)
        self.toggle = 0.15
        print "starting Game mgr"

        pass
Exemplo n.º 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')
Exemplo n.º 34
0
    def test_wrong_action_exit_1(fake_svc, mock_sysname, sysname):
        mock_sysname(sysname)

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