コード例 #1
0
ファイル: front_end.py プロジェクト: OmarNour/new_udi
 def browsefunc(self):
     current_file = self.config_file_entry_txt.get()
     filename = filedialog.askopenfilename(initialdir=md.get_dirs()[1])
     filename = current_file if filename == "" else filename
     self.config_file_entry.delete(0, END)
     self.config_file_entry.insert(END, filename)
     self.refresh_config_file_values()
コード例 #2
0
def get_config_file_path():
    config_file_path = md.get_dirs()[1]
    return config_file_path
コード例 #3
0
ファイル: front_end.py プロジェクト: OmarNour/new_udi
    def __init__(self):
        self.root = Tk()
        img_icon = PhotoImage(
            file=os.path.join(md.get_dirs()[0], 'script_icon.png'))
        self.root.tk.call('wm', 'iconphoto', self.root._w, img_icon)
        self.root.wm_title("SMX Scripts Builder " + pm.ver_no)
        self.root.resizable(width="false", height="false")
        self.msg_no_config_file = "No Config File Found!"
        self.color_msg_no_config_file = "red"
        self.msg_ready = "Ready"
        self.color_msg_ready = "green"
        self.msg_generating = "In Progress... "
        self.color_msg_generating = "blue"
        self.msg_done = "Done, Elapsed Time: "
        self.color_msg_done = "green"
        self.color_msg_done_with_error = "red"
        self.color_error_messager = "red"
        self.project_generation_flag = "Project ACA"

        frame_row0 = Frame(self.root, borderwidth="2", relief="ridge")
        frame_row0.grid(column=0, row=0)

        frame_row1 = Frame(self.root, borderwidth="2", relief="ridge")
        frame_row1.grid(column=0, row=1, sticky=W)

        frame_row2 = Frame(self.root, borderwidth="2", relief="ridge")
        frame_row2.grid(column=0, row=2, sticky=W + E)

        frame_row2.grid_columnconfigure(0, weight=1, uniform="group1")
        frame_row2.grid_columnconfigure(1, weight=1, uniform="group1")
        frame_row2.grid_rowconfigure(0, weight=1)

        frame_row2_l = Frame(frame_row2, borderwidth="2", relief="ridge")
        frame_row2_l.grid(column=0, row=3, sticky=W + E)

        frame_row2_r = Frame(frame_row2, borderwidth="2", relief="ridge")
        frame_row2_r.grid(column=1, row=3, sticky=W + E)

        self.status_label_text = StringVar()
        self.status_label = Label(frame_row2_l)
        self.status_label.grid(column=0, row=0, sticky=W)

        self.server_info_label_text = StringVar()
        self.server_info_label = Label(frame_row2_r)
        self.server_info_label.grid(column=1, row=0, sticky=E)

        config_file_label = Label(frame_row0, text="Config File")
        config_file_label.grid(row=0, column=0, sticky='e')

        self.config_file_browse_button = Button(frame_row0,
                                                text="...",
                                                command=self.browsefunc)
        self.config_file_browse_button.grid(row=0, column=3, sticky='w')

        self.config_file_entry_txt = StringVar()
        self.config_file_entry = Entry(frame_row0,
                                       textvariable=self.config_file_entry_txt,
                                       width=100)
        config_file_path = os.path.join(funcs.get_config_file_path(),
                                        pm.default_config_file_name)
        try:
            x = open(config_file_path)
        except:
            config_file_path = ""
        self.config_file_entry.insert(END, config_file_path)
        self.config_file_entry.grid(row=0, column=1)

        frame_buttons = Frame(frame_row1, borderwidth="2", relief="ridge")
        frame_buttons.grid(column=1, row=0)
        self.generate_button = Button(frame_buttons,
                                      text="Start",
                                      width=12,
                                      height=2,
                                      command=self.start)
        self.generate_button.grid(row=2, column=0)
        # close_button = Button(frame_buttons, text="Abort", width=12, height=1, command=self.close)
        # close_button.grid(row=3, column=0)
        close_button = Button(frame_buttons,
                              text="Exit",
                              width=12,
                              height=2,
                              command=self.close)
        close_button.grid(row=4, column=0)

        frame_config_file_values = Frame(frame_row1,
                                         borderwidth="2",
                                         relief="ridge")
        frame_config_file_values.grid(column=0, row=0, sticky="w")

        frame_checkboxes_values = Frame(frame_config_file_values,
                                        relief="ridge")
        frame_checkboxes_values.grid(column=1, row=6, sticky="W")

        frame_radiobuttons_values = Frame(frame_config_file_values,
                                          relief="ridge")
        frame_radiobuttons_values.grid(column=1, row=5, sticky="W")

        self.get_config_file_values()
        frame_config_file_values_entry_width = 84

        read_from_smx_label = Label(frame_config_file_values,
                                    text="SMXs Folder")
        read_from_smx_label.grid(row=0, column=0, sticky='e')

        self.text_field_read_from_smx = StringVar()
        self.entry_field_read_from_smx = Entry(
            frame_config_file_values,
            textvariable=self.text_field_read_from_smx,
            width=frame_config_file_values_entry_width)
        self.entry_field_read_from_smx.grid(row=0, column=1, sticky="w")

        output_path_label = Label(frame_config_file_values,
                                  text="Output Folder")
        output_path_label.grid(row=1, column=0, sticky='e')

        self.text_field_output_path = StringVar()
        self.entry_field_output_path = Entry(
            frame_config_file_values,
            textvariable=self.text_field_output_path,
            width=frame_config_file_values_entry_width)
        self.entry_field_output_path.grid(row=1, column=1, sticky="w")

        source_names_label = Label(frame_config_file_values, text="Sources")
        source_names_label.grid(row=2, column=0, sticky='e')

        self.text_field_source_names = StringVar()
        self.entry_field_source_names = Entry(
            frame_config_file_values,
            textvariable=self.text_field_source_names,
            width=frame_config_file_values_entry_width)
        self.entry_field_source_names.grid(row=2,
                                           column=1,
                                           sticky="w",
                                           columnspan=1)

        db_prefix_label = Label(frame_config_file_values, text="DB Prefix")
        db_prefix_label.grid(row=3, column=0, sticky='e')

        self.text_db_prefix = StringVar()
        self.entry_db_prefix = Entry(
            frame_config_file_values,
            textvariable=self.text_db_prefix,
            width=frame_config_file_values_entry_width)
        self.entry_db_prefix.grid(row=3, column=1, sticky="w", columnspan=1)

        self.UDI_scripts_generation_value = IntVar()
        self.Testing_scripts_generation_value = IntVar()
        self.Source_smx_generation_value = IntVar()

        scripts_generation_label = Label(frame_config_file_values,
                                         text="Generating scripts")
        scripts_generation_label.grid(row=6,
                                      column=0,
                                      sticky='e',
                                      columnspan=1)
        self.scripts_flag = "UDI"

        self.UDI_scripts_generation = Checkbutton(
            frame_checkboxes_values,
            text="UDI",
            variable=self.UDI_scripts_generation_value,
            onvalue=1,
            offvalue=0,
            command=self.toggle_scripts_flag)
        self.UDI_scripts_generation.grid(row=0,
                                         column=0,
                                         sticky='w',
                                         columnspan=1)
        self.UDI_scripts_generation.grid(row=0,
                                         column=0,
                                         sticky='w',
                                         columnspan=1)

        self.Testing_scripts_generation = Checkbutton(
            frame_checkboxes_values,
            text="Testing",
            variable=self.Testing_scripts_generation_value,
            onvalue=1,
            offvalue=0,
            command=self.toggle_scripts_flag)
        self.Testing_scripts_generation.grid(row=0,
                                             column=1,
                                             sticky='w',
                                             columnspan=1)

        self.source_smx_generation = Checkbutton(
            frame_checkboxes_values,
            text="Source smx",
            variable=self.Source_smx_generation_value,
            onvalue=1,
            offvalue=0,
            command=self.toggle_scripts_flag)
        self.source_smx_generation.grid(row=0,
                                        column=0,
                                        sticky='w',
                                        columnspan=1)
        self.source_smx_generation.grid(row=0,
                                        column=2,
                                        sticky='w',
                                        columnspan=1)

        self.UDI_scripts_generation.select()

        self.populate_config_file_values()
        self.config_file_entry_txt.trace("w", self.refresh_config_file_values)

        thread0 = GenerateScriptsThread(0, "Thread-0", self)
        thread0.start()

        self.root.mainloop()
