Python six.moves.configparser.ConfigParser() Examples

The following are 30 code examples of six.moves.configparser.ConfigParser(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module six.moves.configparser , or try the search function .
Example #1
Source File: sydent.py    From sydent with Apache License 2.0 6 votes vote down vote up
def parse_config_dict(config_dict):
    """Parse the given config from a dictionary, populating missing items and sections

    Args:
        config_dict (dict): the configuration dictionary to be parsed
    """
    # Build a config dictionary from the defaults merged with the given dictionary
    config = copy.deepcopy(CONFIG_DEFAULTS)
    for section, section_dict in config_dict.items():
        if section not in config:
            config[section] = {}
        for option in section_dict.keys():
            config[section][option] = config_dict[section][option]

    # Build a ConfigParser from the merged dictionary
    cfg = configparser.ConfigParser()
    for section, section_dict in config.items():
        cfg.add_section(section)
        for option, value in section_dict.items():
            cfg.set(section, option, value)

    return cfg 
Example #2
Source File: roomba.py    From Roomba980-Python with MIT License 6 votes vote down vote up
def read_config_file(self, file="./config.ini"):
        #read config file
        Config = configparser.ConfigParser()
        try:
            Config.read(file)
        except Exception as e:
            self.log.warn("Error reading config file %s" %e)
            self.log.info("No Roomba specified, and no config file found - "
                          "attempting discovery")
            if Password(self.address, file):
                return self.read_config_file(file)
            else:
                return False
        self.log.info("reading info from config file %s" % file)
        addresses = Config.sections()
        if self.address is None:
            if len(addresses) > 1:
                self.log.warn("config file has entries for %d Roombas, "
                              "only configuring the first!")
                self.address = addresses[0]
        self.blid = Config.get(self.address, "blid"),
        self.password = Config.get(self.address, "password")
        # self.roombaName = literal_eval(
        #     Config.get(self.address, "data"))["robotname"]
        return True 
Example #3
Source File: scripts_config_test.py    From pulsar with Apache License 2.0 6 votes vote down vote up
def _check_project_directory(project_dir):
    def path_if_exists(name):
        path = os.path.join(project_dir, name)
        if os.path.exists(path):
            return path
        else:
            return None

    app_config = None
    app_config_path = path_if_exists("app.yml")
    if app_config_path:
        app_config = yaml.load(open(app_config_path, "r"))
        assert isinstance(app_config, dict) or (app_config is None)

    ini_config = None
    ini_path = path_if_exists("server.ini")
    if ini_path:
        ini_config = configparser.ConfigParser()
        ini_config.read([ini_path])

    return Project(ini_config, app_config) 
Example #4
Source File: jupyter_magic.py    From aliyun-log-python-sdk with MIT License 6 votes vote down vote up
def _save_config(region, ak_id, ak_key, project, logstore):
    global g_default_region, g_default_ak_id, g_default_ak_key, g_default_project, g_default_logstore

    config = configparser.ConfigParser()
    config.read(CLI_CONFIG_FILENAME)

    if not config.has_section(MAGIC_SECTION):
        config.add_section(MAGIC_SECTION)

    config.set(MAGIC_SECTION, "region-endpoint", region)
    config.set(MAGIC_SECTION, "access-id", ak_id)
    config.set(MAGIC_SECTION, "access-key", ak_key)
    config.set(MAGIC_SECTION, "project", project)
    config.set(MAGIC_SECTION, "logstore", logstore)

    # save to disk
    with open(CLI_CONFIG_FILENAME, 'w') as configfile:
        config.write(configfile)

    # save to memory
    g_default_region, g_default_ak_id, g_default_ak_key, g_default_project, g_default_logstore = region, ak_id, ak_key, project, logstore 
Example #5
Source File: cli_core.py    From aliyun-log-cli with MIT License 6 votes vote down vote up
def configure_default_options(options):
    if not options:
        return

    config = configparser.ConfigParser()

    config.read(LOG_CREDS_FILENAME)

    if not config.has_section(GLOBAL_OPTION_SECTION):
        config.add_section(GLOBAL_OPTION_SECTION)

    if GLOBAL_OPTION_KEY_FORMAT_OUTPUT in options:
        config.set(GLOBAL_OPTION_SECTION, GLOBAL_OPTION_KEY_FORMAT_OUTPUT, options[GLOBAL_OPTION_KEY_FORMAT_OUTPUT])
    if GLOBAL_OPTION_KEY_DEFAULT_CLIENT in options:
        config.set(GLOBAL_OPTION_SECTION, GLOBAL_OPTION_KEY_DEFAULT_CLIENT, options[GLOBAL_OPTION_KEY_DEFAULT_CLIENT])
    if GLOBAL_OPTION_KEY_DECODE_OUTPUT in options:
        config.set(GLOBAL_OPTION_SECTION, GLOBAL_OPTION_KEY_DECODE_OUTPUT, options[GLOBAL_OPTION_KEY_DECODE_OUTPUT])

    with open(LOG_CREDS_FILENAME, 'w') as configfile:
        config.write(configfile) 
Example #6
Source File: configuration.py    From azure-cli-shell with MIT License 6 votes vote down vote up
def __init__(self):
        self.config = configparser.ConfigParser({
            'firsttime' : 'yes',
            'style' : 'default'
        })
        self.config.add_section('Help Files')
        self.config.add_section('Layout')
        self.config.set('Help Files', 'command', 'help_dump.json')
        self.config.set('Help Files', 'history', 'history.txt')
        self.config.set('Layout', 'command_description', 'yes')
        self.config.set('Layout', 'param_description', 'yes')
        self.config.set('Layout', 'examples', 'yes')

        azure_folder = get_config_dir()
        if not os.path.exists(azure_folder):
            os.makedirs(azure_folder)
        if not os.path.exists(os.path.join(get_config_dir(), CONFIG_FILE_NAME)):
            with open(os.path.join(get_config_dir(), CONFIG_FILE_NAME), 'w') as config_file:
                self.config.write(config_file)
        else:
            with open(os.path.join(get_config_dir(), CONFIG_FILE_NAME), 'r') as config_file:
                self.config.readfp(config_file)  # pylint: disable=deprecated-method
                self.update() 
Example #7
Source File: jupyter_magic.py    From aliyun-log-python-sdk with MIT License 6 votes vote down vote up
def _load_config():
    global g_default_region, g_default_ak_id,  g_default_ak_key, g_default_project, g_default_logstore

    def _get_section_option(config, section_name, option_name, default=None):
        if six.PY3:
            return config.get(section_name, option_name, fallback=default)
        else:
            return config.get(section_name, option_name) if config.has_option(section_name, option_name) else default

    config = configparser.ConfigParser()
    config.read(CLI_CONFIG_FILENAME)
    g_default_region = _get_section_option(config, MAGIC_SECTION, "region-endpoint", "")
    g_default_ak_id = _get_section_option(config, MAGIC_SECTION, "access-id", "")
    g_default_ak_key = _get_section_option(config, MAGIC_SECTION, "access-key", "")
    g_default_project = _get_section_option(config, MAGIC_SECTION, "project", "")
    g_default_logstore = _get_section_option(config, MAGIC_SECTION, "logstore", "") 
Example #8
Source File: test_l2_flows.py    From dragonflow with Apache License 2.0 6 votes vote down vote up
def _get_config_values(self, section, key):
        readhandle = None
        value = None
        try:
            config = configparser.ConfigParser()
            readhandle = open(ML2_CONF_INI, 'r')
            config.readfp(readhandle)
            value = config.get(section, key)
        except Exception:
            value = None

        if readhandle is not None:
            try:
                readhandle.close()
            except Exception:
                return value
        return value 
Example #9
Source File: settings.py    From jet-bridge with MIT License 6 votes vote down vote up
def parse_config_file(self, path, section, final=True):
    config_parser = configparser.ConfigParser()
    if not config_parser.read(path):
        raise IOError('Config file at path "{}" not found'.format(path))

    try:
        config = config_parser.items(section)
    except KeyError:
        raise ValueError('Config file does not have [{}] section]'.format(section))

    for (name, value) in config:
        normalized = self._normalize_name(name)
        normalized = normalized.lower()
        if normalized in self._options:
            option = self._options[normalized]
            if option.multiple:
                if not isinstance(value, (list, str)):
                    raise Error("Option %r is required to be a list of %s "
                                "or a comma-separated string" %
                                (option.name, option.type.__name__))

            if type(value) == str and option.type != str:
                option.parse(value)
            else:
                option.set(value) 
Example #10
Source File: azurerm.py    From ops-cli with Apache License 2.0 6 votes vote down vote up
def _get_profile(self, profile="default"):
        path = expanduser("~")
        path += "/.azure/credentials"
        try:
            config = configparser.ConfigParser()
            config.read(path)
        except Exception as exc:
            self.fail("Failed to access {0}. Check that the file exists and you have read "
                      "access. {1}".format(path, str(exc)))
        credentials = dict()
        for key in AZURE_CREDENTIAL_ENV_MAPPING:
            try:
                credentials[key] = config.get(profile, key, raw=True)
            except BaseException:
                pass

        if credentials.get('client_id') is not None or credentials.get(
                'ad_user') is not None:
            return credentials

        return None 
Example #11
Source File: base.py    From gFlex with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, filename=None):
    """
    WhichModel is a copy of initialization features inside the main class
    """
    self.filename = filename
    if self.filename:
      try:
        # only let this function imoprt things once
        self.whichModel_AlreadyRun
      except:
        # Open parser and get what kind of model
        _fileisvalid = self.config = configparser.ConfigParser()
        _fileisvalid = len(_fileisvalid)
        if _fileisvalid:
            try:
              self.config.read(filename)
              # Need to change this and all slashes to be Windows compatible
              self.inpath = os.path.dirname(os.path.realpath(filename)) + '/'
              # Need to have these guys inside "try" to make sure it is set up OK
              # (at least for them)
              self.dimension = self.configGet("integer", "mode", "dimension")
              self.whichModel_AlreadyRun = True
            except:
              sys.exit(">>>> Error: cannot locate specified configuration file. <<<<") 
