def _download_file(command_template, remote_loc, local_path): with atomic_output_file(local_path, make_parents=True) as temp_target: popenargs = shell_expand_to_popen(command_template, dict_merge(os.environ, {"REMOTE": remote_loc, "LOCAL": temp_target})) log.info("downloading: %s", " ".join(popenargs)) # TODO: Find a way to support force here. subprocess.check_call(popenargs, stdout=SHELL_OUTPUT, stderr=SHELL_OUTPUT, stdin=DEV_NULL)
def _upload_file(command_template, local_path, remote_loc): popenargs = shell_expand_to_popen( command_template, dict_merge(os.environ, { "REMOTE": remote_loc, "LOCAL": local_path })) log.info("uploading: %s", " ".join(popenargs)) # TODO: Find a way to support force here (e.g. add or remove -f to s4cmd) subprocess.check_call(popenargs, stdout=SHELL_OUTPUT, stderr=SHELL_OUTPUT, stdin=DEV_NULL)
def _load_raw_configs(override_path, defaults, overrides): """ Merge defaults, configs from a file, and overrides. Uses first config file in override_path (if set) or finds it in current dir or config dir. """ if override_path: path = override_path else: search_dirs = [".", _locate_config_dir()] path = _locate_config_file(search_dirs) with open(path) as f: parsed_configs = yaml.safe_load(f) out = [] try: items = parsed_configs["items"] for config_dict in items: # Legacy fix for renamed key. TODO: Remove this after a while. if "copy_type" in config_dict: config_dict["install_method"] = config_dict["copy_type"] del config_dict["copy_type"] # Name this config (since we may override the local_path). config_dict["name"] = config_dict["local_path"] nones = {key: None for key in Config._fields} combined = strif.dict_merge(nones, defaults, config_dict, overrides) log.debug("raw, combined config: %r", combined) try: out.append(combined) except TypeError as e: raise ConfigError("error in config value: %s: %s" % (e, config_dict)) except ValueError as e: raise ConfigError("error reading config file: %s" % e) return out
def _upload_file(command_template, local_path, remote_loc): popenargs = shell_expand_to_popen(command_template, dict_merge(os.environ, {"REMOTE": remote_loc, "LOCAL": local_path})) log.info("uploading: %s", " ".join(popenargs)) # TODO: Find a way to support force here (e.g. add or remove -f to s4cmd) subprocess.check_call(popenargs, stdout=SHELL_OUTPUT, stderr=SHELL_OUTPUT, stdin=DEV_NULL)