How to use the hdfs.config.Config function in hdfs

To help you get started, we’ve selected a few hdfs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mtth / hdfs / test / test_config.py View on Github external
def test_create_client_with_missing_alias(self):
    with temppath() as tpath:
      Config(tpath).get_client('dev')
github mtth / hdfs / test / test_config.py View on Github external
def test_create_client_with_alias(self):
    with temppath() as tpath:
      config = Config(path=tpath)
      section = 'dev.alias'
      config.add_section(section)
      config.set(section, 'url', 'http://host:port')
      save_config(config)
      Config(path=tpath).get_client('dev')
github mtth / hdfs / test / test_config.py View on Github external
def test_create_client_with_alias(self):
    with temppath() as tpath:
      config = Config(path=tpath)
      section = 'dev.alias'
      config.add_section(section)
      config.set(section, 'url', 'http://host:port')
      save_config(config)
      Config(path=tpath).get_client('dev')
github mtth / hdfs / test / test_config.py View on Github external
def test_autoload_client_from_module(self):
    with temppath() as module_dpath:
      os.mkdir(module_dpath)
      sys.path.append(module_dpath)
      module_fpath = osp.join(module_dpath, 'mclient.py')
      self._write_client_module(module_fpath, 'ModuleClient')
      try:
        with temppath() as config_path:
          config = Config(config_path)
          config.add_section(config.global_section)
          config.set(config.global_section, 'autoload.modules', 'mclient')
          config._autoload()
          client = Client.from_options({'url': ''}, 'ModuleClient')
          eq_(client.one, 1)
      finally:
        sys.path.remove(module_dpath)
github mtth / hdfs / test / test_config.py View on Github external
def test_disable_file_logging(self):
    with temppath() as tpath:
      config = Config(tpath)
      config.add_section('cmd.command')
      config.set('cmd.command', 'log.disable', 'true')
      save_config(config)
      config = Config(tpath)
      handler = config.get_log_handler('cmd')
      ok_(not isinstance(handler, TimedRotatingFileHandler))
github mtth / hdfs / test / test_config.py View on Github external
def test_create_client_with_alias_and_timeout(self):
    with temppath() as tpath:
      config = Config(path=tpath)
      section = 'dev.alias'
      config.add_section(section)
      config.set(section, 'url', 'http://host:port')
      config.set(section, 'timeout', '1')
      save_config(config)
      eq_(Config(path=tpath).get_client('dev')._timeout, 1)
      config.set(section, 'timeout', '1,2')
      save_config(config)
      eq_(Config(path=tpath).get_client('dev')._timeout, (1,2))
github mtth / hdfs / test / test_config.py View on Github external
def test_autoload_missing_path(self):
    with temppath() as module_path:
      with temppath() as config_path:
        config = Config(config_path)
        config.add_section(config.global_section)
        config.set(config.global_section, 'autoload.paths', module_path)
        config._autoload()
github mtth / hdfs / test / test_config.py View on Github external
def test_create_client_with_default_alias(self):
    with temppath() as tpath:
      config = Config(tpath)
      config.add_section(config.global_section)
      config.set(config.global_section, 'default.alias', 'dev')
      section = 'dev.alias'
      config.add_section(section)
      config.set(section, 'url', 'http://host:port')
      save_config(config)
      Config(tpath).get_client()
github mtth / hdfs / test / test_config.py View on Github external
def test_create_client_with_alias_and_timeout(self):
    with temppath() as tpath:
      config = Config(path=tpath)
      section = 'dev.alias'
      config.add_section(section)
      config.set(section, 'url', 'http://host:port')
      config.set(section, 'timeout', '1')
      save_config(config)
      eq_(Config(path=tpath).get_client('dev')._timeout, 1)
      config.set(section, 'timeout', '1,2')
      save_config(config)
      eq_(Config(path=tpath).get_client('dev')._timeout, (1,2))
github mtth / hdfs / hdfs / __main__.py View on Github external
:param command: Command name, used to set up the appropriate log handler.
  :param args: Arguments returned by `docopt`.
  :param config: CLI configuration, used for testing.

  If the `--log` argument is set, this method will print active file handler
  paths and exit the process.

  """
  logger = lg.getLogger()
  logger.setLevel(lg.DEBUG)
  lg.getLogger('requests_kerberos.kerberos_').setLevel(lg.INFO)
  # TODO: Filter only at handler level.
  if not config:
    levels = {0: lg.ERROR, 1: lg.WARNING, 2: lg.INFO}
    config = Config(stream_log_level=levels.get(args['--verbose'], lg.DEBUG))
  handler = config.get_log_handler(command)
  if args['--log']:
    if isinstance(handler, NullHandler):
      sys.stdout.write('No log file active.\n')
      sys.exit(1)
    else:
      sys.stdout.write('%s\n' % (handler.baseFilename, ))
      sys.exit(0)
  logger.addHandler(handler)
  return config.get_client(args['--alias'])