예제 #1
0
    def test_profiles(self):
        global VANILLA_PROFILE

        mc._make_skeleton(self.instance_arguments['base_directory'])
        instance = mc('one', **self.instance_arguments)
        instance.create()

        self.assertIsNone(instance.profile)
        with self.assertRaises(KeyError):
            instance.profile = 'vanilla'

        instance.define_profile(VANILLA_PROFILE)
        instance.update_profile(VANILLA_PROFILE['name'])

        self.assertTrue(
            os.path.exists(
                os.path.join(instance.env['pwd'], VANILLA_PROFILE['name'])))

        self.assertFalse(
            os.path.isfile(
                os.path.join(instance.env['pwd'], VANILLA_PROFILE['save_as'])))

        self.assertTrue(
            os.path.isfile(
                os.path.join(instance.env['pwd'], VANILLA_PROFILE['name'],
                             VANILLA_PROFILE['run_as'])))

        from copy import copy
        newprofile = copy(VANILLA_PROFILE)
        newprofile['run_as'] = 'minecraft_server.1.6.2.jar'

        instance.define_profile(newprofile)

        self.assertEqual(instance.profile_config['vanilla':'run_as'],
                         'minecraft_server.1.6.2.jar')
예제 #2
0
    def test_profiles(self):
        global VANILLA_PROFILE

        mc._make_skeleton(self.instance_arguments['base_directory'])
        instance = mc('one', **self.instance_arguments)
        instance.create()

        self.assertIsNone(instance.profile)
        with self.assertRaises(KeyError): instance.profile = 'vanilla'

        instance.define_profile(VANILLA_PROFILE)
        instance.update_profile(VANILLA_PROFILE['name'])
        
        self.assertTrue(os.path.exists(os.path.join(instance.env['pwd'],
                                                    VANILLA_PROFILE['name'])))
        
        self.assertFalse(os.path.isfile(os.path.join(instance.env['pwd'],
                                                     VANILLA_PROFILE['save_as'])))

        self.assertTrue(os.path.isfile(os.path.join(instance.env['pwd'],
                                                    VANILLA_PROFILE['name'],
                                                    VANILLA_PROFILE['run_as'])))

        from copy import copy
        newprofile = copy(VANILLA_PROFILE)
        newprofile['run_as'] = 'minecraft_server.1.6.2.jar'
        
        instance.define_profile(newprofile)
        
        self.assertEqual(instance.profile_config['vanilla':'run_as'],
                         'minecraft_server.1.6.2.jar')
예제 #3
0
    def test_profile_jar_match_md5(self):
        global VANILLA_PROFILE

        mc._make_skeleton(self.instance_arguments['base_directory'])
        instance = mc('one', **self.instance_arguments)
        instance.create()
        
        instance.define_profile(VANILLA_PROFILE)
        instance.update_profile(VANILLA_PROFILE['name'])
        instance.profile = VANILLA_PROFILE['name']

        with instance.profile_config as pc:
            pc[VANILLA_PROFILE['name']:'run_as_md5'] = 'abcd'

        self.assertEqual(instance.profile_config[VANILLA_PROFILE['name']:'run_as_md5'], 'abcd')
예제 #4
0
    def test_profile_jar_match_md5(self):
        global VANILLA_PROFILE

        mc._make_skeleton(self.instance_arguments['base_directory'])
        instance = mc('one', **self.instance_arguments)
        instance.create()

        instance.define_profile(VANILLA_PROFILE)
        instance.update_profile(VANILLA_PROFILE['name'])
        instance.profile = VANILLA_PROFILE['name']

        with instance.profile_config as pc:
            pc[VANILLA_PROFILE['name']:'run_as_md5'] = 'abcd'

        self.assertEqual(
            instance.profile_config[VANILLA_PROFILE['name']:'run_as_md5'],
            'abcd')
예제 #5
0
    def test_update_profile(self):
        global VANILLA_PROFILE

        mc._make_skeleton(self.instance_arguments['base_directory'])
        instance = mc('one', **self.instance_arguments)
        instance.define_profile(VANILLA_PROFILE)

        with self.assertRaises(RuntimeError):
            instance.update_profile(VANILLA_PROFILE['name'], 'asdfasdf')
            
        instance.update_profile(VANILLA_PROFILE['name'])

        with self.assertRaises(RuntimeWarning):
            instance.update_profile(VANILLA_PROFILE['name'], '39df9f29e6904ea7b351ffb4fe949881')

        with self.assertRaises(RuntimeWarning):
            instance.update_profile(VANILLA_PROFILE['name'])
예제 #6
0
    def test_update_profile(self):
        global VANILLA_PROFILE

        mc._make_skeleton(self.instance_arguments['base_directory'])
        instance = mc('one', **self.instance_arguments)
        instance.define_profile(VANILLA_PROFILE)

        with self.assertRaises(RuntimeError):
            instance.update_profile(VANILLA_PROFILE['name'], 'asdfasdf')

        instance.update_profile(VANILLA_PROFILE['name'])

        with self.assertRaises(RuntimeWarning):
            instance.update_profile(VANILLA_PROFILE['name'],
                                    '39df9f29e6904ea7b351ffb4fe949881')

        with self.assertRaises(RuntimeWarning):
            instance.update_profile(VANILLA_PROFILE['name'])