Example #12
Source File: sydent.py    From sydent with Apache License 2.0 6 votes vote down vote up
def parse_config_file(config_file):
    """Parse the given config from a filepath, populating missing items and
    sections
    Args:
        config_file (str): the file to be parsed
    """
    # if the config file doesn't exist, prepopulate the config object
    # with the defaults, in the right section.
    #
    # otherwise, we have to put the defaults in the DEFAULT section,
    # to ensure that they don't override anyone's settings which are
    # in their config file in the default section (which is likely,
    # because sydent used to be braindead).
    use_defaults = not os.path.exists(config_file)
    cfg = configparser.ConfigParser()
    for sect, entries in CONFIG_DEFAULTS.items():
        cfg.add_section(sect)
        for k, v in entries.items():
            cfg.set(configparser.DEFAULTSECT if use_defaults else sect, k, v)

    cfg.read(config_file)

    return cfg 
Example #13
Source File: aws.py    From commcare-cloud with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def _write_profile_for_sso(
        aws_profile,
        sso_start_url,
        sso_region,
        sso_account_id,
        region):
    config = configparser.ConfigParser()
    config.read(os.path.realpath(AWS_CONFIG_PATH))
    section = 'profile {}'.format(aws_profile)

    if section not in config.sections():
        config.add_section(section)
    config.set(section, 'sso_start_url', sso_start_url)
    config.set(section, 'sso_region', sso_region)
    config.set(section, 'sso_account_id', sso_account_id)
    config.set(section, 'sso_role_name', 'AWSPowerUserAccess')
    config.set(section, 'region', region)
    config.set(section, 'output', 'json')
    with open(AWS_CONFIG_PATH, 'w') as f:
        config.write(f) 
