示例#1
0
    def config(self):
        '''
        This property returns a dictionary with all the configuration variables:
        DATASET_DIR, CAPTCHA_TEXT_SIZE, IMAGE_DIMS
        For more info, read the dataset.conf file.
        '''
        # Helper methods to check config variables
        def check_image_dims(value):
            dims = is_int_list(value, min=2, max=2)
            for dim in dims:
                if dim <= 0:
                    raise ValidateError('Wrong image dimensions specified: {}'.format(dims))
            return dims

        def check_dir_exists(value):
            value = is_string(value)
            if not isdir(value):
                raise ValidateError('Directory {} doesnt exist'.format(value))
            return value

        # Load and validate the configuration
        config = Config(join('config', 'dataset.conf'),
                        configspec=join('config', 'dataset.spec.conf'),
                        stringify=True)
        result = config.validate(ConfigValidator({
            'image_dims': check_image_dims,
            'dir': check_dir_exists
        }), preserve_errors=True)

        # Raise an error if the configuration is not valid
        if result is not True:
            raise Exception('Invalid dataset configuration file: {}'.format(result))

        # Return the configuration vars
        config = DictNamespace(config, recursive=True)
        return config
示例#2
0
from configobj import Config

config = Config()
config.port = 2323
示例#3
0
from configobj import Config

config = Config()
config.port = 2000
示例#4
0
from configobj import Config

config = Config()
config.port = 2002
config.drv8835_mode = 1			# 1:PH_EN, 0:IN_IN
config.A_in1 = 14
config.A_in2 = 12
config.B_in1 = 33
config.B_in2 = 25
config.qtr3rc_pins = (26, 27, 15)
示例#5
0
from configobj import Config

config = Config()
config.services = ['admin', 'airterm']
config.ssd1331 = True
config.progress_ssd1331 = True
config.enable_wifi_pin = 36  # PIN Number or None
示例#6
0
from configobj import Config

# my own SSD1331
config = Config()
config.split_COM_odd_even = True  # BUG on chip
config.color_format = 1  # 0:256, 1:65k1, 2:65k2
config.pin_dc = 4
config.pin_rst = 15
config.pin_cs = 5
config.pin_sw = None
#config.pin_sw = 36
示例#7
0
from utils.dictnamespace import DictNamespace
from configobj import ConfigObj as Config
from validate import Validator as ConfigValidator
from os.path import join

global_config = Config(join('config', 'global.conf'),
                       configspec=join('config', 'global.spec.conf'),
                       stringify=True)

result = global_config.validate(ConfigValidator(), preserve_errors=True)
if result is not True:
    raise Exception('Invalid configuration: {}'.format(result))
global_config = DictNamespace(dict(global_config), recursive=True)

if __name__ == '__main__':
    print(global_config)
示例#8
0
from configobj import Config

config = Config()
config.port = 2001
config.drv8835_mode = 1  # 1:PH_EN, 0:IN_IN
config.A_in1 = 14
config.A_in2 = 12
config.B_in1 = 33
config.B_in2 = 25
示例#9
0
from configobj import Config

config = Config()
config.pin_echo = 35
config.pin_trig = 32