def main(args=None): args = get_args(args=args) old_dir = os.getcwd() os.chdir(os.path.dirname(args.compose_file.name)) config = include(read_config(args.compose_file), build_fetch_config(args)) write_config(config, args.output) os.chdir(old_dir)
def get_project_from_file(url): # Handle urls in the form file://./some/relative/path old_dir = os.getcwd() os.chdir(os.path.dirname(url.path)) path = url.netloc + url.path if url.netloc.startswith('.') else url.path with open(path, 'r') as fh: config = resolve_relative_paths(read_config(fh)) os.chdir(old_dir) return config
def get_project_from_http(url, config): try: response = requests.get(url.geturl(), timeout=config.get('timeout', 20), verify=config.get('verify_ssl_cert', True), cert=config.get('ssl_cert', None), proxies=config.get('proxies', None)) response.raise_for_status() except requests.exceptions.RequestException as e: raise FetchExternalConfigError("Failed to include %s: %s" % (url.geturl(), e)) return read_config(response.text)
def get_project_from_http(url, config): try: response = requests.get( url.geturl(), timeout=config.get('timeout', 20), verify=config.get('verify_ssl_cert', True), cert=config.get('ssl_cert', None), proxies=config.get('proxies', None)) response.raise_for_status() except requests.exceptions.RequestException as e: raise FetchExternalConfigError("Failed to include %s: %s" % ( url.geturl(), e)) return read_config(response.text)
def get_project_from_s3(url): import boto.exception try: conn = get_boto_conn() bucket = conn.get_bucket(url.netloc) except (boto.exception.BotoServerError, boto.exception.BotoClientError) as e: raise FetchExternalConfigError("Failed to include %s: %s" % (url.geturl(), e)) key = bucket.get_key(url.path) if not key: raise FetchExternalConfigError("Failed to include %s: Not Found" % url.geturl()) return read_config(key.get_contents_as_string())
def get_project_from_file(url): # Handle urls in the form file://./some/relative/path path = url.netloc + url.path if url.netloc.startswith('.') else url.path with open(path, 'r') as fh: return read_config(fh)
def main(args=None): args = get_args(args=args) config = include(read_config(args.compose_file), build_fetch_config(args)) write_config(config, args.output)
def main(args=None): args = get_args(args=args) config = add_namespace(read_config(args.compose_file), args.namespace) write_config(config, args.output)
def get_project_from_file(url): # Handle urls in the form file://./some/relative/path path = url.netloc + url.path if url.netloc.startswith(".") else url.path with open(path, "r") as fh: return read_config(fh)