Example #14
Source File: config_helper.py    From PyKMIP with Apache License 2.0 6 votes vote down vote up
def __init__(self, path=None):
        self.logger = logging.getLogger(__name__)
        # DEBUG logging here may expose passwords, so log at INFO by default.
        # However, if consumers know the risks, let them go ahead and override.
        if self.logger.level == logging.NOTSET:
            self.logger.setLevel(logging.INFO)

        self.conf = ConfigParser()

        filenames = path
        if not path:
            filenames = CONFIG_FILE

        if self.conf.read(filenames):
            self.logger.debug("Using config file at {0}".format(filenames))
        else:
            self.logger.warning(
                "Config file {0} not found".format(filenames)) 
Example #15
Source File: test_config.py    From PyKMIP with Apache License 2.0 6 votes vote down vote up
def test_parse_auth_settings_no_config(self):
        """
        Test that server authentication plugin settings are parsed correctly,
        even when not specified.
        """
        parser = configparser.ConfigParser()
        parser.add_section('server')

        c = config.KmipServerConfig()
        c._logger = mock.MagicMock()

        self.assertEqual([], c.settings['auth_plugins'])

        c.parse_auth_settings(parser)
        configs = c.settings['auth_plugins']

        self.assertIsInstance(configs, list)
        self.assertEqual(0, len(configs)) 
