Exemplo n.º 1
0
 def delconfig(self):
     if messagebox.askyesno(title = '提示', message = '确认删除?'):
         delvalue = self.combobox2.get()
         valueslist = list(self.combobox2['values'])
         valueslist.remove(delvalue)      
         self.combobox2['values'] = valueslist
         if valueslist != []:
             curvalue = valueslist[-1]
         else:
             curvalue = ''
         _, self.server_ip, self.server_port, self.qs_id = config.readbackup(curvalue)
         self.combobox2.set(curvalue)
         self.ent1_value.set(self.server_ip)
         self.ent2_value.set(self.server_port)
         self.ent3_value.set(self.qs_id)
         config.deletebackup(delvalue, curvalue)
         self.mongo_object = dbinit.Mongo(curvalue)
         #自动初始化listbox列表
         self.lbox_init()            
Exemplo n.º 2
0
    def combo2_selection(self, event):
        self.current_scheme, self.server_ip, self.server_port, self.qs_id = config.readbackup(self.combobox2.get())
        self.mongo_object = dbinit.Mongo(self.current_scheme)
        self.func_object = autotest.Func(self.mongo_object, self.server_ip, self.server_port, self.qs_id)
        self.func_object.readdict()
        self.func_object.write_json()      

        self.ent1_value.set(self.server_ip)
        self.ent2_value.set(self.server_port)
        self.ent3_value.set(self.qs_id)
        self.init_function()
        
        self.mongo_object = dbinit.Mongo(self.current_scheme)
        self.mongo_object.db_init()
        
        self.lbox.delete(0, 'end')
        for item in self.mongo_object.case:
            self.lbox.insert('end', item["_id"])
    
        # Colorize alternating lines of the listbox
        for i in range(0, len(self.mongo_object.case), 2):
            self.lbox.itemconfigure(i, background='#f0f0ff')
            
        self.label.configure(text='0:00:00.000000')
Exemplo n.º 3
0
                print(("-"*60))
                print(promotd)
                choice=input("请选择:").strip()[0]
            except(EOFError,KeyboardInterrupt,IndexError):
                choice='3'
            if choice not in '123':
                print("无效的选择,请重新选择:")
            else:
                break
        if choice=='1':
            show_sub_menu(obj)
        elif choice=='2':
            obj.autotest()
        else:
            break
        

if __name__ == '__main__':
    current_scheme, server_ip, server_port, qs_id = config.readbackup()
    mongo_object = dbinit.Mongo(current_scheme)
    func_object = Func(mongo_object, server_ip, server_port, qs_id)
    
    #建立socket连接和AB握手
    stauts = func_object.create_sokect(10)
    if stauts:
        print('与服务器握手成功')
        func_object.readdict()
        func_object.write_json()
        showmenu(func_object)
    else:
        print("非法或校验通不过等信息")
