TookDES产品BUG报告生成器 v1.0G 源代码探讨
来源:互联网 发布:ncut算法 opencv 编辑:程序博客网 时间:2024/05/04 19:38
TookDES产品BUG报告生成器 v1.0G采用了easygui来制作简单的GUI程序。代码非常简单,能做的工作也不多。主要是一个探讨。
一开始我想使用wxpython作为GUI库,当时想用下拉菜单,无论如何实现不好那个和事件驱动的绑定,我果然是弱爆了……
之后就想到用tkinter,结果觉得功能有点弱,自己又怕麻烦…于是上网一搜,就找到了easygui,照着范例一做,嘿,成了。
源代码如下:
#!usr/bin/env python# -*- coding: utf-8 -*-import sys reload(sys) sys.setdefaultencoding('utf8') from easygui import *global product1product1 = ""global product2product2 = ""global product3product3 = ""global productglobal bugdesglobal seriousnessglobal personinforglobal bugglobal attachmentdef productchoose(): msg = "请选择TookDES产品:(按名称排序)" title = "TookDES产品BUG报告生成器 v1.0G" choices = ["Tookubuntu", "TookDroid", "TookBlog", "TookCode", "TookSUSE", "Windows FLP for VirtualBox", "GAPPS for TookDroid", "njit8021xclient", "定制版Android APK程序","TookDroid x86", "Tookubuntu字体", "Tookubuntu yong输入法","卡尔改键", "TookDES产品BUG报告生成器"] global product1 product1 = choicebox(msg, title, choices)def tookubuntu(): msg = "请选择Tookubuntu版本:" title = "Tookubuntu系列操作系统" choices = ["TooKubuntu 3.0", "Tookubuntux 1.0", "Tookubuntu 2.4 LTS", "Tookubuntu for VNC"] global product2 product2 = choicebox(msg, title, choices)def tookdroid(): msg = "请选择TookDroid支持的设备:" title = "TookDroid系列Android ROM" choices = ["HTC Desire", "HTC Desire S", "HTC Desire Z", "HTC DROID Incredible 2", "HTC EVO 3D GSM", "HTC HD2", "HTC Touch Diamond", "Malata Zpad T8 (WCDMA)", "Motorola Milestone"] global product2 product2 = choicebox(msg, title, choices) global product3 product3 = enterbox('''请输入详细版本号,如“v1.0I”''', "TookDroid详细版本号",)def tookblog(): msg = "请选择Tookblog版本:" title = "TookBlog程序" choices = ["Windows Phone 7", "Android"] global product2 product2 = choicebox(msg, title, choices)def GAPPS(): msg = "请选择GAPPS for TookDroid版本:" title = "TookDroid的Google服务套件" choices = ["Android 2.3.4~2.3.5", "Android 2.3.7" ,"Android 4.0.3~4.0.4"] global product2 product2 = choicebox(msg, title, choices)def njit8021xclient(): msg = "请选择njit8021xclient版本:" title = "H3C iNode 802.1X Linux操作系统第三方客户端" choices = ["openWRT on ar71xx", "openWRT on brcm47xx/53xx", "openWRT on Tp-Link WR941ND"] global product2 product2 = choicebox(msg, title, choices)def APK(): msg = "请选择修改版的APK程序:" title = "TookDES修改或汉化后的APK程序" choices = ["gReader Pro", "Blogger", "ODF阅读器", "Verizon Opera Mini", "一键锁屏"] global product2 product2 = choicebox(msg, title, choices)def bugger(): msg = "请选择产品BUG报告生成器版本:" title = "TookDES产品BUG报告生成器" choices = ["GUI版本(版本号为G字母结尾,图形模式)", "CUI版本(版本号为C字母结尾,终端模式)"] global product2 product2 = choicebox(msg, title, choices)def person(): msg = "请填入个人信息,以方便我们联系:" title = "个人信息" fieldNames = ["姓名/代称","电子邮件","手机号码"] fieldValues = [] global personinfor personinfor = multenterbox(msg, title, fieldNames) if personinfor == "": personinfor = "匿名"def bugdescrible(): global bugdes bugdes = textbox('''请粘贴(而不是在此输入,因为没有自动保存功能)详细的BUG描述,如:1.产生的步骤2.问题的表现3.希望的改进4.错误日志文本''', "BUG描述")def seriousnesschoose(): msg = "请评估BUG的严重程度,这将有利于对BUG的处理:" title = "BUG严重程度" choices = ["高","中","低"] global seriousness seriousness = buttonbox(msg, title=title, choices=choices)def desbugreport(): global product1 global product2 global product3 global bug global product global bugdes global seriousness global attachment productchoose() if product1 == "Tookubuntu": tookubuntu() elif product1 == "TookDroid": tookdroid() elif product1 == "TookBlog": tookblog() elif product1 == "njit8021xclient": njit8021xclient() elif product1 == "定制版Android APK程序": APK() elif product1 == "GAPPS for TookDroid": GAPPS() elif product1 == "": sys.exit("用户未实现有效选择,程序退出") else: pass bugdescrible() seriousnesschoose() person()def txt(): global product1 global product2 global product3 global product global bugdes global seriousness global personinfor text = "【TookDES产品】\n\n"+product1+","+product2+","+product3\ +"\n\n【BUG详情】\n\n"+bugdes+"\n【严重程度】\n\n"+seriousness+\ "\n\n【联系信息】\n\n"+str(personinfor[0])+"\n"+str(personinfor[1])\ +"\n"+str(personinfor[2]) codebox('''请复制下面的所有内容(鼠标拖动,再按键盘Ctrl+C),发送邮件至tookdes@tookdes.tk。你可以在邮件中附上截图等文件,此邮箱接收上限为20M大小。感谢使用TookDES产品BUG收集器!''', "", text) if __name__ == '__main__': desbugreport() txt()
探讨:
未完成的tkinter代码:
#!usr/bin/env python# -*- coding: utf-8 -*-from Tkinter import *import ttkwindow = Tk()window.title("TookDES产品BUG提交工具") frame1 = Frame(window, borderwidth=2, relief=GROOVE)#告诉Tk,如果主窗口调整大小,框架应该扩展来占据额外的空间。frame1.columnconfigure(0,weight=1)Ver = StringVar()Dev = StringVar()label1 = Label(frame1, text="产品名称:").grid(row=0,column=0)chos1 = ttk.Combobox(frame1,values=["Tookbuntu", "TookSUSE", "TookDroid", "TookCode", "TookBlog", "Windows FLP" ]).grid(row=0,column=1)label2 = Label(frame1, text="产品版本:").grid(row=0,column=2)entry = Entry(frame1, textvariable=Ver).grid(row=0,column=3)label2 = Label(frame1, text="设备型号:").grid(row=0,column=4)entry = Entry(frame1, textvariable=Dev).grid(row=0,column=5)frame1.pack()frame2 = Frame(window, borderwidth=2, relief=GROOVE)frame2.columnconfigure(0,weight=1)label2 = Label(frame2, text="BUG详述:").pack(side="left")text = Text(frame2, height=10, width=72).pack()frame2.pack()window.mainloop()
未完成的CUI版本代码:
#!usr/bin/env python# -*- coding: utf-8 -*-print '''TookDES产品BUG提交工具 CUI版 v1.0请输入产品名称序号,或直接输入产品名:1.Tookubuntu2.TookDroid3.TookBlog4.TookCode5.TookSUSE6.Windows FLP'''tdes = raw_input()if tdes == "1": print '''请选择产品版本序号,或直接输入产品版本:1.TooKubuntu 3.02.TookUbuntu 2.4 LTS3.Tookubuntux 1.0''' tu = raw_input() if tu == "1": pro = "Tookubuntu 3.0" elif tu == "2": pro = "TookUbuntu 2.4 LTS" elif tu == "3": pro = "TookUbuntux 1.0" else: pro = tuelif tdes == "2": print '''请选择适配机型:1.HTC
本来还想直接用电子邮件发过去的,但是不知道为什么,可能网易不让直接这样连接发送了吧:
#!usr/bin/env python# -*- coding: utf-8 -*-import sys reload(sys) sys.setdefaultencoding('utf8') from easygui import *import smtplibimport email.MIMEMultipartimport email.MIMEBaseimport os.pathglobal product1product1 = ""global product2product2 = ""global product3product3 = ""global productglobal bugdesglobal seriousnessglobal bugglobal attachmentdef productchoose(): msg = "请选择TookDES产品:(按名称排序)" title = "TookDES产品BUG提交工具 GUI版本 v1.0" choices = ["Tookubuntu", "TookDroid", "TookBlog", "TookCode", "TookSUSE", "Windows FLP for VirtualBox", "GAPPS for TookDroid", "njit8021xclient", "定制版Android APK程序","TookDroid x86", "Tookubuntu字体", "Tookubuntu yong输入法","卡尔改键"] global product1 product1 = choicebox(msg, title, choices)def tookubuntu(): msg = "请选择Tookubuntu版本:" title = "Tookubuntu系列操作系统" choices = ["TooKubuntu 3.0", "Tookubuntux 1.0", "Tookubuntu 2.4 LTS", "Tookubuntu for VNC"] global product2 product2 = choicebox(msg, title, choices)def tookdroid(): msg = "请选择TookDroid支持的设备:" title = "TookDroid系列Android ROM" choices = ["HTC Desire", "HTC Desire S", "HTC Desire Z", "HTC DROID Incredible 2", "HTC EVO 3D GSM", "HTC HD2", "HTC Touch Diamond", "Malata Zpad T8 (WCDMA)", "Motorola Milestone"] global product2 product2 = choicebox(msg, title, choices) global product3 product3 = enterbox('''请输入详细版本号,如“v1.0I”''', "TookDroid详细版本号",)##def tookdroidx86:## msg = "请选择TookDroid x86支持的设备:"## title = "TookDroid x86系列"## choices = ["Virtualbox"]## choic = choicebox(msg, title, choices)def tookblog(): msg = "请选择Tookblog版本:" title = "TookBlog程序" choices = ["Windows Phone 7", "Android"] global product2 product2 = choicebox(msg, title, choices)def GAPPS(): msg = "请选择GAPPS for TookDroid版本:" title = "TookDroid的Google服务套件" choices = ["Android 2.3.4~2.3.5", "Android 2.3.7" ,"Android 4.0.3~4.0.4"] global product2 product2 = choicebox(msg, title, choices)def njit8021xclient(): msg = "请选择njit8021xclient版本:" title = "H3C iNode 802.1X Linux操作系统第三方客户端" choices = ["openWRT on ar71xx", "openWRT on brcm47xx/53xx", "openWRT on Tp-Link WR941ND"] global product2 product2 = choicebox(msg, title, choices)def APK(): msg = "请选择修改版的APK程序:" title = "TookDES修改或汉化后的APK程序" choices = ["gReader Pro", "Blogger", "ODF阅读器", "Verizon Opera Mini", "一键锁屏"] global product2 product2 = choicebox(msg, title, choices)def productensure(): msg = "请修改确认以下信息是否无误:" title = "产品信息最终确认" fieldNames = ["产品名","版本号","次级版本号"] fieldValues = [product1, product2, product3] global product product = multenterbox(msg, title, fieldNames)def bugdescrible(): global bugdes bugdes = textbox('''请粘贴(而不是在此输入,因为没有自动保存功能)详细的BUG描述,如:1.产生的步骤2.问题的表现3.希望的改进4.您的电子邮件地址''', "BUG描述")def attachmentadd(): if ccbox("如果有附件(如截图、错误日志),请将它们压缩打包为一个文件,然后选择:", "附件"): global attachment attachment = fileopenbox() else: passdef seriousnesschoose(): msg = "请评估BUG的严重程度,这将有利于对BUG的处理:" title = "BUG严重程度" choices = ["高","中","低"] global seriousness seriousness = buttonbox(msg, title=title, choices=choices)def desbugreport(): global product1 global product2 global product3 global bug global product global bugdes global seriousness global attachment productchoose() if product1 == "Tookubuntu": tookubuntu() elif product1 == "TookDroid": tookdroid() elif product1 == "TookBlog": tookblog() elif product1 == "njit8021xclient": njit8021xclient() elif product1 == "定制版Android APK程序": APK() elif product1 == "GAPPS for TookDroid": GAPPS() elif product1 == "": sys.exit("用户未实现有效选择,程序退出") else: pass bugdescrible() attachmentadd() seriousnesschoose() productensure() bug = product + bugdes + seriousness print product1 print product2 print product3 print product print bugdes print seriousness print bug print attachmentdef sendemail(): global bug global attachment if ccbox("即将发送报告,请确认", "确认发送"): smtpsvr = 'smtp.126.com' name = '' from_ = '' pw = '' blogmail = 'tookdes@tookdes.tk' contype = 'application/octet-stream' maintype, subtype = contype.split('/', 1)#构造文件附件内容容器 data = open(attachment, 'rb') file_msg = email.MIMEBase.MIMEBase(maintype, subtype) file_msg.set_payload(data.read( )) data.close( ) email.Encoders.encode_base64(file_msg)#读取并格式化 basename = os.path.basename(attachment) file_msg.add_header('Content-Disposition', 'attachment', filename = basename)#设置附件头 origBody = file_msg.as_string() + bug origHdrs = ['From:'+from_, 'To:'+blogmail, 'Subject:'+"TookDES BUG报告 by GUI版 v1.0"] origMsg = '\r\n\r\n'.join(['\r\n'.join(origHdrs), '\r\n'.join(origBody)]) sendSvr = SMTP(smtpsvr) sendSvr.login(name,pw) errs = sendSvr.sendmail(from_, blogmail, origMsg) sendSvr.quit() else: sys.exit("用户取消发送,程序退出") if __name__ == '__main__': desbugreport() sendemail()
- TookDES产品BUG报告生成器 v1.0G 源代码探讨
- bug系统 V1.0
- WinEggDrop v1.0 源代码
- QQ自动登陆脚本生成器 v1.0
- WinEggDrop后门v1.0源代码
- pftp v1.0 beta源代码
- 在线考试平台V1.0产品发布
- 唐&杰出产品经理书 v1.0
- CodePlus C# 代码生成器 V1.0 版 推出了!
- JAVA任意架构源码生成器CodeMaster v1.0 Beta
- 微软 DeviceEmulator v1.0 源代码开放下载
- Linux内核源代码漫游(code v1.0)
- AHK源代码加密器 v1.0
- 产品密钥生成器
- 探讨下一代无线终端硬件设计与测试 加速4G产品上市
- 报告 Bug
- 报告 Bug
- 分析报告生成器
- thinkPHP学习小结
- 第四周上机任务4
- Proxy代理的应用
- 实例解析linux内核I2C体系结构(1)
- Dsedit启动报错:“Fail to initialize LIBTCL.DLL ……"的两种解决办法
- TookDES产品BUG报告生成器 v1.0G 源代码探讨
- 64bit oracle and oracle client.
- ERROR: Invaled boot image pagesize. Device pagesize: 4096, Image pagesize: 16384
- 关于String 的正则
- 关于手机屏幕
- 使用SecureCRT连接Dynamips时, 报错:The remote system refused the connection??前几天还是好好的,奇怪。。
- 九九算法源码
- 第四周任务二
- 辨别 优盘 真假 [金士顿]