Example #16
Source File: util.py    From pygreynoise with MIT License 6 votes vote down vote up
def save_config(config):
    """Save configuration.

    :param config: Data to be written to the configuration file.
    :type config:  dict

    """
    config_parser = ConfigParser()
    config_parser.add_section("greynoise")
    config_parser.set("greynoise", "api_key", config["api_key"])
    config_parser.set("greynoise", "api_server", config["api_server"])
    config_parser.set("greynoise", "timeout", str(config["timeout"]))

    config_dir = os.path.dirname(CONFIG_FILE)
    if not os.path.isdir(config_dir):
        os.makedirs(config_dir)

    with open(CONFIG_FILE, "w") as config_file:
        config_parser.write(config_file) 
Example #17
Source File: tools.py    From ciocheck with MIT License 6 votes vote down vote up
def create_config(self, config):
        """Create a config file for for a given config fname and sections."""
        self.config = config

        if self.config_file and self.config_sections:
            new_config = configparser.ConfigParser()
            new_config_file = os.path.join(self.cmd_root, self.config_file)

            for (cio_config_section, config_section) in self.config_sections:
                if config.has_section(cio_config_section):
                    items = config.items(cio_config_section)
                    new_config.add_section(config_section)

                    for option, value in items:
                        new_config.set(config_section, option, value)

            with open(new_config_file, 'w') as file_obj:
                new_config.write(file_obj) 
Example #18
Source File: test_utils.py    From python-tripleoclient with Apache License 2.0 5 votes vote down vote up
def test_get_config_value(self):
        cfg = ConfigParser()
        cfg.add_section('foo')
        cfg.set('foo', 'bar', 'baz')
        config = utils.get_from_cfg(cfg, 'bar', 'foo')
        self.assertEqual(config, 'baz') 
Example #19
Source File: test_utils.py    From python-tripleoclient with Apache License 2.0 5 votes vote down vote up
def test_getboolean_config_value(self):
        cfg = ConfigParser()
        cfg.add_section('foo')
        test_data_set = [
            (True, 'True'),
            (True, 'true'),
            (False, 'False'),
            (False, 'false')
        ]
        for test_data in test_data_set:
            expected_value, config_value = test_data
            cfg.set('foo', 'bar', config_value)
            obtained_value = utils.getboolean_from_cfg(cfg, 'bar', 'foo')
            self.assertEqual(obtained_value, expected_value) 
Example #20
Source File: library.py    From pyoptools with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, filename, libname=None):

        self.parser=cp.ConfigParser()
        self.parser.read(filename)

        if libname != None:
            globals()[libname]=self 
Example #21
Source File: test_utils.py    From python-tripleoclient with Apache License 2.0 5 votes vote down vote up
def test_getboolean_bad_config_value(self):
        cfg = ConfigParser()
        cfg.add_section('foo')
        cfg.set('foo', 'bar', 'I am not a boolean')
        self.assertRaises(exceptions.NotFound,
                          utils.getboolean_from_cfg,
                          cfg, 'bar', 'foo') 
Example #22
Source File: test_fasp.py    From Slackor with GNU General Public License v3.0 5 votes vote down vote up
def setUp(self):
        FASPTests.setUp(self)
        configFile = configparser.ConfigParser()
        configFile.read('dcetests.cfg')
        self.username = configFile.get('TCPTransport', 'username')
        self.domain   = configFile.get('TCPTransport', 'domain')
        self.serverName = configFile.get('TCPTransport', 'servername')
        self.password = configFile.get('TCPTransport', 'password')
        self.machine  = configFile.get('TCPTransport', 'machine')
        self.hashes   = configFile.get('TCPTransport', 'hashes')
        self.stringBinding = epm.hept_map(self.machine, fasp.MSRPC_UUID_FASP, protocol = 'ncacn_ip_tcp')
        self.ts = ('8a885d04-1ceb-11c9-9fe8-08002b104860', '2.0') 