Exemplo n.º 4
0
    def __init__(self, parent):
        self.scheme_list = config.readschemelist()
        self.current_scheme, self.server_ip, self.server_port, self.qs_id = config.readbackup()
        self.mongo_object = dbinit.Mongo(self.current_scheme)
        self.func_object = autotest.Func(self.mongo_object, self.server_ip, self.server_port, self.qs_id)
        self.func_object.readdict()
        self.func_object.write_json()
        
        self.parent = parent
        self.value_of_combo2 = '11100客户校验'
        self.ft = font.Font(family = '微软雅黑',size = 9,weight = font.BOLD)
        #self.parent.option_add("*TCombobox*Listbox*Font", self.ft)
        self.parent.option_add("*Font", self.ft)
        self.num = 0

        #-------------------组件使用多列(多行)-------------------------------
        # columnspan:指定使用几列
        # rowspan:指定使用几行
    
        #-------------------设置对齐属性----------------------------------------------
        # sticky:设置组件对齐方式
        # 默认属性下,组件的对齐方式为居中,设置sticky 属性可以控制对齐方式,可用的值
        #(N,S,E,W)及其组合值
    
        self.frame1 = ttk.Frame(self.parent)
        self.frame2 = ttk.Frame(self.parent)
        self.frame3 = ttk.Frame(self.parent, padding=(10,0,0,0))
        self.labelframe1 = ttk.LabelFrame(self.frame1,text = '功能配置')
        self.labelframe2 = ttk.LabelFrame(self.frame2,text = '参数配置')
        self.labelframe3 = ttk.LabelFrame(self.frame2,text = '压力测试')
    
        self.frame1.grid(row=0, rowspan=26, column=0, columnspan=2, sticky=(N, S, W))
        self.frame2.grid(row=0, rowspan=5, column=2, columnspan=4, sticky=(N, E, W)) 
        self.frame3.grid(row=11, rowspan=2, column=2, columnspan=7, sticky=(N, W, E, S)) 
    
        #fram1
        label8 = ttk.Label(self.frame1,text = '功能:',font = self.ft)       
        self.combobox1_value = StringVar()
        self.combobox1 = ttk.Combobox(self.frame1, textvariable = self.combobox1_value, width = 40,
                                      height = 30, font = self.ft, postcommand = self.search_func)
        self.combobox1.bind("<<ComboboxSelected>>", self.combo1_selection)
                
        self.labelframe1.grid(row = 1,rowspan = 30,column = 0,columnspan = 2,padx = 10,pady = 2,sticky = (N, S, W))
        label8.grid(row = 0,column = 0,padx = 10,pady = 2,sticky = W)
        self.combobox1.grid(row = 0,column = 1,padx = 0,pady = 2,sticky = EW)  
    
        #fram2
        label1 = ttk.Label(self.frame2,text = '当前方案:',font = self.ft)
        label2 = ttk.Label(self.labelframe2,text = 'IP地址:',font = self.ft)
        label3 = ttk.Label(self.labelframe2,text = '端口:',font = self.ft)
        label4 = ttk.Label(self.labelframe2,text = '券商ID:',font = self.ft)
        label5 = ttk.Label(self.labelframe2,text = '接收超时(s):',font = self.ft)
        label6 = ttk.Label(self.labelframe2,text = '手机号:',state = 'disabled',font = self.ft)
        label7 = ttk.Label(self.labelframe2,text = '通讯密码:',state = 'disabled',font = self.ft)
    
        self.combobox2_value = StringVar()
        self.combobox2 = ttk.Combobox(self.frame2, textvariable=self.combobox2_value, state='readonly', font=self.ft)
        self.combobox2.bind("<<ComboboxSelected>>", self.combo2_selection)
        self.combobox2['values'] = self.scheme_list
    
        self.ent1_value = StringVar()
        self.ent2_value = StringVar()
        self.ent3_value = StringVar()
        self.ent4_value = StringVar()
        self.ent4_value.set(10)
        self.ent5_value = StringVar()
        self.ent6_value = StringVar()
        self.ent1 = ttk.Entry(self.labelframe2,textvariable = self.ent1_value)
        self.ent2 = ttk.Entry(self.labelframe2,textvariable = self.ent2_value)
        self.ent3 = ttk.Entry(self.labelframe2,textvariable = self.ent3_value)
        self.ent4 = ttk.Entry(self.labelframe2,textvariable = self.ent4_value)
        self.ent5 = ttk.Entry(self.labelframe2,textvariable = self.ent5_value,state = 'disabled')
        self.ent6 = ttk.Entry(self.labelframe2,textvariable = self.ent6_value,state = 'disabled')
    
        self.button1 = ttk.Button(self.frame2,text = '新增配置',state = 'normal',command = self.addconfig)
        self.button2 = ttk.Button(self.frame2,text = '删除配置',state = 'normal',command = self.delconfig)
        self.button3 = ttk.Button(self.labelframe2,text = '连接',state = 'normal',command = self.connect)
        self.button4 = ttk.Button(self.labelframe2,text = '断开',state = 'disabled',command = self.close)
        
        self.combobox2.set(self.current_scheme)
        self.ent1_value.set(self.server_ip)
        self.ent2_value.set(self.server_port)
        self.ent3_value.set(self.qs_id)
    
        label1.grid(row = 0,column = 2,padx = 10,pady = 10,sticky = (N, W))
        self.combobox2.grid(row = 0,column = 3,padx = 0,pady = 10,sticky = (N, W))
        self.button1.grid(row = 0,column = 4,padx = 10,pady = 10,sticky = (N, W))
        self.button2.grid(row = 0,column = 5,padx = 0,pady = 10,sticky = (N, W))
    
        self.labelframe2.grid(row = 1,rowspan = 4,column = 2,columnspan = 4,padx = 10,pady = 2,sticky = (N, W))
    
        label2.grid(row = 1,column = 2,padx = 10,pady = 2,sticky = (N, W))
        self.ent1.grid(row = 1,column = 3,padx = 0,pady = 2,sticky = (N, W))
        label3.grid(row = 1,column = 4,padx = 10,pady = 2,sticky = (N, W))
        self.ent2.grid(row = 1,column = 5,padx = 0,pady = 2,sticky = (N, W))
    
        label4.grid(row = 2,column = 2,padx = 10,pady = 2,sticky = (N, W))
        self.ent3.grid(row = 2,column = 3,padx = 0,pady = 2,sticky = (N, W))
        label5.grid(row = 2,column = 4,padx = 10,pady = 2,sticky = (N, W))
        self.ent4.grid(row = 2,column = 5,padx = 0,pady = 2,sticky = (N, W))
    
        label6.grid(row = 3,column = 2,padx = 10,pady = 2,sticky = (N, W))
        self.ent5.grid(row = 3,column = 3,padx = 0,pady = 2,sticky = (N, W))
        label7.grid(row = 3,column = 4,padx = 10,pady = 2,sticky = (N, W))
        self.ent6.grid(row = 3,column = 5,padx = 0,pady = 2,sticky = (N, W))
    
        self.button3.grid(row = 4,column = 4,padx = 0,pady = 2,sticky = (N, E))
        self.button4.grid(row = 4,column = 5,padx = 0,pady = 2,sticky = (N, E))
    
        self.lbox = Listbox(self.frame2, height=5, selectmode="extended")
        self.lbox.grid(row=0, rowspan=9, column=6, columnspan=2, padx = 0,pady = 2, sticky=(N, W, E, S))
        scrollbar1 = ttk.Scrollbar(self.frame2, orient=VERTICAL, command=self.lbox.yview)
        scrollbar1.grid(row=0, rowspan=9, column=8, padx = 0,pady = 2, sticky=(N, S))
        self.lbox['yscrollcommand'] = scrollbar1.set
        self.lbox.grid_columnconfigure(6, weight=1)
        self.frame2.grid_columnconfigure(6, weight=1)
        self.lbox.bind("<Double-1>", self.modify_scene)
        
        #自动初始化listbox列表
        self.lbox_init()
    
        self.button7 = ttk.Button(self.frame2,text = '新增场景',state = 'normal',width = 12, command = self.add_scene)
        self.button8 = ttk.Button(self.frame2,text = '删除场景',state = 'normal',width = 12, command = self.del_scene)  
        self.button7.grid(row = 9,column = 6,padx = 0,pady = 2,sticky = E)
        self.button8.grid(row = 9,column = 7,padx = 0,pady = 2,sticky = (E, W))        
    
        label9 = ttk.Label(self.frame2,text = '请求包:',font = self.ft)
        label10 = ttk.Label(self.frame2,text = '应答包:',font = self.ft)
        self.ent7_value = StringVar()
        self.ent8_value = StringVar()
        self.ent7 = ttk.Entry(self.frame2,textvariable = self.ent7_value)
        self.ent8 = ttk.Entry(self.frame2,textvariable = self.ent8_value)         
        self.button5 = ttk.Button(self.frame2,text = '自动化测试',state = 'normal',command = self.atuo_test)
        self.button6 = ttk.Button(self.frame2,text = '单功能测试',state = 'disabled',
                                  command = lambda: self.functest(self.ent7.get()))
    
        label9.grid(row = 10,column = 2,padx = 10,pady = 2,sticky = (E, W))
        self.ent7.grid(row = 10,column = 3,columnspan = 4,padx = 0,pady = 2,sticky = (E, W))
        label10.grid(row = 11,column = 2,padx = 10,pady = 0,sticky = (E, W))
        self.ent8.grid(row = 11,column = 3,columnspan = 4,padx = 0,pady = 0,sticky = (E, W))
        self.button5.grid(row = 10,column = 7,padx = 0,pady = 2,sticky = (E, W))
        self.button6.grid(row = 11,column = 7,padx = 0,pady = 2,sticky = (E, W))
    
        #frame3
        label11 = ttk.Label(self.labelframe3,text = '连接数:',font = self.ft)
        label12 = ttk.Label(self.labelframe3,text = '每次连接延时(ms):',font = self.ft)
        label13 = ttk.Label(self.labelframe3,text = '每路连接发送间隔(ms):',font = self.ft)
        label14 = ttk.Label(self.labelframe3,text = '计时器:',font = self.ft)
        self.label = ttk.Label(self.labelframe3,text = '0:00:00.000000',font = self.ft)
    
        self.ent10_value = StringVar()
        self.ent11_value = StringVar()
        self.ent12_value = StringVar()
        self.ent10_value.set(500)
        self.ent11_value.set(1000)
        self.ent12_value.set(1000)
        self.ent10 = ttk.Entry(self.labelframe3,textvariable = self.ent10_value)
        self.ent11 = ttk.Entry(self.labelframe3,textvariable = self.ent11_value)
        self.ent12 = ttk.Entry(self.labelframe3,textvariable = self.ent12_value)
        
        self.button13 = ttk.Button(self.labelframe3,text = '开始',state = 'normal',command = self.start)
        self.button14 = ttk.Button(self.labelframe3,text = '结束',state = 'disabled',command = self.end)
        
        self.labelframe3.grid(row = 5,rowspan = 4,column = 2,columnspan = 4,padx = 10,pady = 2,sticky = (N, W, E, S))
        label11.grid(row = 5,column = 2,padx = 10,pady = 2,sticky = (N, W))
        self.ent10.grid(row = 5,column = 3,padx = 0,pady = 2,sticky = (N, W))
        label12.grid(row = 6,column = 2,padx = 10,pady = 2,sticky = (N, W))
        self.ent11.grid(row = 6,column = 3,padx = 0,pady = 2,sticky = (N, W))
        label13.grid(row = 7,column = 2,padx = 10,pady = 2,sticky = (N, W))
        self.ent12.grid(row = 7,column = 3,padx = 0,pady = 2,sticky = (N, W))
        label14.grid(row = 8,column = 2,padx = 10,pady = 2,sticky = (N, W))
        self.label.grid(row = 8,column = 3,padx = 0,pady = 2,sticky = (N, W))
        self.button13.grid(row = 9,column = 2,padx = 10,pady = 2,sticky = (N, E))
        self.button14.grid(row = 9,column = 3,padx = 0,pady = 2,sticky = (N, E))

        self.tree = ttk.Treeview(self.frame3, selectmode="extended")
        scrollbar2 = ttk.Scrollbar(self.frame3, orient=HORIZONTAL, command=self.tree.xview)
        scrollbar3 = ttk.Scrollbar(self.frame3, orient=VERTICAL, command=self.tree.yview)
        self.tree.configure(xscrollcommand=scrollbar2.set, yscrollcommand=scrollbar3.set)
        self.tree.bind("<Button-3>", self.copy_value)
    
        self.tree.grid(row = 12,column = 2,columnspan = 6,padx = 0,pady = 2,sticky = (N, S, E, W))
        scrollbar2.grid(row=13, column=2, columnspan = 6, sticky=(E, W))
        scrollbar3.grid(row=12, rowspan=2, column=8, padx = 0,pady = 2, sticky=(N, S))       
    
        self.ent7.grid_columnconfigure(3, weight=1)
        self.ent8.grid_columnconfigure(3, weight=1)
        self.tree.grid_rowconfigure(12, weight=1)
        self.tree.grid_columnconfigure(2, weight=1)
        self.frame3.grid_rowconfigure(12, weight=1)
        self.frame3.grid_columnconfigure(2, weight=1)
        self.parent.grid_rowconfigure(12, weight=1)
        self.parent.grid_columnconfigure(2, weight=1)
        
        #功能选项界面初始化
        self.init_function()