Beispiel #1
0
    def create_gui(self):

        self.master.title(self.get_version_str())

        self.notebook = Notebook(self.master)
        self.notebook.grid(row=0, column=0)
        self.notebook.bind_all("<<NotebookTabChanged>>", self.tabChangedEvent)

        client_frame = self.create_client_frame(self.notebook)
        admin_frame = self.create_admin_frame(self.notebook)

        self.notebook.add(client_frame, text='Client')
        self.notebook.add(admin_frame, text='Admin')

        to_be_selected_tab_name = var_stack.resolve_var("SELECTED_TAB")
        for tab_id in self.notebook.tabs():
            tab_name = self.notebook.tab(tab_id, option='text')
            if tab_name == to_be_selected_tab_name:
                self.notebook.select(tab_id)
                break

        self.master.resizable(0, 0)

        # bring window to front, be default it stays behind the Terminal window
        if var_stack.resolve_var("__CURRENT_OS__") == "Mac":
            os.system('''/usr/bin/osascript -e 'tell app "Finder" to set frontmost of process "Python" to true' ''')

        self.master.mainloop()
        self.quit_app()
Beispiel #2
0
def create_inheritItem_graph(item_map):
    retVal = nx.DiGraph()
    for item in item_map:
        with item_map[item]:
            for dependant in var_stack.resolve_var_to_list("iid_inherit"):
                retVal.add_edge(var_stack.resolve_var("iid_iid"), dependant)
    return retVal
Beispiel #3
0
 def resolve_defined_paths(self):
     self.path_searcher.add_search_paths(var_stack.resolve_to_list("$(SEARCH_PATHS)"))
     for path_var_to_resolve in var_stack.resolve_to_list("$(PATHS_TO_RESOLVE)"):
         if path_var_to_resolve in var_stack:
             resolved_path = self.path_searcher.find_file(var_stack.resolve_var(path_var_to_resolve),
                                                          return_original_if_not_found=True)
             var_stack.set_var(path_var_to_resolve, "resolve_defined_paths").append(resolved_path)
Beispiel #4
0
def create_dependencies_graph(item_map):
    retVal = nx.DiGraph()
    for item in item_map:
        with item_map[item]:
            for dependant in var_list.resolve_var_to_list("iid_depend_list"):
                retVal.add_edge(var_list.resolve_var("iid_name"), dependant)
    return retVal
Beispiel #5
0
 def read_admin_config_file(self):
     config_path = var_stack.resolve_var("ADMIN_GUI_CONFIG_FILE", default="")
     if os.path.isfile(config_path):
         var_stack.get_configVar_obj("__SEARCH_PATHS__").clear_values() # so __include__ file will not be found on old paths
         self.read_yaml_file(config_path)
         self.admin_config_file_dirty = False
     else:
         print("File not found:", config_path)
Beispiel #6
0
    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.resolve_var_to_list("__GUI_CONFIG_FILE_VARS__"), include_comments=False, resolve=False, ignore_unknown_vars=True)
        the_doc_yaml_ready = augmentedYaml.YamlDumpDocWrap(the_list_yaml_ready, '!define', "Definitions", explicit_start=True, sort_mappings=True)
        with open(var_stack.resolve_var("INSTL_GUI_CONFIG_FILE_NAME"), "w") as wfd:
            make_open_file_read_write_for_all(wfd)
            augmentedYaml.writeAsYaml(the_doc_yaml_ready, wfd)
Beispiel #7
0
 def update_client_input_file_combo(self, *args):
     prev_input_file = var_stack.resolve_var("CLIENT_GUI_IN_FILE")
     new_input_file = self.client_input_path_var.get()
     if os.path.isfile(new_input_file):
         new_input_file_dir, new_input_file_name = os.path.split(new_input_file)
         items_in_dir = os.listdir(new_input_file_dir)
         dir_items = [os.path.join(new_input_file_dir, item) for item in items_in_dir if os.path.isfile(os.path.join(new_input_file_dir, item))]
         self.client_input_combobox.configure(values = dir_items)
     var_stack.set_var("CLIENT_GUI_IN_FILE").append(self.client_input_path_var.get())