Example #23
Source File: theme.py    From ttrv with MIT License 5 votes vote down vote up
def from_file(cls, filename, source):
        """
        Load a theme from the specified configuration file.

        Parameters:
            filename: The name of the filename to load.
            source: A description of where the theme was loaded from.
        """
        _logger.info('Loading theme %s', filename)

        try:
            config = configparser.ConfigParser()
            config.optionxform = six.text_type  # Preserve case
            with codecs.open(filename, encoding='utf-8') as fp:
                config.readfp(fp)
        except configparser.ParsingError as e:
            raise ConfigError(e.message)

        if not config.has_section('theme'):
            raise ConfigError(
                'Error loading {0}:\n'
                '    missing [theme] section'.format(filename))

        theme_name = os.path.basename(filename)
        theme_name, _ = os.path.splitext(theme_name)

        elements = {}
        for element, line in config.items('theme'):
            if element not in cls.DEFAULT_ELEMENTS:
                # Could happen if using a new config with an older version
                # of the software
                _logger.info('Skipping element %s', element)
                continue
            elements[element] = cls._parse_line(element, line, filename)

        return cls(name=theme_name, source=source, elements=elements) 
Example #24
Source File: utils.py    From glog-cli with Apache License 2.0 5 votes vote down vote up
def get_config(config_file_path="~/.glogcli.cfg"):
    config = configparser.ConfigParser()
    try:
        open(os.path.expanduser(config_file_path))
    except Exception:
        click.echo("[WARNING] - Could not find %s file. Please create the configuration file like:" % config_file_path)
        click.echo("\n[environment:default]\n"
                   "host=mygraylogserver.com\n"
                   "port=443\n"
                   "username=john.doe\n"
                   "default_stream=*\n"
                   "\n"
                   "[environment:dev]\n"
                   "host=mygraylogserver.dev.com\n"
                   "port=443\n"
                   "proxy=mycompanyproxy.com\n"
                   "username=john.doe\n"
                   "default_stream=57e14cde6fb78216a60d35e8\n"
                   "\n"
                   "[format:default]\n"
                   "format={host} {level} {facility} {timestamp} {message}\n"
                   "\n"
                   "[format:short]\n"
                   "format=[{timestamp}] {level} {message}\n"
                   "\n"
                   "[format:long]\n"
                   "format=time: [{timestamp}] level: {level} msg: {message} tags: {tags}\n"
                   "color=false\n"
                   "\n")

    config.read(os.path.expanduser(config_file_path))
    return config 
Example #25
Source File: constants.py    From ansibullbot with GNU General Public License v3.0 5 votes vote down vote up
def load_config_file():
    ''' Load Config File order(first found is used):
        ENV,CWD,HOME, /etc/ansible '''

    p = configparser.ConfigParser()

    path0 = os.getenv("%s_CONFIG" % PROG_NAME.upper(), None)
    if path0 is not None:
        path0 = os.path.expanduser(path0)
        if os.path.isdir(path0):
            path0 += "/%s.cfg" % PROG_NAME
    try:
        path1 = os.getcwd() + "/%s.cfg" % PROG_NAME
    except OSError:
        path1 = None
    path2 = os.path.expanduser("~/.%s.cfg" % PROG_NAME)
    path3 = "/etc/%s/%s.cfg" % (PROG_NAME, PROG_NAME)

    for path in [path0, path1, path2, path3]:
        if path is not None and os.path.exists(path):
            try:
                p.read(path)
            except configparser.Error as e:
                print("Error reading config file: \n{0}".format(e))
                sys.exit(1)
            return p, path
    return None, '' 
