예제 #1
0
파일: main.py 프로젝트: eswald/parlance
 def run_program(cls, args):
     r'''Run a game server.
         Takes options from the command line, including number of games and the
         default map.
     '''#'''
     opts = {}
     if args:
         if args[0] in variants:
             Configuration.set_globally('variant', args[0])
         else: cls.usage('Unknown variant %r', args[0])
     
     manager = ThreadManager()
     server = cls(manager)
     if manager.add_server(server):
         manager.run()
     else: manager.log.critical("Failed to open the socket.")
예제 #2
0
파일: main.py 프로젝트: eswald/parlance
 def run_program(cls, args):
     r'''Run one or more Parlance clients.
         Takes options from the command line, including special syntax for
         host, port, number of bots, and passcodes.
     '''#'''
     name = cls.__name__
     num = None
     countries = {}
     
     host = Configuration._args.get('host')
     for arg in args:
         if arg.isdigit():
             if not cls.allow_multiple:
                 cls.usage('%s does not support multiple copies.', name)
             elif num is None:
                 num = int(arg)
             else: cls.usage()       # Only one number specification allowed
         elif len(arg) > 3 and arg[3] == '=':
             if cls.allow_country:
                 countries[arg[:3].upper()] = int(arg[4:])
             else: cls.usage('%s does not accept country codes.', name)
         elif host is None:
             Configuration.set_globally('host', arg)
         else: cls.usage()           # Only one host specification allowed
     if num is None: num = 1
     
     manager = ThreadManager()
     while num > 0 or countries:
         num -= 1
         if countries:
             nation, pcode = countries.popitem()
             result = manager.add_client(cls, power=nation, passcode=pcode)
         else: result = manager.add_client(cls)
         if not result:
             manager.log.critical('Failed to start %s.  Sorry.', name)
     manager.run()