示例#1
0
class Config(StrictSerializable):
    """The configuration needed to run the combine processes.
    """
    maps = Path(example='data/maps')
    models = Path(example='data/models')
    replays = Path(example='data/replays')
    train_queue_db = Path(example='data/train-queue.db')

    model_cache_size = Integer(example=24)
    token_secret_path = Path(example='data/token-secret')
    api_key = Unicode(example='<api-key>')
    username = Unicode(example='<username>')
    password = Unicode(example='<password>')
    github_url = Unicode(example='http://github.com/example-user/example-repo')
    upload_url = Unicode(example='http://localhost/')
    email_address = Unicode(example='*****@*****.**')

    @Instance
    class irc(StrictSerializable):
        server = Unicode(example='cho.ppy.sh')
        port = Integer(example=6667)

    @Instance
    class gunicorn(StrictSerializable):
        bind = Unicode(example='localhost:5000')
        workers = Integer(example=2)
        timeout = Integer(example=6000)
        accesslog = Path(example='-')
        error = Path(example='-')

    @partial(Instance, default_value=None, allow_none=True, example=None)
    class logging_email(StrictSerializable):
        from_address = Unicode(example='*****@*****.**')
        to_address = Unicode(example='*****@*****.**')
        server_address = Unicode(example='smtp.gmail.com')
        server_port = Integer(example=587)
        password = Unicode(example='<password>')
        log_level = Enum(
            values=['debug', 'info'
                    'notice', 'warning', 'error', 'critical'],
            example='error',
            default='error',
        )

    @property
    def token_secret(self):
        with open(self.token_secret_path, 'rb') as f:
            return f.read()

    @property
    def train_queue(self):
        return TrainQueue(self.train_queue_db)

    @property
    def client(self):
        return sl.Client(sl.Library(self.maps), self.api_key)
示例#2
0
 class logging_email(StrictSerializable):
     from_address = Unicode(example='*****@*****.**')
     to_address = Unicode(example='*****@*****.**')
     server_address = Unicode(example='smtp.gmail.com')
     server_port = Integer(example=587)
     password = Unicode(example='<password>')
     log_level = Enum(
         values=['debug', 'info'
                 'notice', 'warning', 'error', 'critical'],
         example='error',
         default='error',
     )
class Config(Serializable):
    bool = Bool()
    unicode = Unicode()
    int = Integer()
 class Bar(Serializable):
     x = Integer()
     y = Integer()
 class Foo(Serializable):
     x = Integer()
     y = Integer()
示例#6
0
 class gunicorn(StrictSerializable):
     bind = Unicode(example='localhost:5000')
     workers = Integer(example=2)
     timeout = Integer(example=6000)
     accesslog = Path(example='-')
     error = Path(example='-')
示例#7
0
 class irc(StrictSerializable):
     server = Unicode(example='cho.ppy.sh')
     port = Integer(example=6667)