示例#1
0
class AccountPoolConfig(ConfigSection):
    def __init__(self, *args, **kwargs):
        ConfigSection.__init__(self, *args, **kwargs)
        self.pool_name = None
        self.filename = None
        self.config = Config(self.global_options.config_dir, False)

    @staticmethod
    def get_description():
        return 'add or configure account pools'

    @staticmethod
    def get_commands():
        return (('add', 'add a new account pool'),
                ('edit', 'replace an existing account pool'))

    def prepare_add(self, parser, pool_name, filename):
        self.pool_name = pool_name
        self.filename = filename
        if not os.path.isfile(filename):
            parser.error('invalid file: ' + filename)
        if self.config.has_account_pool(self.pool_name):
            parser.error('account pool already exists')

    def start_add(self):
        self.config.add_account_pool_from_file(self.pool_name, self.filename)
        print 'Account pool added.'

    def prepare_edit(self, parser, pool_name, filename):
        self.pool_name = pool_name
        self.filename = filename
        if not os.path.isfile(filename):
            parser.error('invalid file: ' + filename)
        if not self.config.has_account_pool(self.pool_name):
            parser.error('account pool not found')

    def start_edit(self):
        self.config.add_account_pool_from_file(self.pool_name, self.filename)
        print 'Account pool configured.'
示例#2
0
class AccountPoolConfig(ConfigSection):
    def __init__(self, *args, **kwargs):
        ConfigSection.__init__(self, *args, **kwargs)
        self.pool_name = None
        self.filename  = None
        self.config    = Config(self.global_options.config_dir, False)

    @staticmethod
    def get_description():
        return 'add or configure account pools'

    @staticmethod
    def get_commands():
        return (('add',  'add a new account pool'),
                ('edit', 'replace an existing account pool'))

    def prepare_add(self, parser, pool_name, filename):
        self.pool_name = pool_name
        self.filename  = filename
        if not os.path.isfile(filename):
            parser.error('invalid file: ' + filename)
        if self.config.has_account_pool(self.pool_name):
            parser.error('account pool already exists')

    def start_add(self):
        self.config.add_account_pool_from_file(self.pool_name, self.filename)
        print 'Account pool added.'

    def prepare_edit(self, parser, pool_name, filename):
        self.pool_name = pool_name
        self.filename  = filename
        if not os.path.isfile(filename):
            parser.error('invalid file: ' + filename)
        if not self.config.has_account_pool(self.pool_name):
            parser.error('account pool not found')

    def start_edit(self):
        self.config.add_account_pool_from_file(self.pool_name, self.filename)
        print 'Account pool configured.'