Beispiel #8
0
    def create_client_command_line(self):
        retVal = [var_stack.resolve_var("__INSTL_EXE_PATH__"), var_stack.resolve_var("CLIENT_GUI_CMD"),
                        "--in", var_stack.resolve_var("CLIENT_GUI_IN_FILE"),
                        "--out", var_stack.resolve_var("CLIENT_GUI_OUT_FILE")]

        if self.client_credentials_on_var.get():
            credentials = self.client_credentials_var.get()
            if credentials != "":
                retVal.append("--credentials")
                retVal.append(credentials)

        if self.run_client_batch_file_var.get() == 1:
            retVal.append("--run")

        if 'Win' in var_stack.resolve_to_list("$(__CURRENT_OS_NAMES__)"):
            if not getattr(sys, 'frozen', False):
                retVal.insert(0, sys.executable)

        return retVal
Beispiel #9
0
    def check_yaml(self, path_to_yaml):
        command_line = [var_stack.resolve_var("__INSTL_EXE_PATH__"), "read-yaml",
                        "--in", path_to_yaml]

        from subprocess import Popen
        if getattr(os, "setsid", None):
            proc = subprocess.Popen(command_line, executable=command_line[0], shell=False, preexec_fn=os.setsid) # Unix
        else:
            proc = subprocess.Popen(command_line, executable=command_line[0], shell=False) # Windows
        unused_stdout, unused_stderr = proc.communicate()
        retcode = proc.returncode
        if retcode != 0:
            print(" ".join(command_line) + " returned exit code " + str(retcode))
        else:
            print(path_to_yaml, "read OK")
Beispiel #10
0
    def defaults_help(self):
        defaults_folder_path = os.path.join(var_stack.resolve("$(__INSTL_DATA_FOLDER__)"), "defaults")
        for yaml_file in os.listdir(defaults_folder_path):
            if fnmatch.fnmatch(yaml_file, '*.yaml') and yaml_file != "P4.yaml": # hack to not read the P4 defaults
                self.instlObj.read_yaml_file(os.path.join(defaults_folder_path, yaml_file))
        defaults_list = [("Variable name", "Raw value", "Resolved value"),
                         ("_____________", "_________", "______________")]
        for var in sorted(var_stack):
            if not var.startswith("__"):
                cv = var_stack.get_configVar_obj(var)
                raw_value = " ".join([value for value in cv])
                resolved_value = var_stack.resolve_var(var)
                if raw_value != resolved_value:
                    defaults_list.append( (var, raw_value, resolved_value) )
                else:
                    defaults_list.append( (var, raw_value) )

        col_format = gen_col_format(max_widths(defaults_list))
        for res_line in defaults_list:
            print(col_format[len(res_line)].format(*res_line))
Beispiel #11
0
    def create_admin_command_line(self):
        command_name = var_stack.resolve_var("ADMIN_GUI_CMD")
        template_variable = admin_command_template_variables[command_name]
        retVal = var_stack.resolve_var_to_list(template_variable)

        # some special handling of command line parameters cannot yet be expressed in the command template
        if command_name != 'depend':
            if self.admin_command_name_var.get() in self.commands_that_accept_limit_option:
                limit_path = self.admin_limit_var.get()
                if limit_path != "":
                    retVal.append("--limit")
                    limit_paths = shlex.split(limit_path) # there might be space separated paths
                    retVal.extend(limit_paths)

            if self.run_admin_batch_file_var.get() == 1 and command_name in self.commands_with_run_option_list:
                retVal.append("--run")

        if 'Win' in var_stack.resolve_to_list("$(__CURRENT_OS_NAMES__)"):
            if not getattr(sys, 'frozen', False):
                retVal.insert(0, sys.executable)

        return retVal