예제 #7
0
    def test_start_home_server(self):
        global VANILLA_PROFILE

        mc._make_skeleton(self.instance_arguments['base_directory'])
        instance = mc('one', **self.instance_arguments)
        instance.create()

        instance.define_profile(VANILLA_PROFILE)
        instance.update_profile(VANILLA_PROFILE['name'])
        instance.profile = VANILLA_PROFILE['name']
        instance.start()
        time.sleep(20)
        self.assertTrue(instance.up)
        instance._command_stuff('stop')
        time.sleep(5)
        try:
            instance.kill()
        except RuntimeError:
            pass  #just want to suppress, not anticipate
        else:
            time.sleep(1.5)
예제 #8
0
    def test_start_home_server(self):
        global VANILLA_PROFILE

        mc._make_skeleton(self.instance_arguments['base_directory'])
        instance = mc('one', **self.instance_arguments)
        instance.create()

        instance.define_profile(VANILLA_PROFILE)
        instance.update_profile(VANILLA_PROFILE['name'])
        instance.profile = VANILLA_PROFILE['name']
        instance.start()
        time.sleep(20)
        self.assertTrue(instance.up)
        instance._command_stuff('stop')
        time.sleep(5)
        try:
            instance.kill()
        except RuntimeError:
            pass #just want to suppress, not anticipate
        else:
            time.sleep(1.5)
예제 #9
0
    arguments = list(args.argv)

    available_methods = list(m for m in dir(mc) if callable(getattr(mc,m)) \
                             and not m.startswith('_'))
    available_properties = list(m for m in dir(mc) if not callable(getattr(mc,m)) \
                                and not m.startswith('_'))

    import pprint, types
    pp = pprint.PrettyPrinter(indent=4)

    if args.this:
        args.server_name = os.path.basename(os.getcwd())
        args.base_directory = os.path.dirname(os.path.dirname(os.getcwd()))
    else:
        args.base_directory = args.base_directory or os.path.expanduser("~")
        mc._make_skeleton(args.base_directory)

    if args.server_name:
        owner = mc.has_server_rights(getuser(), args.server_name, args.base_directory)
        if not owner and os.path.isdir(os.path.join(args.base_directory, mc.DEFAULT_PATHS['servers'], args.server_name)):
            raise OSError("User '%s' does not have rights to %s" % (getuser(),
                                                                    os.path.join(args.base_directory,
                                                                                 args.server_name)))
        else:
            instance = mc(args.server_name, owner, args.base_directory)

        if args.cmd in ['screen', 'console']:
            instance._command_direct('screen -r %s' % instance.screen_pid, instance.env['cwd'])
        elif args.cmd in available_methods:
            retval = getattr(instance, args.cmd)(*arguments)
            if retval:
예제 #10
0
        if args.nopid:
            from cherrypy.process.plugins import PIDFile
            PIDFile(cherrypy.engine, args.nopid).subscribe()

            if os.path.isfile(args.nopid):
                import sys
                print 'MineOS instance already running (PID found)'
                sys.exit(1)

        cherrypy.config.update(global_conf)

    if base_dir == '/':
        raise RuntimeError('Cannot start server at filesystem root.')
    else:
        mc._make_skeleton(base_dir)

    root_conf = {
        '/assets': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': os.path.join(html_dir, 'assets')
            },
        '/css': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': os.path.join(html_dir, 'css')
            },
        '/img': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': os.path.join(html_dir, 'img')
            },
        '/js': {
예제 #11
0
    available_methods = list(
        m for m in dir(mc)
        if callable(getattr(mc, m)) and not m.startswith('_'))
    available_properties = list(
        m for m in dir(mc)
        if not callable(getattr(mc, m)) and not m.startswith('_'))

    pp = pprint.PrettyPrinter(indent=4)

    if args.this:
        args.server_name = os.path.basename(os.getcwd())
        args.base_directory = os.path.dirname(os.path.dirname(os.getcwd()))
    else:
        args.base_directory = args.base_directory or os.path.expanduser("~")
        mc._make_skeleton(args.base_directory)

    if args.server_name:
        owner = mc.has_server_rights(getuser(), args.server_name,
                                     args.base_directory)
        if not owner and os.path.isdir(
                os.path.join(args.base_directory, mc.DEFAULT_PATHS['servers'],
                             args.server_name)):
            raise OSError(
                "User '%s' does not have rights to %s" %
                (getuser(), os.path.join(args.base_directory,
                                         args.server_name)))
        else:
            instance = mc(args.server_name, owner, args.base_directory)

        if args.cmd in ['screen', 'console']:
예제 #12
0
        if args.nopid:
            from cherrypy.process.plugins import PIDFile
            PIDFile(cherrypy.engine, args.nopid).subscribe()

            if os.path.isfile(args.nopid):
                import sys
                print 'MineOS instance already running (PID found)'
                sys.exit(1)

        cherrypy.config.update(global_conf)

    if base_dir == '/':
        raise RuntimeError('Cannot start server at filesystem root.')
    else:
        mc._make_skeleton(base_dir)

    root_conf = {
        '/assets': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': os.path.join(html_dir, 'assets')
        },
        '/css': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': os.path.join(html_dir, 'css')
        },
        '/img': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': os.path.join(html_dir, 'img')
        },
        '/js': {