Example #26
Source File: test_config.py    From PyKMIP with Apache License 2.0 5 votes vote down vote up
def test_parse_auth_settings(self):
        """
        Test that server authentication plugin settings are parsed correctly.
        """
        parser = configparser.ConfigParser()
        parser.add_section('server')
        parser.add_section('auth:slugs')
        parser.set('auth:slugs', 'enabled', 'True')
        parser.set('auth:slugs', 'url', 'http://127.0.0.1:8080/slugs/')
        parser.add_section('auth:ldap')
        parser.set('auth:ldap', 'enabled', 'False')
        parser.set('auth:ldap', 'url', 'http://127.0.0.1:8080/ldap/')

        c = config.KmipServerConfig()
        c._logger = mock.MagicMock()

        self.assertEqual([], c.settings['auth_plugins'])

        c.parse_auth_settings(parser)
        configs = c.settings['auth_plugins']

        self.assertIsInstance(configs, list)
        self.assertEqual(2, len(configs))

        for c in configs:
            self.assertIsInstance(c, tuple)
            self.assertEqual(2, len(c))
            self.assertIn(c[0], ['auth:slugs', 'auth:ldap'])
            self.assertIsInstance(c[1], dict)

            if c[0] == 'auth:slugs':
                self.assertIn('enabled', six.iterkeys(c[1]))
                self.assertEqual('True', c[1]['enabled'])
                self.assertIn('url', six.iterkeys(c[1]))
                self.assertEqual('http://127.0.0.1:8080/slugs/', c[1]['url'])
            elif c[0] == 'auth:ldap':
                self.assertIn('enabled', six.iterkeys(c[1]))
                self.assertEqual('False', c[1]['enabled'])
                self.assertIn('url', six.iterkeys(c[1]))
                self.assertEqual('http://127.0.0.1:8080/ldap/', c[1]['url']) 
Example #27
Source File: test_config.py    From PyKMIP with Apache License 2.0 5 votes vote down vote up
def test_load_settings(self):
        """
        Test that the right calls are made and the right errors generated when
        loading configuration settings from a configuration file specified by
        a path string.
        """
        c = config.KmipServerConfig()
        c._logger = mock.MagicMock()
        c._parse_settings = mock.MagicMock()
        c.parse_auth_settings = mock.MagicMock()

        # Test that the right calls are made when correctly processing the
        # configuration file.
        with mock.patch('os.path.exists') as os_mock:
            os_mock.return_value = True
            with mock.patch(
                'six.moves.configparser.ConfigParser.read'
            ) as parser_mock:
                c.load_settings("/test/path/server.conf")
                c._logger.info.assert_any_call(
                    "Loading server configuration settings from: "
                    "/test/path/server.conf"
                )
                parser_mock.assert_called_with("/test/path/server.conf")
                self.assertTrue(c._parse_settings.called)
                self.assertTrue(c.parse_auth_settings.called)

        # Test that a ConfigurationError is generated when the path is invalid.
        c._logger.reset_mock()

        with mock.patch('os.path.exists') as os_mock:
            os_mock.return_value = False
            args = ('/test/path/server.conf', )
            self.assertRaises(
                exceptions.ConfigurationError,
                c.load_settings,
                *args
            ) 
Example #28
Source File: config.py    From PyKMIP with Apache License 2.0 5 votes vote down vote up
def load_settings(self, path):
        """
        Load configuration settings from the file pointed to by path.

        This will overwrite all current setting values.

        Args:
            path (string): The path to the configuration file containing
                the settings to load. Required.
        Raises:
            ConfigurationError: Raised if the path does not point to an
                existing file or if a setting value is invalid.
        """
        if not os.path.exists(path):
            raise exceptions.ConfigurationError(
                "The server configuration file ('{0}') could not be "
                "located.".format(path)
            )

        self._logger.info(
            "Loading server configuration settings from: {0}".format(path)
        )

        parser = configparser.ConfigParser()
        parser.read(path)
        self._parse_settings(parser)
        self.parse_auth_settings(parser) 
Example #29
Source File: core.py    From stash with MIT License 5 votes vote down vote up
def _load_config(no_cfgfile=False):
        config = ConfigParser()
        config.optionxform = str  # make it preserve case

        # defaults
        if not six.PY3:
            config.readfp(BytesIO(_DEFAULT_CONFIG))
        else:
            config.read_file(StringIO(_DEFAULT_CONFIG))

        # update from config file
        if not no_cfgfile:
            config.read(os.path.join(_STASH_ROOT, f) for f in _STASH_CONFIG_FILES)

        return config 
Example #30
Source File: test_client.py    From StrategyEase-Python-SDK with MIT License 5 votes vote down vote up
def setUpClass(cls):
        logging.basicConfig(level=logging.DEBUG)
        config = ConfigParser()
        dir_path = os.path.dirname(os.path.realpath(__file__))
        config.read('{}/../config/config.ini'.format(dir_path))
        cls.client = Client(logging.getLogger(), **dict(config.items('StrategyEase')))
        cls.client_param = config.get('StrategyEase', 'client')