Beispiel #12
0
    def update_admin_state(self, *args):
        var_stack.set_var("ADMIN_GUI_CMD").append(self.admin_command_name_var.get())

        current_config_path = var_stack.resolve_var("ADMIN_GUI_CONFIG_FILE", default="")
        new_config_path = self.admin_config_path_var.get()
        if current_config_path != new_config_path:
            self.admin_config_file_dirty = True
        var_stack.set_var("ADMIN_GUI_CONFIG_FILE").append(new_config_path)
        if self.admin_config_file_dirty:
             self.read_admin_config_file()

        _, input_file_base_name = os.path.split(var_stack.unresolved_var("ADMIN_GUI_CONFIG_FILE"))
        var_stack.set_var("ADMIN_GUI_CONFIG_FILE_NAME").append(input_file_base_name)

        var_stack.set_var("ADMIN_GUI_OUT_BATCH_FILE").append(self.admin_output_path_var.get())

        var_stack.set_var("ADMIN_GUI_RUN_BATCH").append(bool_int_to_str(self.run_admin_batch_file_var.get()))
        var_stack.set_var("ADMIN_GUI_LIMIT").append(self.admin_limit_var.get())

        self.admin_stage_index_var.set(var_stack.resolve("$(__STAGING_INDEX_FILE__)"))
        self.admin_svn_repo_var.set(var_stack.resolve("$(SVN_REPO_URL), REPO_REV: $(REPO_REV)"))

        sync_url = var_stack.resolve("$(SYNC_BASE_URL)")
        self.admin_sync_url_var.set(sync_url)

        if self.admin_command_name_var.get() in self.commands_that_accept_limit_option:
            self.limit_path_entry_widget.configure(state='normal')
        else:
            self.limit_path_entry_widget.configure(state='disabled')

        if self.admin_command_name_var.get() in self.commands_with_run_option_list:
            self.admin_run_batch_file_checkbox.configure(state='normal')
        else:
            self.admin_run_batch_file_checkbox.configure(state='disabled')

        command_line = " ".join(self.create_admin_command_line())

        self.admin_command_line_var.set(var_stack.resolve(command_line))
Beispiel #13
0
    def init_from_cmd_line_options(self, cmd_line_options_obj):
        """ turn command line options into variables """
        const_attrib_to_var = {
            "input_file": ("__MAIN_INPUT_FILE__", None),
            "output_file": ("__MAIN_OUT_FILE__", None),
            "props_file": ("__PROPS_FILE__", None),
            "config_file": ("__CONFIG_FILE__", None),
            "sh1_checksum": ("__SHA1_CHECKSUM__", None),
            "rsa_signature": ("__RSA_SIGNATURE__", None),
            "start_progress": ("__START_DYNAMIC_PROGRESS__", "0"),
            "total_progress": ("__TOTAL_DYNAMIC_PROGRESS__", "0"),
            "just_with_number": ("__JUST_WITH_NUMBER__", "0"),
            "limit_command_to": ("__LIMIT_COMMAND_TO__", None),
            "shortcut_path": ("__SHORTCUT_PATH__", None),
            "target_path": ("__SHORTCUT_TARGET_PATH__", None),
            "credentials": ("__CREDENTIALS__", None),
            "base_url": ("__BASE_URL__", None),
            "file_sizes_file": ("__FILE_SIZES_FILE__", None)
        }

        for attrib, var in const_attrib_to_var.iteritems():
            attrib_value = getattr(cmd_line_options_obj, attrib)
            if attrib_value:
                var_stack.add_const_config_variable(var[0], "from command line options", *attrib_value)
            elif var[1] is not None:  # there's a default
                var_stack.add_const_config_variable(var[0], "from default", var[1])

        non_const_attrib_to_var = {
            "filter_in": "__FILTER_IN_VERSION__",
            "target_repo_rev": "TARGET_REPO_REV",
            "base_repo_rev": "BASE_REPO_REV",
        }

        for attrib, var in non_const_attrib_to_var.iteritems():
            attrib_value = getattr(cmd_line_options_obj, attrib)
            if attrib_value:
                var_stack.set_var(var, "from command line options").append(attrib_value[0])

        if cmd_line_options_obj.command:
            var_stack.set_var("__MAIN_COMMAND__", "from command line options").append(cmd_line_options_obj.command)

        if hasattr(cmd_line_options_obj, "subject") and cmd_line_options_obj.subject is not None:
            var_stack.add_const_config_variable("__HELP_SUBJECT__", "from command line options",
                                               cmd_line_options_obj.subject)
        else:
            var_stack.add_const_config_variable("__HELP_SUBJECT__", "from command line options", "")

        if cmd_line_options_obj.state_file:
            var_stack.add_const_config_variable("__MAIN_STATE_FILE__", "from command line options",
                                               cmd_line_options_obj.state_file)
        if cmd_line_options_obj.filter_out:
            var_stack.add_const_config_variable("__FILTER_OUT_PATHS__", "from command line options",
                                               *cmd_line_options_obj.filter_out)
        if cmd_line_options_obj.run:
            var_stack.add_const_config_variable("__RUN_BATCH__", "from command line options", "yes")

        if cmd_line_options_obj.no_wtar_artifacts:
            var_stack.add_const_config_variable("__NO_WTAR_ARTIFACTS__", "from command line options", "yes")

        # if credentials were given...
        credentials = None
        if "__CREDENTIALS__" in var_stack:
            credentials = var_stack.resolve_var("__CREDENTIALS__", default=None)

        connection_factory(credentials)