コード例 #4
0
ファイル: front_end.py プロジェクト: AyazzHamdy/SAMA_UDI
    def __init__(self):
        self.root = Tk()
        img_icon = PhotoImage(file=os.path.join(md.get_dirs()[0], 'script_icon.png'))
        self.root.tk.call('wm', 'iconphoto', self.root._w, img_icon)
        self.root.wm_title("SMX Scripts Builder " + pm.ver_no)
        self.root.resizable(width="false", height="false")
        self.msg_no_config_file = "No Config File Found!"
        self.color_msg_no_config_file = "red"
        self.msg_ready = "Ready"
        self.color_msg_ready = "green"
        self.msg_generating = "In Progress... "
        self.color_msg_generating = "blue"
        self.msg_done = "Done, Elapsed Time: "
        self.msg_done_sftp = "Done"
        self.msg_error_sftp = "Error"
        self.color_msg_done = "green"
        self.color_msg_done_with_error = "red"
        self.color_error_messager = "red"
        self.scripts_generation_flag = "Project ACA"
        self.log_file = "LOG FILE"
        now = datetime.now()
        self.current_date = now.strftime("%d/%m/%Y %H:%M:%S")

        tab_parent = ttk.Notebook(self.root)

        tab1 = ttk.Frame(tab_parent)
        tab2 = ttk.Frame(tab_parent)

        tab_parent.add(tab1, text="UDI")
        tab_parent.add(tab2, text="SFTP SCRIPTS")

        tab_parent.pack(expand=1, fill='both')

        frame_row0 = Frame(tab1, borderwidth="2", relief="ridge")
        frame_row0.grid(column=0, row=0, sticky=W)

        frame_row1 = Frame(tab1, borderwidth="2", relief="ridge")
        frame_row1.grid(column=0, row=1, sticky=W)

        frame_row2 = Frame(tab1, borderwidth="2", relief="ridge")
        frame_row2.grid(column=0, row=2, sticky=W + E)

        frame_row3 = Frame(tab2, borderwidth="2", relief="ridge")
        frame_row3.grid(column=0, row=0, sticky=W)

        frame_row4 = Frame(tab2, borderwidth="2", relief="ridge")
        frame_row4.grid(column=0, row=1, sticky=W)

        frame_row5 = Frame(tab2, borderwidth="2", relief="ridge")
        frame_row5.grid(column=0, row=2, sticky=W + E)

        frame_row2.grid_columnconfigure(0, weight=1, uniform="group1")
        frame_row2.grid_columnconfigure(1, weight=1, uniform="group1")
        frame_row2.grid_rowconfigure(0, weight=1)

        frame_row2_l = Frame(frame_row2, borderwidth="2", relief="ridge")
        frame_row2_l.grid(column=0, row=3, sticky=W + E)

        frame_row2_r = Frame(frame_row2, borderwidth="2", relief="ridge")
        frame_row2_r.grid(column=1, row=3, sticky=W + E)

        frame_row2_rr = Frame(frame_row2, relief="ridge")
        frame_row2_rr.grid(column=2, row=3, sticky=W + E)

        frame_row5.grid_columnconfigure(0, weight=1, uniform="group1")
        frame_row5.grid_columnconfigure(1, weight=1, uniform="group1")
        frame_row5.grid_rowconfigure(0, weight=1)

        frame_row5_l = Frame(frame_row5, borderwidth="2", relief="ridge")
        frame_row5_l.grid(column=0, row=3, sticky=W + E)

        frame_row5_r = Frame(frame_row5, borderwidth="2", relief="ridge")
        frame_row5_r.grid(column=1, row=3, sticky=W + E)

        frame_row5_rr = Frame(frame_row5, relief="ridge")
        frame_row5_rr.grid(column=2, row=3, sticky=W + E)

        abs_file_path = os.path.join(md.get_dirs()[0], 'Teradata_logo-two_color.png')
        img = Image.open(abs_file_path, 'r')
        resized = img.resize((110, 45), Image.ANTIALIAS)
        resized_image = ImageTk.PhotoImage(resized)
        self.image_label = Label(frame_row2_rr, image=resized_image)
        self.image_label1 = Label(frame_row5_rr, image=resized_image)
        self.image_label.grid(column=2, row=0, sticky=S + W + N + E)
        self.image_label1.grid(column=2, row=0, sticky=S + W + N + E)

        self.status_label_text = StringVar()
        self.status_label_text1 = StringVar()
        self.status_label = Label(frame_row2_l, height=2)
        self.status_label.grid(column=0, row=0, sticky=W)
        self.status_label1 = Label(frame_row5_l, height=2)
        self.status_label1.grid(column=0, row=0, sticky=W)

        self.server_info_label_text = StringVar()
        self.server_info_label_text1 = StringVar()
        self.server_info_label = Label(frame_row2_r, height=2)
        self.server_info_label.grid(column=1, row=0, sticky=E)
        self.server_info_label1 = Label(frame_row5_r, height=2)
        self.server_info_label1.grid(column=1, row=0, sticky=E)

        config_file_label = Label(frame_row0, text="Config File")
        config_file_label.grid(row=0, column=0, sticky='e')

        self.config_file_browse_button = Button(frame_row0, text="...", command=self.browsefunc)
        self.config_file_browse_button.grid(row=0, column=3, sticky='w')

        config_file_label1 = Label(frame_row3, text="Config File")
        config_file_label1.grid(row=0, column=0, sticky='e')

        self.config_file_browse_button = Button(frame_row3, text="...", command=self.browsefunc_sftp)
        self.config_file_browse_button.grid(row=0, column=3, sticky='w')

        self.config_file_entry_txt1 = StringVar()
        self.config_file_entry1 = Entry(frame_row3, textvariable=self.config_file_entry_txt1, width=105)
        config_file_path1 = os.path.join(funcs.get_config_file_path(), pm.default_config_file_name)
        try:
            x = open(config_file_path1)
        except:
            config_file_path1 = ""
        self.config_file_entry1.insert(END, config_file_path1)
        self.config_file_entry1.grid(row=0, column=1)

        self.config_file_entry_txt = StringVar()
        self.config_file_entry = Entry(frame_row0, textvariable=self.config_file_entry_txt, width=105)
        config_file_path = os.path.join(funcs.get_config_file_path(), pm.default_config_file_name)
        try:
            x = open(config_file_path)
        except:
            config_file_path = ""
        self.config_file_entry.insert(END, config_file_path)
        self.config_file_entry.grid(row=0, column=1)

        frame_buttons = Frame(frame_row1, borderwidth="2", relief="ridge")
        frame_buttons.grid(column=1, row=0)
        self.generate_button = Button(frame_buttons, text="Start", width=14, height=2, command=self.start)
        self.generate_button.grid(row=2, column=0)
        close_button = Button(frame_buttons, text="Exit", width=14, height=1, command=self.close)
        close_button.grid(row=3, column=0)

        frame_config_file_values = Frame(frame_row1, borderwidth="2", relief="ridge")
        frame_config_file_values.grid(column=0, row=0, sticky="w")

        frame_radiobuttons_values = Frame(frame_config_file_values, relief="ridge")
        frame_radiobuttons_values.grid(column=1, row=3, sticky="W")

        frame_buttons1 = Frame(frame_row4, borderwidth="2", relief="ridge")
        frame_buttons1.grid(column=1, row=0)
        self.generate_button = Button(frame_buttons1, text="Start", width=14, height=2, command=self.start_sftp)
        self.generate_button.grid(row=2, column=0)
        close_button = Button(frame_buttons1, text="Exit", width=14, height=1, command=self.close)
        close_button.grid(row=3, column=0)

        frame_config_file_values1 = Frame(frame_row4, borderwidth="2", relief="ridge")
        frame_config_file_values1.grid(column=0, row=0, sticky="w")

        self.get_config_file_values()
        frame_config_file_values_entry_width = 84

        files_names_label = Label(frame_config_file_values1, text="Files names")
        files_names_label.grid(row=0, column=0, sticky='e')

        self.text_field_files_names = StringVar()
        self.entry_field_files_names = Entry(frame_config_file_values1, textvariable=self.text_field_files_names,
                                             width=frame_config_file_values_entry_width)
        self.entry_field_files_names.grid(row=0, column=1, sticky="w")

        source_path_label = Label(frame_config_file_values1, text="Source path")
        source_path_label.grid(row=1, column=0, sticky='e')

        self.text_field_source_path = StringVar()
        self.entry_field_source_path = Entry(frame_config_file_values1, textvariable=self.text_field_source_path,
                                             width=frame_config_file_values_entry_width)
        self.entry_field_source_path.grid(row=1, column=1, sticky="w")

        destination_path_label = Label(frame_config_file_values1, text="Destination path")
        destination_path_label.grid(row=2, column=0, sticky='e')

        self.text_field_destination_path = StringVar()
        self.entry_field_destination_path = Entry(frame_config_file_values1,
                                                  textvariable=self.text_field_destination_path,
                                                  width=frame_config_file_values_entry_width)
        self.entry_field_destination_path.grid(row=2, column=1, sticky="w", columnspan=1)

        read_from_smx_label = Label(frame_config_file_values, text="SMXs Folder")
        read_from_smx_label.grid(row=0, column=0, sticky='e')

        self.text_field_read_from_smx = StringVar()
        self.entry_field_read_from_smx = Entry(frame_config_file_values, textvariable=self.text_field_read_from_smx,
                                               width=frame_config_file_values_entry_width)
        self.entry_field_read_from_smx.grid(row=0, column=1, sticky="w")

        output_path_label = Label(frame_config_file_values, text="Output Folder")
        output_path_label.grid(row=1, column=0, sticky='e')

        self.text_field_output_path = StringVar()
        self.entry_field_output_path = Entry(frame_config_file_values, textvariable=self.text_field_output_path,
                                             width=frame_config_file_values_entry_width)
        self.entry_field_output_path.grid(row=1, column=1, sticky="w")

        templates_path_label = Label(frame_config_file_values, text="Templates Folder")
        templates_path_label.grid(row=2, column=0, sticky='e')

        self.text_field_templates_path = StringVar()
        self.entry_field_templates_path = Entry(frame_config_file_values, textvariable=self.text_field_templates_path,
                                                width=frame_config_file_values_entry_width)
        self.entry_field_templates_path.grid(row=2, column=1, sticky="w", columnspan=1)

        self.excel_sheet = StringVar()
        scripts_generation_label = Label(frame_config_file_values, text="Project")
        scripts_generation_label.grid(row=3, column=0, sticky='e', columnspan=1)
        self.scripts_generation_flag = "Staging Tables"

        self.staging_tables_flag = Radiobutton(frame_radiobuttons_values, text="Staging Tables", value='Staging Tables'
                                               , variable=self.excel_sheet
                                               , command=self.toggle_excel_sheet_flag)
        self.staging_tables_flag.grid(row=1, column=0, sticky='w', columnspan=1)

        self.smx_flag = Radiobutton(frame_radiobuttons_values, text="SMX ", value='SMX'
                                    , variable=self.excel_sheet
                                    , command=self.toggle_excel_sheet_flag)
        self.smx_flag.grid(row=1, column=1, sticky='w', columnspan=1)

        self.staging_tables_flag.select()
        try:
            self.populate_config_file_values()
        except:
            self.populate_config_file_values_sftp()
        self.config_file_entry_txt.trace("w", self.refresh_config_file_values)

        thread0 = GenerateScriptsThread(0, "Thread-0", self)
        thread0.start()

        self.root.mainloop()