Re: Python/GTK-based bug-reporting script



  Bleah.  I forgot to attach the script.  One thing about this..the sendmail
call makes it somewhat UNIX-specific.  I'm not sure that Gnome runs well enough
on non-Unix systems yet for a bug report script using Gnome to be helpful,
though..

-- 
  Using a metaphor in front of Ridcully was like a red rag to a--was like
using something very annoying in the presence of someone who was very annoyed
by it.

              -- Terry Pratchett, _Lords and Ladies_
#!/usr/bin/python

# Simple bug-reporting script

from gtk import *
from gnome.ui import *
import os

def option_menu_activate(item,self,num):
  self.current=num

def my_label(text):
  label=GtkLabel(text)
  label.set_alignment(1.0,0.5)
  return label

def attach_label(label,x1,y1,x2,y2):
  table.attach(label,x1,y1,x2,y2,FILL,0,0,0)

def attach_entry(entry,x1,x2,y1,y2):
  table.attach(entry,x1,x2,y1,y2)

severities=["Wishlist","Normal","Grave","Critical"]
severity_default=1

dialog=GnomeDialog("Gnome Bug Reporter",STOCK_BUTTON_OK,STOCK_BUTTON_CANCEL,None)

table=GtkTable(6,2,FALSE)
table.set_row_spacings(PAD_SMALL)
table.set_col_spacings(PAD_SMALL)

package=GtkEntry()
version=GtkEntry()
subject=GtkEntry()
email=GtkEntry()
severity=GtkOptionMenu()
frame=GtkFrame("Problem")
body=GtkText()

subject.set_text("Describe the problem briefly")

body.set_editable(TRUE)
body.set_word_wrap(TRUE)

#ok=GnomeStockButton(STOCK_BUTTON_OK)
#cancel=GnomeStockButton(STOCK_BUTTON_CANCEL)

attach_label(my_label("Package:"),0,1,0,1)
attach_entry(package,1,2,0,1)

attach_label(my_label("Version:"),0,1,1,2)
attach_entry(version,1,2,1,2)

attach_label(my_label("Subject:"),0,1,2,3)
attach_entry(subject,1,2,2,3)

attach_label(my_label("Your email:"),0,1,3,4)
attach_entry(email,1,2,3,4)

menu=GtkMenu()
for i in range(len(severities)):
  item=GtkMenuItem(severities[i])
  menu.append(item)
  item.connect("activate",option_menu_activate,severity,i)

severity.current=severity_default
menu.set_active(severity_default)

severity.set_menu(menu)

attach_label(my_label("Severity:"),0,1,4,5)
attach_entry(severity,1,2,4,5)

frame.add(body)
table.attach(frame,0,2,5,6)

dialog.vbox.add(table)

#ok.connect("clicked",mainquit)
#cancel.connect("clicked",mainquit)

#dialog.action_area.add(ok)
#dialog.action_area.add(cancel)

dialog.vbox.show_all()

if dialog.run()==0:
  pipe=os.popen("/usr/sbin/sendmail submit@bugs.gnome.org","w")
  if email.get_text()!='':
    pipe.write("From: %s\n"%email.get_text())
  pipe.write("Subject: %s\n"%subject.get_text())
  pipe.write("\n")
  pipe.write("Package: %s\n"%package.get_text())
  pipe.write("Version: %s\n"%version.get_text())
  pipe.write("Severity: %s\n"%severities[severity.current])
  pipe.write("\n")
  pipe.write(body.get_chars(0,-1))
  pipe.close()
  GnomeMessageBox("Bug report submitted!",MESSAGE_BOX_INFO,STOCK_BUTTON_OK,None).run()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]