Beispiel #14
0
 def read_history(self):
     try:
         self.read_yaml_file(var_stack.resolve_var("INSTL_GUI_CONFIG_FILE_NAME"))
     except:
         pass
Beispiel #15
0
    def create_client_frame(self, master):

        client_frame = Frame(master)
        client_frame.grid(row=0, column=0)


        curr_row = 0
        command_label = Label(client_frame, text="Command:")
        command_label.grid(row=curr_row, column=0, sticky=W)

        # instl command selection
        client_command_list = var_stack.resolve_var_to_list("__CLIENT_GUI_CMD_LIST__")
        self.client_command_name_var.set(var_stack.unresolved_var("CLIENT_GUI_CMD"))
        OptionMenu(client_frame, self.client_command_name_var,
                   self.client_command_name_var.get(), *client_command_list, command=self.update_client_state).grid(row=curr_row, column=1, sticky=W)

        self.run_client_batch_file_var.set(str_to_bool_int(var_stack.unresolved_var("CLIENT_GUI_RUN_BATCH")))
        self.client_run_batch_file_checkbox = Checkbutton(client_frame, text="Run batch file",
                    variable=self.run_client_batch_file_var, command=self.update_client_state)
        self.client_run_batch_file_checkbox.grid(row=curr_row, column=2, sticky=E)

        # path to input file
        curr_row += 1
        Label(client_frame, text="Input file:").grid(row=curr_row, column=0)
        self.client_input_path_var.set(var_stack.unresolved_var("CLIENT_GUI_IN_FILE"))
        self.client_input_combobox = Combobox(client_frame, textvariable=self.client_input_path_var)
        self.client_input_combobox.grid(row=curr_row, column=1, columnspan=2, sticky=W+E)
        self.client_input_path_var.trace('w', self.update_client_state)
        Button(client_frame, width=2, text="...", command=self.get_client_input_file).grid(row=curr_row, column=3, sticky=W)
        Button(client_frame, width=4, text="Edit",
               command=lambda: self.open_file_for_edit(var_stack.resolve_var("CLIENT_GUI_IN_FILE"))).grid(row=curr_row, column=4, sticky=W)
        Button(client_frame, width=3, text="Chk",
               command=lambda: self.check_yaml(var_stack.resolve_var("CLIENT_GUI_IN_FILE"))).grid(row=curr_row, column=5, sticky=W)

        # path to output file
        curr_row += 1
        Label(client_frame, text="Batch file:").grid(row=curr_row, column=0)
        self.client_output_path_var.set(var_stack.unresolved_var("CLIENT_GUI_OUT_FILE"))
        Entry(client_frame, textvariable=self.client_output_path_var).grid(row=curr_row, column=1, columnspan=2, sticky=W+E)
        self.client_output_path_var.trace('w', self.update_client_state)
        Button(client_frame, width=2, text="...", command=self.get_client_output_file).grid(row=curr_row, column=3, sticky=W)
        Button(client_frame, width=4, text="Edit",
                command=lambda: self.open_file_for_edit(var_stack.resolve_var("CLIENT_GUI_OUT_FILE"))).grid(row=curr_row, column=4, sticky=W)

        # s3 user credentials
        curr_row += 1
        Label(client_frame, text="Credentials:").grid(row=curr_row, column=0, sticky=E)
        self.client_credentials_var.set(var_stack.unresolved_var("CLIENT_GUI_CREDENTIALS"))
        Entry(client_frame, textvariable=self.client_credentials_var).grid(row=curr_row, column=1, columnspan=2, sticky=W+E)
        self.client_credentials_var.trace('w', self.update_client_state)

        self.client_credentials_on_var.set(var_stack.unresolved_var("CLIENT_GUI_CREDENTIALS_ON"))
        Checkbutton(client_frame, text="", variable=self.client_credentials_on_var).grid(row=curr_row, column=3, sticky=W)
        self.client_credentials_on_var.trace('w', self.update_client_state)

        # the combined command line text
        curr_row += 1
        Button(client_frame, width=6, text="run:", command=self.run_client).grid(row=curr_row, column=0, sticky=W)
        self.client_command_line_var = StringVar()
        Label(client_frame, textvariable=self.client_command_line_var, wraplength=400, anchor=W).grid(row=curr_row, column=1, columnspan=4, sticky=W)

        client_frame.grid_columnconfigure(0, minsize=80)
        client_frame.grid_columnconfigure(1, minsize=300)
        client_frame.grid_columnconfigure(2, minsize=80)

        return client_frame
