def download_from_config_files(self, parallel_run_config_file_path, config_files): with open(parallel_run_config_file_path, "w", encoding='utf-8') as wfd: utils.make_open_file_read_write_for_all(wfd) for config_file in config_files: wfd.write(var_stack.ResolveStrToStr('"$(DOWNLOAD_TOOL_PATH)" --config "{config_file}"\n'.format(**locals()))) download_command = " ".join( (self.platform_helper.run_instl(), "parallel-run", "--in", utils.quoteme_double(parallel_run_config_file_path)) ) return download_command
def write_history(self): selected_tab = self.notebook.tab(self.notebook.select(), option='text') var_stack.set_var("SELECTED_TAB").append(selected_tab) the_list_yaml_ready= var_stack.repr_for_yaml(which_vars=var_stack.ResolveVarToList("__GUI_CONFIG_FILE_VARS__", default=[]), include_comments=False, resolve=False, ignore_unknown_vars=True) the_doc_yaml_ready = aYaml.YamlDumpDocWrap(the_list_yaml_ready, '!define', "Definitions", explicit_start=True, sort_mappings=True) with open(var_stack.ResolveVarToStr("INSTL_GUI_CONFIG_FILE_NAME"), "w", encoding='utf-8') as wfd: utils.make_open_file_read_write_for_all(wfd) aYaml.writeAsYaml(the_doc_yaml_ready, wfd)
def download_from_config_files(self, parallel_run_config_file_path, config_files): import win32api with utils.utf8_open(parallel_run_config_file_path, "w") as wfd: utils.make_open_file_read_write_for_all(wfd) for config_file in config_files: # curl on windows has problem with path to config files that have unicode characters normalized_path = win32api.GetShortPathName(config_file) wfd.write(var_stack.ResolveStrToStr('''"$(DOWNLOAD_TOOL_PATH)" --config "{}"\n'''.format(normalized_path))) download_command = " ".join((self.platform_helper.run_instl(), "parallel-run", "--in", utils.quoteme_double(parallel_run_config_file_path))) return download_command, self.platform_helper.exit_if_error()
def write_require_file(self, file_path, require_dict): with open(file_path, "w", encoding='utf-8') as wfd: utils.make_open_file_read_write_for_all(wfd) define_dict = aYaml.YamlDumpDocWrap({"REQUIRE_REPO_REV": var_stack.ResolveVarToStr("MAX_REPO_REV")}, '!define', "definitions", explicit_start=True, sort_mappings=True) require_dict = aYaml.YamlDumpDocWrap(require_dict, '!require', "requirements", explicit_start=True, sort_mappings=True) aYaml.writeAsYaml((define_dict, require_dict), wfd)
def create_instl_history_file(self): var_stack.set_var("__BATCH_CREATE_TIME__").append(time.strftime("%Y/%m/%d %H:%M:%S")) yaml_of_defines = aYaml.YamlDumpDocWrap(var_stack, '!define', "Definitions", explicit_start=True, sort_mappings=True) # write the history file, but only if variable LOCAL_REPO_BOOKKEEPING_DIR is defined # and the folder actually exists. instl_temp_history_file_path = var_stack.ResolveVarToStr("INSTL_HISTORY_TEMP_PATH") instl_temp_history_folder, instl_temp_history_file_name = os.path.split(instl_temp_history_file_path) if os.path.isdir(instl_temp_history_folder): with open(instl_temp_history_file_path, "w", encoding='utf-8') as wfd: utils.make_open_file_read_write_for_all(wfd) aYaml.writeAsYaml(yaml_of_defines, wfd) self.batch_accum += self.platform_helper.append_file_to_file("$(INSTL_HISTORY_TEMP_PATH)", "$(INSTL_HISTORY_PATH)")
def create_config_files(self, curl_config_file_path, num_files): import itertools num_urls_to_download = len(self.urls_to_download) if num_urls_to_download > 0: connect_time_out = var_stack.ResolveVarToStr("CURL_CONNECT_TIMEOUT", "16") max_time = var_stack.ResolveVarToStr("CURL_MAX_TIME", "180") retries = var_stack.ResolveVarToStr("CURL_RETRIES", "3") retry_delay = var_stack.ResolveVarToStr("CURL_RETRY_DELAY", "60") actual_num_files = int(max(0, min(num_urls_to_download, num_files))) num_digits = len(str(actual_num_files)) file_name_list = ["-".join((curl_config_file_path, str(file_i).zfill(num_digits))) for file_i in range(actual_num_files)] wfd_list = list() for file_name in file_name_list: wfd = open(file_name, "w", encoding='utf-8') utils.make_open_file_read_write_for_all(wfd) wfd_list.append(wfd) for wfd in wfd_list: wfd.write("insecure\n") wfd.write("raw\n") wfd.write("fail\n") wfd.write("silent\n") wfd.write("show-error\n") wfd.write("compressed\n") wfd.write("create-dirs\n") wfd.write("connect-timeout = {connect_time_out}\n".format(**locals())) wfd.write("max-time = {max_time}\n".format(**locals())) wfd.write("retry = {retries}\n".format(**locals())) wfd.write("retry_delay = {retry_delay}\n".format(**locals())) wfd.write("write-out = \"Progress: ... of ...; " + os.path.basename(wfd.name) + ": " + DownloadToolBase.curl_write_out_str + "\"\n") wfd.write("\n") wfd.write("\n") wfd_cycler = itertools.cycle(wfd_list) url_num = 0 for url, path in self.urls_to_download: wfd = next(wfd_cycler) wfd.write('''url = "{url}"\noutput = "{path}"\n\n'''.format(**locals())) url_num += 1 for wfd in wfd_list: wfd.close() return file_name_list else: return ()
def create_excludes_file(self): if self.excludes_set: with utils.utf8_open(var_stack.ResolveVarToStr("XCOPY_EXCLUDE_FILE_PATH"), "w") as wfd: utils.make_open_file_read_write_for_all(wfd) wfd.write("\n".join(self.excludes_set))