-
-
Save soleshka/dfa30128e33ae93f16a72e55253d5d97 to your computer and use it in GitHub Desktop.
| from tkinter import * | |
| from tkinter import ttk | |
| import datetime | |
| class HistoryTabC: | |
| """This is a container class for saving previously executed commands | |
| It contains a text widget which shows commands content as well as | |
| combo box containng the names of the commands | |
| Commands are being labeld with a name and suffix of the date """ | |
| def __init__(self,root): | |
| """initializer for this class""" | |
| self.root = root | |
| self.cmds_content_l = [] #[("name","content"),("name2","content2")] | |
| #contains the active cmd lable value | |
| self.cmds_names_v = StringVar() | |
| self.cmds_names_v.trace('w',self.combo_selected_cb) | |
| #text widget | |
| self.text = text = Text(root,width=50,height=20) | |
| self.test_l = ["a","b","c"] | |
| self.cmds_names_cmb = ttk.Combobox(root,values=self.test_l,textvariable=self.cmds_names_v,width=50) | |
| #load button command | |
| self.load_cmd_btn = Button(root,text="load cmd",command=self.exec_button_cb) | |
| self.del_cmd_btn = Button(root,text="del cmd",command=self.del_button_cb) | |
| self.text.pack() | |
| self.cmds_names_cmb.pack() | |
| self.load_cmd_btn.pack() | |
| self.del_cmd_btn.pack() | |
| def bind_load_cmd(self,load_cb): | |
| """binded to external callback which in turn | |
| catches the content of the current active command""" | |
| self.load_cmd_btn.config(command=load_cb) | |
| def exec_button_cb(self): | |
| """This is a call back fired when load command | |
| button is clicked . It will set..?""" | |
| self.get_active_cmd() | |
| def del_button_cb(self): | |
| """call back for delete command. | |
| removes the spesified command from | |
| combo and it context""" | |
| name = self.cmds_names_v.get() | |
| # in case no more commands in list | |
| if name: | |
| indx = [x for x in range(len(self.cmds_content_l)) if self.cmds_content_l[x][0] == name] | |
| self.cmds_content_l.pop(indx[0]) | |
| self.update_combo() | |
| def update_combo(self): | |
| """updates combo and active cmd with | |
| full self.get_cmds_name list""" | |
| self.cmds_names_cmb.config(values=self.get_cmds_names()) | |
| if not len(self.cmds_content_l): | |
| self.cmds_names_v.set("") | |
| else: | |
| self.cmds_names_v.set(self.cmds_content_l[-1][0]) | |
| def combo_selected_cb(self,*args): | |
| """call back for updating text container | |
| with command content based on commbo active | |
| label""" | |
| name = self.cmds_names_v.get() | |
| text = [y for x,y in self.cmds_content_l if x == name] | |
| if not text: | |
| self.update_text_content("") | |
| else: | |
| self.update_text_content(text[0]) | |
| #self.update_combo() # not sure why this was here | |
| def get_active_cmd(self): | |
| """Returns the content of the current active command. i.# -*- coding: utf-8 -*- | |
| the content of the self.cmds_content_l[self.cmds_names_v.get()]""" | |
| name = self.cmds_names_v.get() | |
| #print([y for x,y in self.cmds_content_l if x == name]) | |
| return [y for x,y in self.cmds_content_l if x == name] | |
| def add_history_cmd(self,name,content,suffix=""): | |
| """Adds new command label to combo box | |
| with suffix of date and hour . Updates the content | |
| list with the text and cmd label. use @date to add date""" | |
| #create suffix | |
| if suffix == "@date": | |
| now = datetime.datetime.now() | |
| suffix = str(now.day)+str(now.month)+str(now.year)+"_"+str(now.hour)+":"+str(now.minute) | |
| #update command content list | |
| self.update_cmds_content((name+suffix,content)) | |
| #update new values for the combo box | |
| self.cmds_names_cmb['values'] =self.get_cmds_names() | |
| def update_cmds_content(self,name_content_tpl): | |
| """adds new entry to commands content list """ | |
| self.cmds_content_l.append(name_content_tpl) | |
| self.update_combo() | |
| def get_cmds_names(self): | |
| """retrievs all command cmds_names | |
| existing in combo box""" | |
| return [x for x,y in self.cmds_content_l] | |
| def get_cmds_w_content(self): | |
| """Returns commands and content list of tuples""" | |
| return self.cmds_content_l | |
| def update_text_content(self,text_content): | |
| """Deletes previous text content and inserts | |
| new content """ | |
| self.text.delete('1.0','end') | |
| self.text.insert('1.0',text_content) | |
| def dummy(): | |
| print("i am in dummy") | |
| def main(): | |
| root = Tk() | |
| cls1 = HistoryTabC(root) | |
| cls1.add_history_cmd("name","content") | |
| cls1.add_history_cmd("name1","content1") | |
| cls1.add_history_cmd("name2","content2") | |
| cls1.bind_load_cmd(dummy) | |
| root.mainloop() | |
| if __name__=='__main__':main() | |
| import numpy as np | |
| import os | |
| class SaveContentC: | |
| def __init__(self,filename): | |
| self.file = filename+".npy" | |
| def append(dic): | |
| """ | |
| Appends dictionary dic to active file | |
| """ | |
| pass | |
| def save(self,dic): | |
| """ | |
| Saves the content of the dic into file | |
| overrides the content if was existing before | |
| """ | |
| np.save(self.file,dic) | |
| def load_few(self,entries_l): | |
| """ | |
| Recieves entries_l with commands labels. | |
| Returns dictionary with entries which exist in the file | |
| Entries which do not exist are not in the returned dictionary | |
| """ | |
| if os.path.isfile(self.file): | |
| dir = np.load(self.file) | |
| dic_r = dict() | |
| for entry in entries_l: | |
| if entry in dir[()].keys(): | |
| dic_r[entry] = dir[()][entry] | |
| return dic_r | |
| else: | |
| print("[Py-Warning]: Saved content file does not exist") | |
| return None | |
| def load_all(self): | |
| """ | |
| returns all the content of the file. | |
| Warning if file does not exist. return None | |
| """ | |
| if os.path.isfile(self.file): | |
| dir = np.load(self.file) | |
| #print (dir[()].keys()) | |
| #print (dir[()]) | |
| return dir[()] | |
| else: | |
| print("[Py-Warning]: Saved content file does not exist") | |
| return None | |
| # for cmd_indx in range(len(cmds_text_l)): | |
| # cmd_lable = cmds_text_l[cmd_indx][0]["text"] | |
| # if cmd_lable in dir[()].keys(): | |
| # cmds_text_l[cmd_indx][1].insert('insert'," "+dir[()][cmd_lable]) | |
| def main(): | |
| dic1 = {'cmd0': 'setenv SOMETHING 56 - changed', 'clean': 'changed',\ | |
| 'compile': 'vlogan -full64 module.sv', 'elab': 'vcs -full64 -top top', 'run': 'simv -verdi changed'} | |
| sav1 = SaveContentC("run_test_commands_do_not_remove.txt") | |
| sav1.save(dic1) | |
| print (sav1.load_all()) | |
| print (sav1.load_few(['compile','cmd0','whatever'])) | |
| print (sav1.load_few([])) | |
| if __name__=='__main__': | |
| main() |
| #!/global/freeware/Linux/RHEL6/python-3.6.3/bin/python | |
| from tkinter import * | |
| from tkinter import messagebox | |
| from tkinter import ttk | |
| from subprocess import call | |
| import subprocess | |
| import numpy as np | |
| import os.path | |
| import history_tab | |
| import save_content | |
| import os | |
| import makefile | |
| import menubar | |
| import threading | |
| import time | |
| import tools_setup | |
| import tools_setup_gui | |
| """ | |
| Debug | |
| Architeture | |
| Reuse | |
| Interface | |
| Application | |
| """ | |
| class PanedDEsignC: | |
| def __init__(self,root,cmds_info,mouse_text_click_cb): | |
| self.frame_list = list() | |
| self.texts_list = list() | |
| self.painwindow = PanedWindow(root,orient=VERTICAL,relief=RAISED,background=BG_COLOR) | |
| #self.painwindow = PanedWindow(root,orient=VERTICAL,cursor='spider',relief=RAISED,background=BG_COLOR) | |
| self.painwindow.pack(fill=BOTH,expand=True) | |
| #print(self.painwindow.config()) | |
| for indx in range(len(cmds_info)): | |
| #print(indx) | |
| self.frame_list.append(ttk.LabelFrame(self.painwindow,text=cmds_info[indx][0])) | |
| self.frame_list[indx].config(relief=SUNKEN) | |
| self.frame_list[indx].pack() | |
| self.painwindow.add(self.frame_list[indx]) | |
| text = Text(self.frame_list[indx],height=cmds_info[indx][2]) | |
| text.insert('insert', cmds_info[indx][4]) | |
| text.pack(side=LEFT,fill=BOTH,expand=True)#grid(row=0,column=0,sticky='nwse') | |
| self.texts_list.append((self.frame_list[indx],text)) | |
| scroll_bar = Scrollbar(self.frame_list[indx],orient=VERTICAL,command=text.yview) | |
| scroll_bar.pack(side=LEFT,anchor="w")#grid(row=0,column=1) | |
| text.config(yscrollcommand=scroll_bar.set) | |
| def get_frame_list(self): | |
| return self.texts_list | |
| # def add_frame(self,text): | |
| # """this will create additional frame with some default parameters""" | |
| # self.frame_list.append(ttk.LabelFrame(self.painwindow,text=text)) | |
| # self.frame_list[len(self.frame_list)-1].config(height=20,width=20,relief=SUNKEN) | |
| # self.frame_list[len(self.frame_list)-1].pack() | |
| # self.painwindow.add(self.frame_list[len(self.frame_list)-1],weight=1) | |
| FILE_NAME ="run_test_commands_do_not_remove.txt" | |
| CMD_TEXT_SIZE_X =70 | |
| CMD_TEXT_SIZE_Y =3 | |
| CONTROL_FRAME_X = 100 | |
| cmds_info = [ ("cmd0",CMD_TEXT_SIZE_X,CMD_TEXT_SIZE_Y,1,"setenv PATH;\nsetenv PATH $VCS_HOME/bin:$PATH"), | |
| ("clean",CMD_TEXT_SIZE_X,CMD_TEXT_SIZE_Y-2,1,"rm -rf AN* 64* csrc simv* work.lib* work/*"), | |
| ("compile",CMD_TEXT_SIZE_X,CMD_TEXT_SIZE_Y,1,"vlogan -kdb -full64 ;\nvhdlan -kdb -full64"), | |
| ("elab",CMD_TEXT_SIZE_X,CMD_TEXT_SIZE_Y,1,"vcs -full64 -lca -kdb -debug_access+all -top top;"), | |
| ("run",CMD_TEXT_SIZE_X,CMD_TEXT_SIZE_Y-1,1,"simv -verdi; ")] | |
| COMPILE_FLAGS = ["-kdb","-full64","-work","+define+<macro>",\ | |
| "-f file.f","-q","-l compile.log","-nc",\ | |
| "-timescale=1ns/1ps","+incdir+<incdir>", | |
| "+v2k","+notimingchecks","+nospecify","-y <libdir>",\ | |
| "-v <libfile>"] | |
| ELAB_FLAGS = ["-kdb","-full64","-lca","-sverilog","-top","-partcomp",\ | |
| "+optconfig","-g <generic.f>","-P pli.tab","-xlrm","-o simv"\ | |
| "-debug_accee+all","-debug_pp","-debug_access+f","-debug",\ | |
| "-cm","-cm+line+assert+fsm+cond","-cm_dir cov.dir","-cm_hier\ | |
| hier.cfg","-l elab.log",] | |
| RUN_FLAGS = ["-gui=verdi","-gui","-ucli -i ucli.cmd","-ucli", | |
| "+fsdb+force","+fsdb+delta"\ | |
| "-cm","-cm+line+assert+fsm+cond"] | |
| ALL_FLAGS = COMPILE_FLAGS+ELAB_FLAGS+RUN_FLAGS | |
| NUM_OF_CMDS = len(cmds_info) | |
| FLAG_DEFAULT = "pick flag" | |
| BG_COLOR ='#e1d8b9' | |
| #'#e0f8ff' | |
| #'#82B1FF' | |
| #'#d6b4e7' | |
| #'#c18ed0' | |
| #'#793698' - purple too bright | |
| #'#d6b4e7' - purple light | |
| #'#e1d8b9' - bezh | |
| root = Tk() | |
| root.title("Tester@DaRiA (C)Oleg Greenberg ->"+os.getcwd()) | |
| #root.configure(bg='orange') | |
| cmds_text_l = list() | |
| cmds_var = StringVar() | |
| vcs_ver_var = StringVar() | |
| verdi_ver_var = StringVar() | |
| add_flag_var = StringVar() | |
| notebk = ttk.Notebook(root) | |
| main_frame = Frame(root,padx=10,pady=10,background=BG_COLOR) | |
| history_frame = Frame(root,padx=10,pady=10,background=BG_COLOR) | |
| info_frame = Frame(root,padx=10,pady=10,background=BG_COLOR) | |
| control_frame = LabelFrame(main_frame,background=BG_COLOR,text="Configuartions ") | |
| #history tab container classsc | |
| hist_tab = history_tab.HistoryTabC(history_frame) | |
| #save content container class | |
| save_contnt = save_content.SaveContentC("run_test_commands_do_not_remove.txt") | |
| #instead of set_vcs_verdi | |
| path_constructor = {"vcsmx":([tools_setup.fs_release_vcsmx_pathes,tools_setup.vcsmx_global_pathes,tools_setup.vcsmx_snps_apps_pathes],"VCS_HOME") ,"verdi":([tools_setup.verdi_global_pathes ,tools_setup.verdi_snps_apps_pathes,tools_setup.verdi_remote_vtgimages],"VERDI_HOME"),"xa":([tools_setup.xa_global_pathes],"XA_HOME")} | |
| tool_setup = tools_setup.ToolC(path_constructor) | |
| tools_to_add_d = dict() | |
| tool_paths_d = dict() | |
| t_gui = tools_setup_gui.ToolsSetupGuiC() | |
| added_tools_versions_label = Label(info_frame,text="Added tools : ",height=10,bg='#e1FFb9') | |
| added_tools_versions_label.pack() | |
| def center_window(root,width=300, height=200): | |
| # get screen width and height | |
| screen_width = root.winfo_screenwidth() | |
| screen_height = root.winfo_screenheight() | |
| # calculate position x and y coordinates | |
| x = screen_width - width | |
| y = 0#screen_height - height | |
| root.geometry('%dx%d+%d+%d' % (width, height, x, y)) | |
| def create_cmd_choice_radio_btn(root,cmds_info,start_row,start_col,cmd_var): | |
| """ | |
| returns list of radio buttons ocntaining commands labels | |
| conected to the cmds_var String variable | |
| """ | |
| cmds_radio_btn_l = list() | |
| for cmds_indx in range(len(cmds_info)): | |
| #cmds_combo_l[cmds_indx].grid(row=start_row+cmds_indx,column=0) | |
| cmds_radio_btn_l.append(Radiobutton(root,background=BG_COLOR,text=cmds_info[cmds_indx][0],value=cmds_info[cmds_indx][0],variable=cmd_var)) | |
| cmds_radio_btn_l[cmds_indx].grid(row=start_row+cmds_indx,column=start_col,sticky="wn",ipadx='5') | |
| #append "all" command | |
| cmds_radio_btn_l.append(Radiobutton(root,text="all",value="all",variable=cmd_var,background=BG_COLOR)) | |
| cmds_radio_btn_l[len(cmds_info)].grid(row=start_row+len(cmds_info),column=start_col,sticky="wn",ipadx='5') | |
| return cmds_radio_btn_l | |
| def get_cmds_text_content(cmd_label): | |
| """returns text for cmd's name cmd_label""" | |
| #This is a list with one item | |
| cmd_indx = [x for x,y in enumerate(cmds_text_l) if y[0]["text"]== cmd_label ] | |
| text = cmds_text_l[cmd_indx[0]][1].get('1.0','end') | |
| return text | |
| def get_cmds_indx_list(cmd_label): | |
| """return index of a spesific command in command list""" | |
| return [x for x,y in enumerate(cmds_text_l) if y[0]["text"]== cmd_label ] | |
| def get_cmds_labels_list(cmds_text_l): | |
| return [y[0]["text"] for x,y in enumerate(cmds_text_l) ] | |
| def exec_save_cmd_cb(saved_cmd_text_suffix): | |
| global hist_tab,cmds_var,cmds_text_l | |
| cmd_label = cmds_var.get() | |
| #cmd = cmds_text_l[cmd_indx][1].get('1.0','end') | |
| if cmd_label != "all": | |
| text = get_cmds_text_content(cmd_label) | |
| #to prevent saving empty commands | |
| if text.strip()!="": | |
| prefix = saved_cmd_text_suffix.get().strip() | |
| if not prefix: | |
| prefix = "@date" | |
| hist_tab.add_history_cmd(cmd_label,text,prefix) | |
| else:#save all commands #TODO | |
| pass | |
| def add_flags_cb(cmd_text_l,cmds_var,add_flag_var): | |
| flag_str = add_flag_var.get() | |
| #no action when all is used | |
| if cmds_var.get() != "all": | |
| if flag_str:#prevent empty string | |
| cmds_text_l[get_cmds_indx_list(cmds_var.get())[0]][1].insert('insert'," "+flag_str) | |
| def ordered_thread(task,task_args): | |
| t = threading.Thread(target= task, name="execute command",args=task_args) | |
| t.start() | |
| #t.join() to do a blocking thread | |
| def exec_button_cb(): | |
| global cmds_var, cmds_text_l | |
| cmd_label = cmds_var.get() | |
| print("These are the tools to add ",tools_to_add_d) | |
| #The use of hardcoded VCS_HOME & and other homes is a wa , because | |
| #everything here is written through the as*. In proper coding one | |
| #needs to retrieve these based on the tool path from the too_setup | |
| #the home variabels are already there.When adding new tool this WA needs to be updated | |
| if not len(tools_to_add_d): | |
| print("[py-Warning]: Please add at least one Tool with Add Tool button") | |
| messagebox.showwarning("Warning","Please set at least one tool") | |
| return | |
| for tool in tools_to_add_d.keys(): | |
| home = "IAMBADLYSET_HOME" | |
| if tool == "vcsmx": | |
| home = "VCS_HOME" | |
| elif tool == "verdi": | |
| home = "VERDI_HOME" | |
| elif tool == "xa": | |
| home = "XA_HOME" | |
| tool_setup.setenv_tool_home(tool,home,tools_to_add_d[tool]) | |
| if cmd_label == "all": | |
| #execute_command(list(range(len(cmds_text_l)))) | |
| args_v = list(range(len(cmds_text_l))) | |
| else: | |
| y = get_cmds_indx_list(cmd_label)#[x for x,y in enumerate(cmds_text_l) if y[0]["text"]== cmd_label ] | |
| #print("[Py-Info]:Exec was pressed . Executing",y,cmd_label) | |
| #execute_command(y) | |
| args_v = get_cmds_indx_list(cmd_label) | |
| #print(args_v) | |
| ordered_thread(execute_command,[args_v]) | |
| def create_combo(root,values,cmds_info,vcs_ver_var,start_row,start_col): | |
| vcs_verscombo=ttk.Combobox(root,values=values,width=25,textvariable=vcs_ver_var,background=BG_COLOR) | |
| vcs_verscombo.grid(row=start_row,column=start_col,sticky='w') | |
| return vcs_verscombo | |
| def create_exec_button(root,name,callback,start_row,start_col,stick,bg=BG_COLOR,fg='black'): | |
| exec_button = Button(root,text=name,command=callback,width=6,bg=bg,fg=fg) | |
| exec_button.grid(row=start_row,column=start_col,sticky=stick) | |
| return exec_button | |
| def create_label(**kwargs): | |
| #root,text,height,row,column,sticky,bg=BG_COLOR | |
| root = kwargs.get("root",None) | |
| text = kwargs.get("text","") | |
| height = kwargs.get("hg",1) | |
| row = kwargs.get("row",0) | |
| column = kwargs.get("col",0) | |
| sticky = kwargs.get("sticky",0) | |
| bg = kwargs.get("bg","red") | |
| columnspan = kwargs.get("colspan",None) | |
| label = Label(root,text=text,height=height,background=bg) | |
| label.grid(row=row,column=column,sticky=sticky,columnspan=columnspan) | |
| return label | |
| def load_from_file(cmds_text_l,save_contnt): | |
| global hist_tab,added_tools_versions_label,t_gui,tools_to_add_d | |
| """onstartup read file conent and insert into text ids | |
| both in the main frame and history frame. History frame will | |
| get all the commands including duplicaates of main frame. for simplicity""" | |
| #main frame commands | |
| cmds_content_d = save_contnt.load_few(get_cmds_labels_list(cmds_text_l)) | |
| if cmds_content_d : | |
| for label,content in cmds_content_d.items(): | |
| cmds_text_l[get_cmds_indx_list(label)[0]][1].delete('1.0',END) | |
| cmds_text_l[get_cmds_indx_list(label)[0]][1].insert('insert'," "+content) | |
| tools_labels_d =save_contnt.load_few(["tools"]) | |
| tools_to_add_d = save_contnt.load_few(tools_labels_d['tools']) #save_contnt.load_few['tools'] - contains saved tools labels | |
| print("[py-Info]: Adding the following tools:\n",tools_labels_d,tools_to_add_d) | |
| text = ''.join("{} : {}\n".format(key,val) \ | |
| for (key,val) in tools_to_add_d.items()) | |
| added_tools_versions_label['text'] = text | |
| for tool in tools_to_add_d.keys(): | |
| t_gui.add_version_external(tool,tools_to_add_d[tool]) | |
| #history frame commands | |
| cmds_content_hist_d = save_contnt.load_all() | |
| for label,content in cmds_content_hist_d.items(): | |
| #TODO exlude the tools from history!!!! | |
| if label not in [cmds_content_d.keys(),tools_labels_d.keys(),tools_to_add_d.keys()]:# check if command not in main frame | |
| hist_tab.add_history_cmd(label,content) | |
| def save_to_file(): | |
| """On program exit save to file command texts content and insert into FILE_NAME""" | |
| global save_contnt,hist_tab,t_gui | |
| dic = dict() | |
| #1. get main frame commands data to save | |
| for cmd_indx in range(len(cmds_text_l)): | |
| #cmds_text_l[cmd_indx][1] : is the text pointer | |
| dic[cmds_text_l[cmd_indx][0]["text"]] = cmds_text_l[cmd_indx][1].get('1.0',END).strip() | |
| #2. get history data | |
| hist_dic = hist_tab.get_cmds_w_content() | |
| #get used tools | |
| tools_d = t_gui.get_added_versions() | |
| # this is required to retrieve the saved tools labels | |
| saved_tools_d = dict() | |
| saved_tools_d["tools"] = list(tools_d.keys()) | |
| #merge dictionaries | |
| dic = {**dic,**dict(hist_dic),**dict(tools_d),**dict(saved_tools_d)} | |
| save_contnt.save(dic) | |
| def onClose(): | |
| if messagebox.askokcancel("Quit", "Do you want to quit?"): | |
| save_to_file() | |
| root.destroy() | |
| def execute_command(cmds_to_exe_l): | |
| global tool_setup | |
| """Recievs a list of cmd indexes in cmd_text_l to execute. | |
| Excecutes the commands into shell maintaining list order | |
| example [0,1,3] : cmd0 ,clean ,elab""" | |
| for cmd_indx in cmds_to_exe_l: | |
| cmd = cmds_text_l[cmd_indx][1].get('1.0','end') | |
| cmd_l = parse_text2commands(''.join(cmd.rstrip("\n"))) | |
| for itm in cmd_l: | |
| itm = itm.rstrip() | |
| if itm:# to remove the empty commands caused by parse_text2commands | |
| itm1 = " ".join(itm.split()) # to removedouble spaces /t /n | |
| print("\n\t[Py-Info]:\t\t Start execution ") | |
| print("\t[Py-Info]:\t{}\n ".format(itm1)) | |
| if "setenv" in itm1: | |
| print('[Py-Info]:Command contains setenv:',itm1) | |
| if ' ' not in [itm1.split(' ')[1],itm1.split(' ')[2]]: | |
| tool_setup.setenv_var(itm1.split(' ')[1],itm1.split(' ')[2]) | |
| else: | |
| call(itm1,shell=True) | |
| print("\n\t[Py-Info]:\t\t End execution ") | |
| print("\t[Py-Info]:\t{}\n ".format(itm1)) | |
| def parse_text2commands(text): | |
| """divides text to commands usingthe semicolumn ; seperator | |
| returns list of commands . """ | |
| #print(text) | |
| return text.split(';') | |
| # def configure_grid(root,cmd_info): | |
| # for cmd in range(len(cmd_info)): | |
| # root.rowconfigure(cmd,weight=cmd_info[cmd][3],minsize=40) | |
| # root.columnconfigure(0,weight=cmd_info[cmd][3],minsize=300) | |
| # #for control frame | |
| # root.rowconfigure(len(cmd_info),weight=3) | |
| def root_configs(root): | |
| global cmds_info | |
| root.protocol("WM_DELETE_WINDOW", onClose) | |
| #this will set the min size | |
| #root.minsize(420,300) | |
| #root.columnconfigure(0,weight=1) | |
| #root.columnconfigure(1,weight=1) | |
| #root.rowconfigure(0,weight=1) | |
| #root.rowconfigure(1,weight=1) | |
| #configure_grid(root,cmds_info) | |
| root.mainloop() | |
| def on_mouse_click_cmd_cb(cmd_label): | |
| """gets cmd label on which the left click wasexecuted""" | |
| str1 = cmd_label | |
| #print("Woooooohhhuuuuuu:",str1) | |
| def bind_texts(cmds_text_l,callback): | |
| """binds texsts (frame,text) to spesific callback""" | |
| for itm in cmds_text_l: | |
| widg = itm[1] | |
| cmd_label = itm[0]["text"] | |
| print (cmd_label) #TODO there is a problem here referencing the same last adress forthe parameter to cb | |
| widg.bind('<1>',lambda : on_mouse_click_cmd_cb(cmd_label)) | |
| def hist_load_command_cb(): | |
| """this method is called when history .load cmd. is issued | |
| it updates the current active commnd text. message for | |
| confirmation pops up """ | |
| global cmds_var,notebk | |
| print("[py-Info]:current command to overwrite:",cmds_var.get()) | |
| if cmds_var.get() != "all": | |
| notebk.select(main_frame) #set focus on main frame to see the command | |
| if messagebox.askokcancel("Overwrite", "Do you want to overwrite - {} - content?".format(cmds_var.get())): | |
| cmds_text_l[get_cmds_indx_list(cmds_var.get())[0]][1].delete('1.0',END) | |
| content = hist_tab.get_active_cmd()[0] | |
| cmds_text_l[get_cmds_indx_list(cmds_var.get())[0]][1].insert('insert',content) | |
| def create_makefile(): | |
| """creates file based on commands . Adds export to | |
| vcs and verdi versions if this are set""" | |
| global cmds_text_l | |
| targets_l = list() | |
| all_cmds = "" | |
| for cmd_indx in range(len(cmds_text_l)): | |
| cmd_label=cmds_text_l[cmd_indx][0]["text"] | |
| cmd_content=cmds_text_l[cmd_indx][1].get('1.0','end') | |
| print(cmd_label,cmd_content) | |
| targets_l.append((cmd_label,cmd_content)) | |
| all_cmds += cmd_label + " " | |
| targets_l.insert(0,("all",all_cmds)) | |
| mk = makefile.MakefileC("Makefile_DaRiA",["all"]) | |
| #again really bad coding style | |
| exp_tool_d =dict() | |
| for_path_s = "" | |
| for tool in tools_to_add_d.keys(): | |
| home = "IAMBADLYSET_HOME" | |
| if tool == "vcsmx": | |
| home = "VCS_HOME" | |
| elif tool == "verdi": | |
| home = "VERDI_HOME" | |
| elif tool == "xa": | |
| home = "XA_HOME" | |
| exp_tool_d[home] = tools_to_add_d[tool] | |
| for_path_s += "$("+home+")/bin:" | |
| exp_tool_d["PATH"] = for_path_s+":$(PATH)" | |
| mk.export_setenv_vars(exp_tool_d) | |
| mk.create_makefile(targets_l) | |
| def add_tools_versions_to_label(t_gui,container_label): | |
| """adds the added tools in tool_gui_setup to the label under the info tab""" | |
| global tools_to_add_d | |
| t_gui.add_version_button_cb() | |
| tools_to_add_d = t_gui.get_added_versions() | |
| print("[py-Info]: Adding the following tools:\n",tools_to_add_d) | |
| text = ''.join("{} : {}\n".format(key,val) \ | |
| for (key,val) in tools_to_add_d.items()) | |
| container_label['text'] = text | |
| def main(): | |
| global root,cmds_var,cmds_text_l,notebk,main_frame,history_frame,save_contnt, tool_paths_d ,t_gui,added_tools_versions_label | |
| #center_window(root,500, 600) | |
| notebk.pack(fill=BOTH)#this makes the main view fully streched | |
| main_frame.pack() | |
| history_frame.pack() | |
| info_frame.pack() | |
| ttk.Style().configure("TNotebook", background=BG_COLOR) | |
| hist_tab.bind_load_cmd(hist_load_command_cb) | |
| #main_frame.bind('<1>',on_mouse_click_cmd_cb) | |
| control_frame.pack(fill=BOTH,expand=True) | |
| design = PanedDEsignC(main_frame,cmds_info,on_mouse_click_cmd_cb) | |
| cmds_text_l = design.get_frame_list() | |
| #bind_texts(cmds_text_l,on_mouse_click_cmd_cb) | |
| # widg = design.get_widget() | |
| # widg.bind('<1>',on_mouse_click_cmd_cb) | |
| #menubar | |
| menu = menubar.MenubarC(root,create_makefile) | |
| #new implementation | |
| vcsmx_ids_new = tool_setup.get_tool_paths("vcsmx") | |
| verdi_ids_new = tool_setup.get_tool_paths("verdi") | |
| #cmd radio buttons not to resize | |
| #all the rest in control frame to resize | |
| control_frame.rowconfigure(0,weight=1) | |
| control_frame.rowconfigure(1,weight=1) | |
| control_frame.rowconfigure(2,weight=1) | |
| control_frame.rowconfigure(3,weight=1) | |
| control_frame.columnconfigure(0,weight=0) | |
| control_frame.columnconfigure(1,weight=1) | |
| control_frame.columnconfigure(2,weight=1) | |
| control_frame.columnconfigure(3,weight=1) | |
| main_frame.rowconfigure(0,weight=1) | |
| main_frame.rowconfigure(1,weight=1) | |
| #main_frame.rowconfigure(3,weight=1) | |
| #main_frame.rowconfigure(2,weight=1) | |
| #main_frame.rowconfigure(4,weight=1) | |
| main_frame.columnconfigure(0,weight=1) | |
| main_frame.columnconfigure(1,weight=1) | |
| #main_frame.columnconfigure(2,weight=1) | |
| #main_frame.columnconfigure(3,weight=1) | |
| #main_frame.columnconfigure(4,weight=1) | |
| cmds_var.set(cmds_info[0][0]) | |
| grid_row = NUM_OF_CMDS | |
| grid_col = 0 | |
| cmds_radio_btn_l = create_cmd_choice_radio_btn(control_frame,cmds_info,grid_row,grid_col,cmds_var) | |
| grid_col +=1 | |
| tool_paths_d['vcsmx'] = tool_setup.get_tool_paths('vcsmx') | |
| tool_paths_d['verdi'] = tool_setup.get_tool_paths('verdi') | |
| tool_paths_d['xa'] = tool_setup.get_tool_paths('xa') | |
| t_gui.init_me(control_frame,tool_paths_d,grid_col,grid_row,BG_COLOR) | |
| grid_col +=1 | |
| runc_cmd_btn = create_exec_button(control_frame,"Execute",\ | |
| exec_button_cb,grid_row,3,"nwes",'green','white') | |
| grid_row +=2 | |
| grid_col +=1 | |
| add_tool_button = Button(control_frame,text="Add Tool",bg=BG_COLOR,fg='white') | |
| add_tool_button.grid(row=grid_row,column=grid_col,sticky='nwe ') | |
| grid_col -=2 | |
| grid_row +=1 | |
| label_add_flags = create_label(root=control_frame,text="Add flags: ", | |
| hg=1,row=grid_row,col=grid_col,sticky='w', | |
| bg=BG_COLOR) | |
| grid_col +=1 | |
| add_flags_combo = create_combo(control_frame,ALL_FLAGS,cmds_info,\ | |
| add_flag_var,grid_row,grid_col) | |
| grid_col +=1 | |
| add_flgs_btn = create_exec_button(control_frame,"Add flags",\ | |
| lambda: add_flags_cb(cmds_text_l,cmds_var,\ | |
| add_flag_var),grid_row,3,"wsne",BG_COLOR,'white') | |
| grid_row +=1 | |
| grid_col -=2 | |
| label_saved_cmd_suffix = create_label(root=control_frame,text="Command save suffix: ", | |
| hg=1,row=grid_row,col=grid_col,sticky='w', | |
| bg=BG_COLOR) | |
| grid_col +=1 | |
| saved_cmd_suffix_entr = Entry(control_frame,bg="white") | |
| saved_cmd_suffix_entr.grid(row=grid_row,column=grid_col,sticky='w') | |
| grid_col +=1 | |
| save_cmd_btn = create_exec_button(control_frame,"Save",lambda: \ | |
| exec_save_cmd_cb(saved_cmd_suffix_entr),grid_row,3,"wnse",BG_COLOR,'white') | |
| grid_row +=3 | |
| grid_col -=3 | |
| add_tool_button.configure(command = lambda: add_tools_versions_to_label(t_gui,added_tools_versions_label)) | |
| load_from_file(cmds_text_l,save_contnt) | |
| notebk.add(main_frame,text="main",state='normal') | |
| notebk.add(history_frame,text="history",state='normal') | |
| notebk.add(info_frame,text="Info",state='normal') | |
| s = ttk.Style() | |
| s.configure('.',background=BG_COLOR) | |
| root.config(menu = menu.get_menu()) | |
| root_configs(root) | |
| if __name__=='__main__':main() |
| import numpy as np | |
| import os | |
| class SaveContentC: | |
| def __init__(self,filename): | |
| self.file = filename+".npy" | |
| def append(dic): | |
| """ | |
| Appends dictionary dic to active file | |
| """ | |
| pass | |
| def save(self,dic): | |
| """ | |
| Saves the content of the dic into file | |
| overrides the content if was existing before | |
| """ | |
| np.save(self.file,dic) | |
| def load_few(self,entries_l): | |
| """ | |
| Recieves entries_l with commands labels. | |
| Returns dictionary with entries which exist in the file | |
| Entries which do not exist are not in the returned dictionary | |
| """ | |
| if os.path.isfile(self.file): | |
| dir = np.load(self.file) | |
| dic_r = dict() | |
| for entry in entries_l: | |
| if entry in dir[()].keys(): | |
| dic_r[entry] = dir[()][entry] | |
| return dic_r | |
| else: | |
| print("[Py-Warning]: Saved content file does not exist") | |
| return None | |
| def load_all(self): | |
| """ | |
| returns all the content of the file. | |
| Warning if file does not exist. return None | |
| """ | |
| if os.path.isfile(self.file): | |
| dir = np.load(self.file) | |
| #print (dir[()].keys()) | |
| #print (dir[()]) | |
| return dir[()] | |
| else: | |
| print("[Py-Warning]: Saved content file does not exist") | |
| return None | |
| # for cmd_indx in range(len(cmds_text_l)): | |
| # cmd_lable = cmds_text_l[cmd_indx][0]["text"] | |
| # if cmd_lable in dir[()].keys(): | |
| # cmds_text_l[cmd_indx][1].insert('insert'," "+dir[()][cmd_lable]) | |
| def main(): | |
| dic1 = {'cmd0': 'setenv SOMETHING 56 - changed', 'clean': 'changed',\ | |
| 'compile': 'vlogan -full64 module.sv', 'elab': 'vcs -full64 -top top', 'run': 'simv -verdi changed'} | |
| sav1 = SaveContentC("run_test_commands_do_not_remove.txt") | |
| sav1.save(dic1) | |
| print (sav1.load_all()) | |
| print (sav1.load_few(['compile','cmd0','whatever'])) | |
| print (sav1.load_few([])) | |
| if __name__=='__main__': | |
| main() |
| #!/global/freeware/Linux/RHEL6/python-3.6.3/bin/python | |
| from tkinter import * | |
| from tkinter import messagebox | |
| from tkinter import ttk | |
| import fnmatch | |
| import re | |
| # class InfoC(): | |
| # def __init__(self): | |
| # pass | |
| # | |
| # def add_content(self,label,text): | |
| # pass | |
| # | |
| # def create_label(**kwargs): | |
| # #root,text,height,row,column,sticky,bg=BG_COLOR | |
| # root = kwargs.get("root",None) | |
| # text = kwargs.get("text","") | |
| # height = kwargs.get("hg",1) | |
| # bg = kwargs.get("bg","red") | |
| # | |
| # label = Label(root,text=text,height=height,background=bg) | |
| # label.pack() | |
| # return label | |
| class ToolsSetupGuiC(): | |
| def __init__(self): | |
| pass | |
| def init_me(self,root,tools_paths,col=0,row=0,bg_color="#e1d8b9"): | |
| """Ths should be in init but as the code written through the as* this build me is required""" | |
| self.tools_paths = tools_paths | |
| start_col = col | |
| start_row = row | |
| self.tool_label = Label(root,text="Tool:",bg=bg_color) | |
| self.tool_label.grid(row=start_row,column=start_col,sticky='w',padx = 5 , pady = (5,0)) | |
| start_col +=1 | |
| #spin box to hold the tool types | |
| self.tools_var = StringVar() | |
| self.tools_spin = Spinbox(root,values=list(self.tools_paths.keys()),\ | |
| textvariable = self.tools_var,font =10,\ | |
| command=lambda :self.tools_spin_change_cb(),state="readonly") | |
| self.tools_spin.grid(row=start_row,column=start_col,sticky='w',padx = 5) | |
| start_row+=1 | |
| start_col -=1 | |
| print(start_col ) | |
| self.filter_label = Label(root,text="Filter versions(regex):",bg=bg_color) | |
| self.filter_label.grid(row=start_row,column=start_col,sticky='w',\ | |
| padx = 5 , pady = (5,0)) | |
| start_col +=1 | |
| # entry to hold regex expression patten | |
| self.filter_entry = Entry(root,font=("Courier",11,'bold')) | |
| self.filter_entry.grid(row=start_row,column=start_col,sticky='w',padx = 5) | |
| self.filter_entry.insert(0,".*global.*(17.12).*") | |
| start_row+=1 | |
| start_col-=1 | |
| # combot o hold all the versions for the same tool | |
| self.version_var= StringVar() | |
| self.version_combo=ttk.Combobox(root,values=self.tools_paths[self.tools_var.get()],\ | |
| textvariable=self.version_var,state="readonly") | |
| self.version_combo.grid(row=start_row,column=start_col,columnspan=2,\ | |
| sticky='we',padx = 5) | |
| self.version_combo.current(0) | |
| #start_row+=1 | |
| # contains the actual versions which needs to be added to the path | |
| self.versions_to_add_d=dict() | |
| start_row +=1 | |
| def filter_versions(self,pattern,versions_l): | |
| "Return only matched pattern versions in new list" | |
| versions_filt_l = list() | |
| #for entry in versions_l: | |
| # if fnmatch.fnmatch(entry, pattern): | |
| # #print ("matched pattern in path {}: {}".format(path,entry)) | |
| # versions_filt_l.append(entry) | |
| r = re.compile(pattern) | |
| #matches = r.finditer(?) | |
| versions_filt_l = list(filter(r.match,versions_l)) | |
| return versions_filt_l | |
| def tools_spin_change_cb(self): | |
| tool_v = self.tools_var.get() | |
| pattern= self.filter_entry.get() | |
| versions_filt_l = sorted(self.filter_versions(pattern,self.tools_paths[tool_v])) | |
| if not versions_filt_l: | |
| versions_filt_l = self.tools_paths[tool_v] | |
| self.version_combo.config(values=versions_filt_l) | |
| #update the current active value | |
| self.version_combo.current(0) | |
| def add_version_button_cb(self): | |
| """adds a version to a spesific tool . | |
| overrides if such exists""" | |
| version = self.version_var.get() | |
| tool = self.tools_var.get() | |
| text = "" #self.added_versions_label['text']"" | |
| if version :# check not an empty content | |
| #text = text + "\n\t" + version | |
| self.versions_to_add_d[tool]=version | |
| #text = "The following will be added: "+ ''.join("\n->{!s}:{!r}".format(key,val) \ | |
| # for (key,val) in self.versions_to_add_d.items()) | |
| #self.added_versions_label['text'] = text | |
| #print(self.versions_to_add_d) | |
| def add_version_external(self,tool="",version=""): | |
| """adds a version to a spesific tool . | |
| overrides if such exists""" | |
| if version :# check not an empty content | |
| self.versions_to_add_d[tool]=version | |
| def get_added_versions(self): | |
| return self.versions_to_add_d | |
| def main(): | |
| root = Tk() | |
| tool_paths = {"vcsmx":["vcsmx_path1/1712/p","vcsmx_path2/1703/l","vcsmx_path/1809/o","vcsmx_path/1606/f"], | |
| "verdi":["verdi_path1","verdi_path2/1703/","verdi/1712/release-build/vcsmx", | |
| "/remote/vtgimages/SAFE/<name>/release-build/verdi"], | |
| "xa":["xa_path1","xa_path2"], | |
| "VC_LP":["vclp_path1","vc_lp_path2","vc_lp1712","vc_lp1703sp1","vc_lp1703sp21"]} | |
| t = ToolsSetupGuiC(root,tool_paths) | |
| add_button = Button(root,text="Add Tool",command=lambda: \ | |
| t.add_version_button_cb()) | |
| add_button.grid(row=3,column=3,sticky='nwe ') | |
| root.rowconfigure(0,weight=1) | |
| root.rowconfigure(1,weight=1) | |
| root.rowconfigure(2,weight=1) | |
| root.columnconfigure(0,weight=1) | |
| root.columnconfigure(1,weight=1) | |
| root.columnconfigure(2,weight=1) | |
| root.mainloop() | |
| if __name__ == '__main__': main() |
| #!/global/freeware/Linux/RHEL6/python-3.6.3/bin/python | |
| import os | |
| import re , fnmatch | |
| class ToolC: | |
| def __init__(self,*args): | |
| """ | |
| args[0]={tool: [task1,task2] ,tool2:[task2,task3],.. | |
| self.tool_paths : {tool:([path1,path2],"tool_HOME"),tool2:([path1:path2],"tool_HOME")}""" | |
| if args: | |
| #assuming if args exist it contains the pathes and constructors | |
| ##print("These are args :\n\t",args[0]) | |
| self.tool_paths = dict() | |
| #retrieves list of rrelevant tool pathes | |
| for tool,cnstr_list in args[0].items(): | |
| #print("oleggrex debug 0 ",tool,cnstr_list) | |
| for cnstr in cnstr_list[0]:#cnstr_list[1] = "VCS_HOME" , [0] = list of all path constructors | |
| ##print("cnstr",cnstr) | |
| if tool in self.tool_paths: | |
| #Extend existing list of pathes | |
| cnstr_list_of_paths = cnstr() | |
| #print("oleggrex debug 1",cnstr_list_of_paths) | |
| self.tool_paths[tool][0].extend(cnstr_list_of_paths) # cnstr returns list of pathes | |
| else: | |
| self.tool_paths[tool]=(cnstr(),cnstr_list[1]) | |
| else: | |
| print("[py-ERROR]: No paths provided to tool constructor in ToolC") | |
| def print_tool_paths(self,tool=""): | |
| if not tool: | |
| for tool,path_list in self.tool_paths.items(): | |
| print("[py-INFO]: -->tool = {}\n paths = {}\n".format(tool,path_list[0])) | |
| #else: | |
| #print(self.tool_paths[tool]) | |
| def get_tool_paths(self,tool = ""): | |
| """returns a list of pathes from spesific tool""" | |
| paths_list = self.tool_paths.get(tool,{None})[0] | |
| if not paths_list: | |
| print("[py-Error]: Tool {} is not present in tools list".format(tool)) | |
| return None | |
| return paths_list | |
| def get_tool_home(self,path = ""): | |
| """returns tool home env variable """ | |
| pass | |
| #TODO find the tool home from the path | |
| #paths_list = self.tool_paths.get(tool,{None})[0] | |
| #if not paths_list: | |
| # print("[py-Error]: Tool {} is not present in tools list".format(tool)) | |
| # return None | |
| #return paths_list | |
| def setenv_var(self,var,val=""): | |
| """setenv environment variable: setenv var val""" | |
| os.environ[var]=os.path.expandvars(val) | |
| #print("setenv_var : var = {} val = {}".format(var,val)) | |
| def setenv_tool_home(self,tool="",var="",path=""): | |
| """setenvs the tool's home (ex.VCS_HOME) and the path""" | |
| #sanity check that such path and tool exist | |
| #print(self.tool_paths.keys()) | |
| if tool not in self.tool_paths: | |
| print("[py-Warning]: Such tool {} does not exist ".format(tool)) | |
| return | |
| else: | |
| if path not in self.tool_paths[tool][0]: | |
| print("[py-Warning]: Such path ----{}---- does not exist for the tool ---{}----".format(path,tool)) | |
| return | |
| print("[py-Info]: Setting {} to : {}".format(var,path)) | |
| self.setenv_var(var,path) | |
| #print("The following was set {} with {}".format(var,os.environ[var])) | |
| self.set_home_bin_to_path(path) | |
| def set_home_bin_to_path(self,param=""): | |
| """sets the param/bin to path:""" | |
| ##print os.environ['PATH'] | |
| #uncomment PATH = os.environ['PATH'] | |
| print("set_home_bin_to_path , param=",param) | |
| if param != "": | |
| print("") | |
| PATH = os.environ['PATH'] | |
| os.environ['PATH']=param + '/bin:' + PATH | |
| else: | |
| print ("[py-Warning]: Wrong parameter for set_home_bin_to_path function") | |
| def get_tool_path_spesific_pattern(path,pattern): | |
| """gets directory path and a pattern acording to which | |
| retrieves list of sub directories iwith a full path""" | |
| listOfFiles = next(os.walk(path))[1] | |
| listOfFiles_filtered_l = list() | |
| #match_b = False | |
| #for entry in listOfFiles: | |
| # if fnmatch.fnmatch(entry, pattern): | |
| # ##print ("matched pattern in path {}: {}".format(path,entry)) | |
| # listOfFiles_filtered_l.append(entry) | |
| # match_b = True | |
| #if not match_b: | |
| # print ("[py-Warning]:NO matched pattern in path {} with pattern: {}".format(path,pattern)) | |
| # return | |
| r = re.compile(pattern) | |
| listOfFiles_filtered_l = list(filter(r.match,listOfFiles)) | |
| if not len(listOfFiles_filtered_l): | |
| print ("[py-Warning]:NO matched pattern in path {} with pattern: {}".format(path,pattern)) | |
| listOfFiles_filtered_l = listOfFiles # as no filtered found return all | |
| else: | |
| pass | |
| #print("[py-Info]:found matches in path {} are : {}".format(path,listOfFiles_filtered_l)) | |
| for indx in range(len(listOfFiles_filtered_l)): | |
| listOfFiles_filtered_l[indx] = path + "/" + listOfFiles_filtered_l[indx] | |
| ##print (listOfFiles_filtered_l) | |
| return listOfFiles_filtered_l | |
| def verdi_remote_vtgimages(path="/remote/vtgimages/SAFE"): | |
| """retrieves tool pathes from a main directory and formats the path | |
| to the bin/ level. """ | |
| pattern = ".*_VERDI201[5,6,7,8].*" | |
| verdi_paths = get_tool_path_spesific_pattern(path,pattern) | |
| if verdi_paths: | |
| for indx in range(len(verdi_paths)): | |
| verdi_paths[indx] = verdi_paths[indx] + "/release-build/verdi" | |
| return verdi_paths | |
| return None | |
| def xa_global_pathes(path='/global/apps'): | |
| """retrieves tool pathes from a main directory and formats the path | |
| to the bin/ level. """ | |
| #/global/apps/<name> | |
| ##print("Here is the list of dirs in path \n",next(os.walk(path))[1]) #'next.. returns list of directories | |
| pattern = ".*xa_.*201[6,7,8]*" | |
| xa_pathes = get_tool_path_spesific_pattern(path,pattern) | |
| return xa_pathes | |
| def vcsmx_global_pathes(path='/global/apps'): | |
| """retrieves tool pathes from a main directory and formats the path | |
| to the bin/ level. """ | |
| #/global/apps/<name> | |
| ##print("Here is the list of dirs in path \n",next(os.walk(path))[1]) #'next.. returns list of directories | |
| pattern = ".*(vcsmx).*" | |
| #pattern = "(?!.*static)(17).*" | |
| vcsmx_pathes = get_tool_path_spesific_pattern(path,pattern) | |
| return vcsmx_pathes | |
| def vcsmx_snps_apps_pathes(path='/global/snps_apps'): | |
| """retrieves tool pathes from a main directory and formats the path | |
| to the bin/ level. """ | |
| #/global/apps/<name> | |
| ##print("Here is the list of dirs in path \n",next(os.walk(path))[1]) #'next.. returns list of directories | |
| pattern = ".*vcs[_,(mx)].*201[5,6,7,8].*Beta*" | |
| vcsmx_pathes = get_tool_path_spesific_pattern(path,pattern) | |
| return vcsmx_pathes | |
| def verdi_snps_apps_pathes(path='/global/snps_apps'): | |
| """retrieves tool pathes from a main directory and formats the path | |
| to the bin/ level. """ | |
| #/global/apps/<name> | |
| ##print("Here is the list of dirs in path \n",next(os.walk(path))[1]) #'next.. returns list of directories | |
| pattern = ".*verdi.*201[5,6,7,8].*Beta*" | |
| verdi_paths = get_tool_path_spesific_pattern(path,pattern) | |
| return verdi_paths | |
| def fs_release_vcsmx_pathes(path='/fs/Release'): | |
| """retrieves tool pathes from a main directory and formats the path | |
| to the bin/ level.formats each path with the following: | |
| /fs/Release/linux_<name>/release-build/vcs-mx""" | |
| #/fs/Release/linux_RH5_EM64T_VCS2016.06_mode64_debug_Engineer/release-build/vcs-mx | |
| pattern = ".*VCS201[5,6,7,8].*" | |
| #print("oleggrex debug 3 ",path,pattern) | |
| vcsmx_paths = get_tool_path_spesific_pattern(path,pattern) | |
| if vcsmx_paths: | |
| for indx in range(len(vcsmx_paths)): | |
| vcsmx_paths[indx] = vcsmx_paths[indx] + "/release-build/vcs-mx" | |
| return vcsmx_paths | |
| return None | |
| def verdi_global_pathes(path='/global/apps'): | |
| """retrieves tool pathes from a main directory and formats the path | |
| to the bin/ level. """ | |
| #/global/apps/<name> | |
| pattern = ".*verdi.*201[6,7,8].*"#"*vcsmx_201[7]*" | |
| verdi_paths = get_tool_path_spesific_pattern(path,pattern) | |
| return verdi_paths | |
| def main(): | |
| path_constructor = {"vcsmx":([fs_release_vcsmx_pathes,vcsmx_global_pathes],"VCS_HOME") , | |
| "verdi":([verdi_global_pathes],"VERDI_HOME")} | |
| t = ToolC(path_constructor) | |
| t.setenv_tool_home("vcsmx","VCS_HOME",'/fs/images/linux_64_VCS2017.12_temp0/release-build/vcs-mx') | |
| if __name__=='__main__':main() | |
| #def main(): | |
| # path_constructor = { "vcsmx":('/fs/Release',fs_release_vcsmx_pathes), | |
| # "vcsmx":('/global/apps',vcsmx_global_pathes) , | |
| # "verdi":('/remote/vtgimages/SAFE',verdi_global_pathes)} | |
| # t = ToolC('vcsmx',path_constructor) | |
| # t.#print_tool_paths("vcsmx") | |
| # | |
| # | |
| #if __name__=='__main__':main() |
Addition to current version : Load command from history tab acording to the selected command in main window . delete command from history tab .
Creates a makefile based on the command in manetab using menu Create makefile option .
Has a PWD as title .
Has default vcsmx/verdi versions when loaded
This version is a new version which allows to add different tools and not only vcs or verdi .
It allows to filter using regex expression the type of versions . It saves the already added tools and reloads them on next start up .
It creates makefile and adds the tools which are set .
When no tool is set and one starts execution it pops up a warning to add at least one tool .
Attention : This content was taken from unix . Tab/spaces issue may be encountered .
Added setenv Functinality from any command line