Beispiel #16
0
 def create_variables_assignment(self):
     self.batch_accum.set_current_section("assign")
     for identifier in var_stack:
         if identifier not in self.do_not_write_vars:
             self.batch_accum += self.platform_helper.var_assign(identifier, var_stack.resolve_var(identifier),
                                                                 None)  # var_stack[identifier].resolved_num
Beispiel #17
0
    def create_admin_frame(self, master):

        admin_frame = Frame(master)
        admin_frame.grid(row=0, column=1)

        curr_row = 0
        Label(admin_frame, text="Command:").grid(row=curr_row, column=0, sticky=E)

        # instl command selection
        self.admin_command_name_var.set(var_stack.unresolved_var("ADMIN_GUI_CMD"))
        admin_command_list = var_stack.resolve_var_to_list("__ADMIN_GUI_CMD_LIST__")
        commandNameMenu = OptionMenu(admin_frame, self.admin_command_name_var,
                                     self.admin_command_name_var.get(), *admin_command_list, command=self.update_admin_state)
        commandNameMenu.grid(row=curr_row, column=1, sticky=W)
        ToolTip(commandNameMenu, msg="instl admin command")

        self.run_admin_batch_file_var.set(str_to_bool_int(var_stack.unresolved_var("ADMIN_GUI_RUN_BATCH")))
        self.admin_run_batch_file_checkbox = Checkbutton(admin_frame, text="Run batch file", variable=self.run_admin_batch_file_var,
                    command=self.update_admin_state)
        self.admin_run_batch_file_checkbox.grid(row=curr_row, column=2, columnspan=2, sticky=E)

        # path to config file
        curr_row += 1
        Label(admin_frame, text="Config file:").grid(row=curr_row, column=0, sticky=E)
        self.admin_config_path_var.set(var_stack.unresolved_var("ADMIN_GUI_CONFIG_FILE"))
        configFilePathEntry = Entry(admin_frame, textvariable=self.admin_config_path_var)
        configFilePathEntry.grid(row=curr_row, column=1, columnspan=2, sticky=W+E)
        ToolTip(configFilePathEntry, msg="path instl repository config file")
        self.admin_config_path_var.trace('w', self.update_admin_state)

        openConfigButt = Button(admin_frame, width=2, text="...", command=self.get_admin_config_file)
        openConfigButt.grid(row=curr_row, column=3, sticky=W)
        ToolTip(openConfigButt, msg="open admin config file")

        editConfigButt = Button(admin_frame, width=4, text="Edit",
                                command=lambda: self.open_file_for_edit(var_stack.resolve_var("ADMIN_GUI_CONFIG_FILE")))
        editConfigButt.grid(row=curr_row, column=4, sticky=W)
        ToolTip(editConfigButt, msg="edit admin config file")

        checkConfigButt = Button(admin_frame, width=3, text="Chk",
                                 command=lambda: self.check_yaml(var_stack.resolve_var("ADMIN_GUI_CONFIG_FILE")))
        checkConfigButt.grid(row=curr_row, column=5, sticky=W)
        ToolTip(checkConfigButt, msg="read admin config file to check it's structure")

        # path to stage index file
        curr_row += 1
        Label(admin_frame, text="Stage index:").grid(row=curr_row, column=0, sticky=E)
        Label(admin_frame, text="---", textvariable=self.admin_stage_index_var).grid(row=curr_row, column=1, columnspan=2, sticky=W)
        editIndexButt = Button(admin_frame, width=4, text="Edit", command=lambda: self.open_file_for_edit(var_stack.resolve("$(__STAGING_INDEX_FILE__)", raise_on_fail=True)))
        editIndexButt.grid(row=curr_row, column=4, sticky=W)
        ToolTip(editIndexButt, msg="edit repository index")

        checkIndexButt = Button(admin_frame, width=3, text="Chk",  command=lambda: self.check_yaml(var_stack.resolve("$(__STAGING_INDEX_FILE__)")))
        checkIndexButt.grid(row=curr_row, column=5, sticky=W)
        ToolTip(checkIndexButt, msg="read repository index to check it's structure")

        # path to svn repository
        curr_row += 1
        Label(admin_frame, text="Svn repo:").grid(row=curr_row, column=0, sticky=E)
        svnRepoLabel = Label(admin_frame, text="---", textvariable=self.admin_svn_repo_var)
        svnRepoLabel.grid(row=curr_row, column=1, columnspan=2, sticky=W)
        ToolTip(svnRepoLabel, msg="URL of the SVN repository with current repo-rev")

        # sync URL
        curr_row += 1
        Label(admin_frame, text="Sync URL:").grid(row=curr_row, column=0, sticky=E)
        syncURLLabel = Label(admin_frame, text="---", textvariable=self.admin_sync_url_var)
        syncURLLabel.grid(row=curr_row, column=1, columnspan=2, sticky=W)
        ToolTip(syncURLLabel, msg="Top URL for uploading to the repository")

        # path to output file
        curr_row += 1
        Label(admin_frame, text="Batch file:").grid(row=curr_row, column=0, sticky=E)
        self.admin_output_path_var.set(var_stack.unresolved_var("ADMIN_GUI_OUT_BATCH_FILE"))
        Entry(admin_frame, textvariable=self.admin_output_path_var).grid(row=curr_row, column=1, columnspan=2, sticky=W+E)
        self.admin_output_path_var.trace('w', self.update_admin_state)
        Button(admin_frame, width=2, text="...", command=self.get_admin_output_file).grid(row=curr_row, column=3, sticky=W)
        Button(admin_frame, width=4, text="Edit",
                command=lambda: self.open_file_for_edit(var_stack.resolve_var("ADMIN_GUI_OUT_BATCH_FILE"))).grid(row=curr_row, column=4, sticky=W)

        # relative path to limit folder
        curr_row += 1
        Label(admin_frame, text="Limit to:").grid(row=curr_row, column=0, sticky=E)
        self.admin_limit_var.set(var_stack.unresolved_var("ADMIN_GUI_LIMIT"))
        self.limit_path_entry_widget = Entry(admin_frame, textvariable=self.admin_limit_var)
        self.limit_path_entry_widget.grid(row=curr_row, column=1, columnspan=2, sticky=W+E)
        self.admin_limit_var.trace('w', self.update_admin_state)

        # the combined command line text
        curr_row += 1
        Button(admin_frame, width=6, text="run:", command=self.run_admin).grid(row=curr_row, column=0, sticky=W)
        self.admin_command_line_var = StringVar()
        Label(admin_frame, textvariable=self.admin_command_line_var, wraplength=400, anchor=W).grid(row=curr_row, column=1, columnspan=2, sticky=W)

        return admin_frame