def get_s3_conf(cfg, section): key_id = cfg.get(section, 'key_id') key = cfg.get(section, 'key') bucket = cfg.get(section, 'bucket') host = None port = None if cfg.has_option(section, 'host'): addr = cfg.get(section, 'host') segs = addr.split(':') host = segs[0] try: port = int(segs[1]) except IndexError: pass use_v4_sig = False if cfg.has_option(section, 'use_v4_signature'): use_v4_sig = cfg.getboolean(section, 'use_v4_signature') aws_region = None if use_v4_sig: if not cfg.has_option(section, 'aws_region'): raise InvalidConfigError('aws_region is not configured') aws_region = cfg.get(section, 'aws_region') from seafobj.backends.s3 import S3Conf conf = S3Conf(key_id, key, bucket, host, port, use_v4_sig, aws_region) return conf
def get_s3_conf(cfg, section): key_id = cfg.get(section, 'key_id') key = cfg.get(section, 'key') bucket = cfg.get(section, 'bucket') host = None port = None if cfg.has_option(section, 'host'): addr = cfg.get(section, 'host') if ':' not in addr: raise InvalidConfigError('invalid s3 host %s' % addr) segs = addr.split(':') if len(segs) != 2: raise InvalidConfigError('invalid s3 host %s' % addr) host = segs[0] try: port = int(segs[1]) except ValueError: raise InvalidConfigError('invalid s3 host %s' % addr) from seafobj.backends.s3 import S3Conf conf = S3Conf(key_id, key, bucket, host, port) return conf
def get_s3_conf_from_json(cfg): key_id = cfg['key_id'] key = cfg['key'] bucket = cfg['bucket'] host = None port = None if 'host' in cfg: addr = cfg['host'] segs = addr.split(':') host = segs[0] try: port = int(segs[1]) except IndexError: pass use_v4_sig = False if 'use_v4_signature' in cfg: use_v4_sig = cfg['use_v4_signature'] aws_region = None if use_v4_sig: if 'aws_region' not in cfg: raise InvalidConfigError('aws_region is not configured') aws_region = cfg['aws_region'] use_https = False if 'use_https' in cfg: if str(cfg['use_https']).lower().strip() == 'true': use_https = True path_style_request = False if 'path_style_request' in cfg: path_style_request = cfg['path_style_request'] from seafobj.backends.s3 import S3Conf conf = S3Conf(key_id, key, bucket, host, port, use_v4_sig, aws_region, use_https, path_style_request) return conf
def get_s3_conf_from_json(cfg): key_id = cfg['key_id'] key = cfg['key'] bucket = cfg['bucket'] host = None port = None if cfg.has_key('host'): addr = cfg['host'] segs = addr.split(':') host = segs[0] try: port = int(segs[1]) except IndexError: pass use_v4_sig = False if cfg.has_key('use_v4_signature'): use_v4_sig = cfg['use_v4_signature'] aws_region = None if use_v4_sig: if not cfg.has_key('aws_region'): raise InvalidConfigError('aws_region is not configured') aws_region = cfg('aws_region') use_https = False if cfg.has_key('use_https'): use_https = cfg['use_https'] path_style_request = False if cfg.has_key('path_style_request'): path_style_request = cfg['path_style_request'] from seafobj.backends.s3 import S3Conf conf = S3Conf(key_id, key, bucket, host, port, use_v4_sig, aws_region, use_https, path_style_request) return conf