home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / bin / hwdb-gui < prev    next >
Encoding:
Text File  |  2007-04-25  |  21.3 KB  |  620 lines

  1. #!/usr/bin/python
  2.  
  3. import os
  4. import os.path
  5. import string
  6. import gtk
  7. import gtk.glade
  8. import gnome.ui
  9. import gnomecanvas
  10. import gobject
  11.  
  12. #from gettext import gettext as _
  13. import gettext
  14. def _(x): return x
  15. import locale
  16.  
  17. from gtk import RcStyle
  18. from gtk import Settings
  19.  
  20. from hwdb_client import Constants
  21.  
  22. DISTRO = "Ubuntu"
  23.  
  24. class Collector:
  25.     def __init__(self):
  26.         self.output = []
  27.         self.comments = []
  28.     self.devdata = []
  29.     self.devicename = ''
  30.         self.i = 3638089728
  31.     self.wTree=gtk.glade.XML (Constants.DATADIR + "/collector.glade",
  32.                                   "window","hwdb-client")
  33.     self.xmlfile = Constants.DATADIR + "/questions_en.xml"
  34.     self.step = 0
  35.     self.headericon = ''
  36.     self.headtxt = ''
  37.     self.cont_txt = ''
  38.     self.hline = ''
  39.     self.yesno = ''
  40.     self.comtxt = ''
  41.     self.comwin = ''
  42.     self.comrtf = ''
  43.     self.box1 = ''
  44.     self.donetxt = ''
  45.     self.radio = ''
  46.     self.cont_rec = ''
  47.     self.yesbutt = gtk.RadioButton(None, _("Yes"))
  48.     self.redo = gtk.Button()
  49.     self.urlbutt = gtk.Button()
  50.     self.cpybutt = gtk.Button()
  51.     self.co_textview = gtk.TextView()
  52.     hwdb_lock = ""
  53.     home_path=os.environ["HOME"]    
  54.     path = home_path+'/.hwdb'
  55.     clip = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
  56.  
  57.     if os.path.isfile(path):
  58.         lock = open(path)
  59.         hwdb_lock = lock.read()
  60.  
  61.     canvas = self.wTree.get_widget("canvas")
  62.     self.root = canvas.root().add(gnomecanvas.CanvasGroup)
  63.     canvas_bg = gtk.gdk.pixbuf_new_from_file(Constants.DATADIR + "/canvas_bg.png") 
  64.  
  65.     self.root.add(gnomecanvas.CanvasPixbuf, pixbuf = canvas_bg, 
  66.          x = 0, y = 0, anchor = "nw")
  67.  
  68.     cancel = self.wTree.get_widget("cancel_button")
  69.     self.advance = self.wTree.get_widget("adv_button")
  70.     help = self.wTree.get_widget("help_button")
  71.  
  72.     if hwdb_lock:
  73.           tt = gtk.Tooltips()
  74.         self.advance.hide()
  75.         urlbox1 = gtk.HBox(False, 0)
  76.             image = gtk.Image()
  77.             image.set_from_stock(gtk.STOCK_CONNECT, gtk.ICON_SIZE_BUTTON)
  78.             label = gtk.Label(_('Show online record'))
  79.             urlbox1.add(image)
  80.             urlbox1.add(label)
  81.         self.online_button = self.root.add(gnomecanvas.CanvasWidget, x = 250, y = 200, widget = self.urlbutt, 
  82.              width = 160, height = 30)
  83.            self.urlbutt.add(urlbox1)
  84.         self.urlbutt.show_all()
  85.         cpybox1 = gtk.HBox(False, 0)
  86.             image = gtk.Image()
  87.             image.set_from_stock(gtk.STOCK_COPY, gtk.ICON_SIZE_BUTTON)
  88.             label = gtk.Label(_('Copy to clipboard'))
  89.             cpybox1.add(image)
  90.             cpybox1.add(label)
  91.         self.copy_button = self.root.add(gnomecanvas.CanvasWidget, x = 80, y = 200, widget = self.cpybutt, 
  92.              width = 160, height = 30)
  93.            self.cpybutt.add(cpybox1)
  94.         self.cpybutt.show_all()
  95.  
  96.         self.urlbutt.connect("clicked", lambda w: self.open_online(hwdb_lock))
  97.         self.cpybutt.connect("clicked", lambda w: clip.set_text(hwdb_lock))
  98.         tt.set_tip(self.urlbutt, _('Click here to open a browser with your record on the database server'), '')
  99.         tt.set_tip(self.cpybutt, _('Click here to copy the id to the Gnome clipboard'), '')
  100.  
  101.         logo_img = gtk.gdk.pixbuf_new_from_file(Constants.DATADIR + "/hwdb.png") 
  102.         logo = (self.root.add(gnomecanvas.CanvasPixbuf, pixbuf = logo_img, 
  103.                      x = 50, y = 45, anchor = "nw"))
  104.         line = self.root.add(gnomecanvas.CanvasLine,
  105.                 points = [40,85, 400, 85],
  106.                 width_pixels = 1, 
  107.                 fill_color_rgba = 288581136)
  108.  
  109.         self.donetxt = self.root.add(gnomecanvas.CanvasText, 
  110.             markup = '<span size="12000"><b>%s:</b>\n'%_("Submission id")+hwdb_lock+'</span>\n\
  111.                 \n<span size="8500" color="#000000">%s</span>'%_("Attach this id to your bugreports or use it \nif you get online support.\nUse the 'Copy to clipboard' button to copy and \npaste the id or the 'Show online record' button to \naccess your online datasheet directly."), 
  112.             fill_color_rgba = 288581375, x = 250, y = 105)
  113.  
  114.         self.advance.set_sensitive(False)
  115.     else:
  116.             txt = "<big><b>%s</b></big>\n" % _("Hardware Database Collection")
  117.             txt += _("This is the %s hardware database collection tool.\n"
  118.                      "It obtains all possible data about your hardware,\n"
  119.                      "performs certain self-tests, and asks you some\n"
  120.                      "questions about the autodetected values.\n\n") % DISTRO
  121.             txt += "<b>%s</b>\n" % _("Online Submission")
  122.             txt += _("The collected data is submitted to the central\n"
  123.                      "%s hardware database for building a web-based\n"
  124.                      "information resource about supported hardware.\n"
  125.                      "(for detailed information about the collected data "
  126.                      "see help)\n\n") % DISTRO
  127.             txt += "<b>%s</b>\n"%_("Improvement")
  128.             txt += _("Developers use the collected data to fine tune "
  129.                      "autodetection \n"
  130.                      "and improve %s hardware support.  By submitting "
  131.                      "your hardware \n"
  132.                      "information to the central Ubuntu database, you will "
  133.                      "have \n"
  134.                      "online access to your data in the future.  No personal "
  135.                      "user information \n"
  136.                      "will be collected or transmitted through this process."
  137.                      "\n\n\t\t") % DISTRO
  138.             txt += _("Thank you for helping to improve %s.") % DISTRO
  139.             self.inittext = self.root.add(gnomecanvas.CanvasText, markup = txt,
  140.                         size = 8000, fill_color_rgba = self.i, x = 220, y = 140)
  141.         self.fadein(self.inittext)
  142.                     
  143.     self.win = self.wTree.get_widget("window")
  144.     self.win.set_resizable(False)
  145.     self.win.set_size_request(450,400)
  146.     self.win.set_icon_from_file(Constants.DATADIR + "/ubuntu_logo.png")
  147.     
  148.     #self.advance.grab_focus()
  149.  
  150.     help.connect("clicked", lambda w: gnome.help_display_uri ('ghelp:///usr/share/gnome/help/hwdb-client/C/hwdb-client.xml'))
  151.     cancel.connect("clicked", lambda w: gtk.main_quit())
  152.     self.win.connect("destroy", lambda w: gtk.main_quit())
  153.     self.advance.connect("clicked", lambda w: self.adv(self.xmlfile))
  154.     
  155.     def main(self):
  156.     gtk.main()
  157.  
  158.     def open_online(self, id):
  159.     gnome.url_show ('http://hwdb.ubuntu.com/?xml='+id)
  160.     gobject.timeout_add(1000, lambda: gtk.main_quit())
  161.  
  162.     def test(self, set):
  163.     self.netani = [] 
  164.     spk_ani = gtk.gdk.PixbufAnimation(Constants.DATADIR + "/speaker_shadow.gif") 
  165.     spk_img = gtk.image_new_from_animation(spk_ani)
  166.  
  167.     yes_img = gtk.gdk.pixbuf_new_from_file(Constants.DATADIR + "/yes.png") 
  168.     no_img = gtk.gdk.pixbuf_new_from_file(Constants.DATADIR + "/no.png") 
  169.     self.anibox = gtk.VBox(False, 0)
  170.     self.anibox.add(spk_img)
  171.     self.anibox.show_all()
  172.  
  173.         if set[1].startswith("Audio"):
  174.         gnome.sound_init("localhost")
  175.         gnome.sound_play(Constants.DATADIR + "/sound.wav")
  176.         devname = os.popen('cat /proc/asound/card0/id')
  177.         for line in devname:
  178.             self.devicename = line.strip()
  179.             set[2] = _("Testing detected soundcard: ") + self.devicename+"\n"+set[2]
  180.             if len(self.devdata) < 1:
  181.                     self.devdata.append(self.devicename)
  182.         self.canvasani = self.root.add(gnomecanvas.CanvasWidget, x = 40, y = 130, widget = self.anibox, 
  183.              width = 145, height = 160)
  184.         if not (self.redo.flags() & gtk.MAPPED):
  185.             self.repeat(set)
  186.             self.draw_content(set)
  187.         self.redo.set_sensitive(False)
  188.         gobject.timeout_add(1700, lambda: self.killani(set[1]))
  189.         gobject.timeout_add(1800, lambda: self.draw_yesno(set[1]))
  190.     
  191.       if set[1].startswith("Network") or set[1].startswith("Wireless"):
  192.         repflag = 0
  193.         netdevice = self.getroute()[len(self.getroute())-1].strip()
  194.         if not (self.redo.flags() & gtk.MAPPED):
  195.             self.repeat(set)
  196.             set[2] = set[2]+_(" On interface: ")+netdevice
  197.             self.draw_content(set)
  198.         else:
  199.             repflag = 1
  200.  
  201.         self.redo.set_sensitive(False)
  202.         command = 'LC_ALL=C fping '+self.getroute()[9]+' 2>/dev/null'
  203.          seq = 0    
  204.         flag = 0
  205.         while (seq < 4):
  206.                 while gtk.events_pending():
  207.                     gtk.main_iteration(True)
  208.             img = yes_img
  209.             timer = 0
  210.             for line in os.popen(command):
  211.                 fields = string.splitfields(line, 'is')
  212.             status = fields[1].strip()
  213.             if status.startswith('unreachable'):
  214.                 img = no_img
  215.                 timer = 1
  216.                 flag = flag +1
  217.             if timer == 0:
  218.                 i=0
  219.                 while i<500000:
  220.                     i = i + 1
  221.             if seq == 3:
  222.                 self.output.append(flag)
  223.                 self.comments.append(netdevice+" failures: "+str(flag))
  224.                 self.killnettest(set)
  225.                     self.devdata.append(netdevice)
  226.                 break
  227.             gnome.sound_init("localhost")
  228.             self.netani.append(self.root.add(gnomecanvas.CanvasPixbuf, pixbuf = img, 
  229.                      x = 50+(seq*130), y = 140, anchor = "nw"))
  230.             gnome.sound_play(Constants.DATADIR + "/ping.wav")
  231.             seq = seq+1
  232.         return
  233.  
  234.     def getroute(self):
  235.     for line in os.popen('route -n'):
  236.         if line.startswith('0.0.0.0'):
  237.             route = string.splitfields(line, ' ')
  238.     return route
  239.  
  240.     def get_xorgdata(self):
  241.         ati_brain_damage = []
  242.         command = 'xrandr -q'
  243.     for item in os.popen('lsmod|grep fglrx'):
  244.         ati_brain_damage.append(item)
  245.     if len(ati_brain_damage):
  246.         retval = _("\nDetected settings: impossible with fglrx")
  247.     else:
  248.             for line in os.popen(command):
  249.                 fields = string.splitfields(line, '  ')
  250.                 if fields[0].startswith('*'):
  251.                     freq = fields[4].strip('*')
  252.                     if fields[4].strip('*') == '\n':
  253.                         freq = "N/A"
  254.                     retval = _("\nDetected settings: ")+fields[1]+" @ "+freq+" Hz"
  255.                         self.devdata.append(fields[1].lstrip()+" @ "+fields[4].strip('*')+" Hz")
  256.     return retval
  257.     
  258.     def killani(self, set):
  259.     self.redo.set_sensitive(True)
  260.         self.canvasani.destroy()
  261.     return False
  262.    
  263.     def repeat(self, set):
  264.         repbox1 = gtk.HBox(False, 0)
  265.     image = gtk.Image()
  266.     image.set_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_BUTTON)
  267.     label = gtk.Label(_("Test again"))
  268.     repbox1.add(image)
  269.     repbox1.add(label)
  270.     self.redo.add(repbox1)
  271.     self.redobutt = self.root.add(gnomecanvas.CanvasWidget, x = 330, y = 80, widget = self.redo, 
  272.              width = 100, height = 30)
  273.     self.redo.show_all()
  274.  
  275.     self.redo.connect("clicked", lambda w: self.retest(set))
  276.  
  277.     def retest(self, set):
  278.     if set[1].startswith('Network') and (self.donetxt.flags() & gtk.MAPPED):
  279.         self.donetxt.destroy()
  280.             self.output.pop()
  281.             self.comments.pop()
  282.     else:
  283.             self.yesno_hide()
  284.     gnome.sound_init("localhost")
  285.     self.test(set)
  286.  
  287.     def killnettest(self, set):
  288.         i=0
  289.         while (i<3):
  290.             self.netani[i].destroy()
  291.         i=i+1
  292.     self.donetxt = self.root.add(gnomecanvas.CanvasText, 
  293.             markup = "<span size='16000'><b>%s</b></span>" % _("Test done, please proceed"), 
  294.             fill_color_rgba = 288581375, x = 230, y = 182)
  295.     self.redo.set_sensitive(True)
  296.     self.advance.set_sensitive(True)
  297.     #self.advance.grab_focus()
  298.     return False 
  299.  
  300.     def yesno_hide(self):
  301.     if self.yesno:
  302.         buffer = self.textview.get_buffer()
  303.         self.comments.append(buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter()))
  304.         if self.yesbutt.get_active():
  305.             self.output.append(0)
  306.         elif  self.partbutt.get_active():
  307.             self.output.append(1)
  308.         elif self.nobutt.get_active():
  309.             self.output.append(2)
  310.         else:
  311.               self.output.append(3)
  312.         self.yesno.destroy()
  313.         self.comtxt.destroy()
  314.         self.comwin.destroy()
  315.         self.combg.destroy()
  316.         
  317.     def draw_yesno(self, set):
  318.       tt = gtk.Tooltips()
  319.     i_out = gtk.Image()
  320.     if self.yesno:
  321.         self.yesno.destroy()
  322.         self.box1.destroy()
  323.         self.comtxt.destroy()
  324.         self.combg.destroy()
  325.  
  326.     self.yesbutt = gtk.RadioButton(None, _("Yes"))
  327.     self.yesbutt.connect("clicked", lambda w: i_out.set_from_file(Constants.DATADIR + "/true.png"))
  328.     self.nobutt = gtk.RadioButton(self.yesbutt, _("No"))
  329.     self.nobutt.connect("clicked", lambda w: i_out.set_from_file(Constants.DATADIR + "/false.png"))
  330.     self.partbutt = gtk.RadioButton(self.yesbutt, _("Partial"))
  331.     self.partbutt.connect("clicked", lambda w: i_out.set_from_file(Constants.DATADIR + "/partial.png"))
  332.     self.neutbutt = gtk.RadioButton(self.yesbutt, _("N/A"))
  333.     self.neutbutt.connect("clicked", lambda w: i_out.set_from_file(Constants.DATADIR + "/neutral.png"))
  334.  
  335.     self.yesbutt.connect("toggled", lambda w: self.advance.set_sensitive(True))
  336.     self.nobutt.connect("toggled", lambda w: self.advance.set_sensitive(True))
  337.     self.partbutt.connect("toggled", lambda w: self.advance.set_sensitive(False))
  338.     self.neutbutt.connect("toggled", lambda w: self.advance.set_sensitive(True))
  339.  
  340.     commentwin = gtk.gdk.pixbuf_new_from_file(Constants.DATADIR + "/comment_bg.png") 
  341.     i_out.set_from_file(Constants.DATADIR + "/true.png")
  342.  
  343.     self.box1 = gtk.VBox(False, 0)
  344.     self.hbox1 = gtk.HBox(False, 0)
  345.     self.box1.pack_start(self.yesbutt, False, False, 2)
  346.     self.box1.pack_start(self.partbutt, False, False, 2)
  347.     self.box1.pack_start(self.nobutt, False, False, 2)
  348.     self.box1.pack_start(self.neutbutt, False, False, 2)
  349.  
  350.     self.hbox1.pack_start(i_out, False, False, 10)
  351.     self.hbox1.pack_start(self.box1, False, False, 0)
  352.     self.hbox1.show_all()
  353.  
  354.         self.yesno = self.root.add(gnomecanvas.CanvasWidget, x = 40, y = 160, widget = self.hbox1, 
  355.                 width = 140, height = 100) 
  356.     self.comtxt = self.root.add(gnomecanvas.CanvasText, 
  357.             markup = "<span size='10000'><b>%s</b></span>" % _("Comments:"), 
  358.             fill_color_rgba = 288581375, x = 225, y = 135)
  359.     self.combg = (self.root.add(gnomecanvas.CanvasPixbuf, pixbuf = commentwin, 
  360.                      x = 175, y = 140, anchor = "nw"))
  361.     self.comwin = gtk.ScrolledWindow(None, None)
  362.     self.comwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
  363.     self.textview = gtk.TextView()
  364.     self.textview.set_editable(True)
  365.     self.textview.set_cursor_visible(True)
  366.     self.textview.set_wrap_mode(gtk.WRAP_WORD)
  367.     self.comwin.add(self.textview)
  368.     self.comwin.show_all()
  369.     
  370.     buffer = self.textview.get_buffer()
  371.     buffer.connect("changed", lambda w: self.buffoc(buffer))
  372.  
  373.         self.comrtf = self.root.add(gnomecanvas.CanvasWidget, x = 185, y = 150, widget = self.comwin, width = 220, height = 120) 
  374.     
  375.     tt.set_tip(self.yesbutt, _("The device was automatically detected and is functioning properly"), '')
  376.     tt.set_tip(self.nobutt, _("The device is not functioning at all"), '')
  377.     tt.set_tip(self.partbutt, _("The device is functioning, but not fully, or it required manual configuration (please explain in comment)"), '')
  378.     tt.set_tip(self.neutbutt, _("The device is not available"), '')
  379.     tt.enable()
  380.  
  381.     self.advance.set_sensitive(True)
  382.     #self.advance.grab_focus()
  383.    
  384.     def buffoc(self, buffer):
  385.         if buffer.get_char_count() and self.partbutt.get_active(): 
  386.         self.advance.set_sensitive(True)
  387.     elif self.yesbutt.get_active() or self.nobutt.get_active() or self.neutbutt.get_active():
  388.         self.advance.set_sensitive(True)
  389.     else:
  390.         self.advance.set_sensitive(False)
  391.  
  392.     def draw_commentwin(self):
  393.     self.advance.set_sensitive(True)
  394.     scrwin = gtk.ScrolledWindow(None, None)
  395.     scrwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
  396.     self.co_textview.set_editable(True)
  397.     self.co_textview.set_cursor_visible(True)
  398.     self.co_textview.set_wrap_mode(gtk.WRAP_WORD)
  399.     scrwin.add(self.co_textview)
  400.     scrwin.show_all()
  401.  
  402.     c_win = gtk.gdk.pixbuf_new_from_file(Constants.DATADIR + "/full_comment_bg.png") 
  403.     self.cont_rec = (self.root.add(gnomecanvas.CanvasPixbuf, pixbuf = c_win, 
  404.                      x = 80, y = 120, anchor = "nw"))
  405.  
  406.         self.cont_inp = self.root.add(gnomecanvas.CanvasWidget, x = 95, y = 130, widget = scrwin, 
  407.                 width = 265, height = 150) 
  408.  
  409.     #self.advance.grab_focus()
  410.  
  411.     def draw_content(self, set):
  412.     if self.cont_txt:
  413.         self.cont_txt.hide()
  414.     if self.hline:
  415.         self.hline.hide()
  416.     # text area too small for e-mail text in gtk frontend, trim it -- jriddell
  417.         if set[1].startswith("Your"):
  418.             split = set[2].split("  ")
  419.             set[2] = split[0]
  420.     self.cont_txt = self.root.add(gnomecanvas.CanvasRichText, x = 30, y = 70, width = 300, height = 180, 
  421.                 text = set[2], cursor_visible = False, grow_height = True) 
  422.     self.hline = self.root.add(gnomecanvas.CanvasLine,
  423.                 points = [30,120, 430, 120],
  424.                 width_pixels = 1, 
  425.                 fill_color_rgba = 288581136)
  426.     gtk.rc_reset_styles(gtk.settings_get_default())
  427.     
  428.     def draw_header(self, set):
  429.     if self.headtxt:
  430.         self.fadeout(self.headtxt)
  431.     if self.headericon:
  432.         self.headericon.hide()
  433.  
  434.     icon_pixbuf = gtk.gdk.pixbuf_new_from_file(Constants.DATADIR + "/"+set[0]) 
  435.     head_pixbuf = gtk.gdk.pixbuf_new_from_file(Constants.DATADIR + "/header_bg.png") 
  436.  
  437.     self.headerbg = self.root.add(gnomecanvas.CanvasPixbuf, pixbuf = head_pixbuf, 
  438.          x = 24, y = 26, anchor = "nw")
  439.     self.headtxt = self.root.add(gnomecanvas.CanvasText, markup = "<span size='20000'><b>"+set[1]+"</b></span>", 
  440.                 fill_color_rgba = 288581375, x = 230, y = 42)
  441.     self.headericon = self.root.add(gnomecanvas.CanvasPixbuf, pixbuf = icon_pixbuf, 
  442.          x = 40, y = 15, anchor = "nw")
  443.         
  444.     def propstrip(self, line, type):
  445.             line = line.rstrip("</property>\n")
  446.         line = line.lstrip('<property name="'+type+'">')
  447.         return _(line.strip())
  448.  
  449.     def fadein(self, text):
  450.         self.i = self.i-538976288
  451.             while self.i > 0:
  452.             while gtk.events_pending():
  453.                 gtk.main_iteration(1)
  454.             if self.i <= 0:
  455.             self.i = 0
  456.                 text.set(fill_color_rgba = self.i)   
  457.             self.i = self.i-353703189
  458.         return 1
  459.  
  460.     def fadeout(self, text):
  461.         self.i = 1
  462.         while self.i <= 4294967040:
  463.             while gtk.events_pending():
  464.                     gtk.main_iteration(1)
  465.                 text.set(fill_color_rgba = self.i)   
  466.             self.i = self.i+623191333
  467.         text.hide()
  468.         return 1
  469.  
  470.     def assemble(self):
  471.         self.datapipe = []
  472.         self.pbar = gtk.ProgressBar()
  473.         self.as_bar = self.root.add(gnomecanvas.CanvasWidget, x = 60, y = 175, widget = self.pbar, 
  474.                 width = 350, height = 24) 
  475.  
  476.     self.pbar.show()
  477.  
  478.     self.timer = gobject.timeout_add (100, lambda w: self.pulsator(), self)
  479.     while gtk.events_pending():
  480.             gtk.main_iteration(True)
  481.  
  482.     for line in os.popen('/usr/bin/hwdb-xml -a'):
  483.         self.datapipe.append(line)
  484.         while gtk.events_pending():
  485.                 gtk.main_iteration(True)
  486.     
  487.     self.datapipe.append("<!--<quadata>\n")
  488.     i = 0
  489.     for line in open(self.xmlfile, 'r'):
  490.         line = line.strip()
  491.         if line.startswith('<property name="title">'):
  492.             line = self.propstrip(line, 'title')
  493.             if not line.startswith("Assembling"):
  494.                 line = line.rstrip()
  495.                 self.datapipe.append("<question id=\""+line.lower()+"\">\n")
  496.                 if not line.startswith("Comments") and not line.startswith("Your"):
  497.                     self.datapipe.append(" <result>"+str(self.output[i])+"</result>\n")
  498.                         self.datapipe.append("  <detected>"+str(self.devdata[i])+"</detected>\n")
  499.                 self.datapipe.append(" <comment>"+str(self.comments[i])+"</comment>\n")
  500.                 self.datapipe.append("</question>\n")
  501.                 i = i + 1
  502.     self.datapipe.append("</quadata>\n-->\n")
  503.  
  504.     while gtk.events_pending():
  505.             gtk.main_iteration(True)
  506.  
  507.         self.datapipe.append("<!--<distroData>\n")
  508.  
  509.         for distro in [ "kubuntu", "ubuntu", "edubuntu", "xubuntu" ]:
  510.              if os.path.exists("/var/lib/dpkg/info/" + distro + "-desktop.list"):
  511.                  self.datapipe.append("  <installed>"+distro+"</installed>\n")
  512.  
  513.         self.datapipe.append("</distroData>\n-->\n")
  514.  
  515.     while gtk.events_pending():
  516.             gtk.main_iteration(True)
  517.  
  518.     self.timeout = gobject.timeout_add (5000, lambda w: self.hidepulse(), self)
  519.     
  520.     def pulsator(self):
  521.     self.pbar.pulse()
  522.     return True
  523.  
  524.     def hidepulse(self):
  525.  
  526.     #####################################################
  527.     # call hwdb-send here (print to tmpfile)        #
  528.     #####################################################
  529.  
  530.      self.pbar.hide()
  531.     self.donetxt = self.root.add(gnomecanvas.CanvasText, 
  532.             markup = "<span size='16000'><b>Thank you for your contribution</b></span>", 
  533.             fill_color_rgba = 288581375, x = 230, y = 182)
  534.  
  535.     sendpipe = open('/tmp/hwdb_data.xml', 'w')
  536.  
  537.     for line in self.datapipe:
  538.         while gtk.events_pending():
  539.         gtk.main_iteration(True)
  540.         sendpipe.write(line)
  541.     sendpipe.close()
  542.     os.spawnl(os.P_NOWAIT, '/usr/bin/hwdb-send')
  543.  
  544.     gtk.main_quit()
  545.     return False
  546.  
  547.     def adv(self, xmlfile):
  548.         elem = 0
  549.     set = []
  550.   
  551.     self.advance.set_sensitive(False)
  552.     self.fadeout(self.inittext)
  553.  
  554.     if (self.yesbutt.flags() & gtk.MAPPED):
  555.         self.yesno_hide()
  556.  
  557.     if (self.redo.flags() & gtk.MAPPED):
  558.         self.redo.destroy()
  559.     
  560.     if (self.co_textview.flags() & gtk.MAPPED):
  561.         buffer = self.co_textview.get_buffer()
  562.         self.comments.append(buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter()))
  563.         self.cont_rec.destroy()
  564.         self.cont_inp.destroy()
  565.     
  566.     self.step = self.step + 1
  567.     for line in open(xmlfile, 'r'):
  568.         line = line.strip()
  569.         if line.startswith('<advmark step="'+str(self.step)+'"'):
  570.             elem = 1
  571.             newline = line.rsplit("=", 1)
  572.             showline = newline[1].strip('\">\n')
  573.             set.append(showline+".png")
  574.         if elem == 1:
  575.             if line.startswith('<property name="title">'):
  576.                 line = self.propstrip(line, 'title')
  577.                 set.append(line.strip())
  578.             if line.startswith('<property name="content">'):
  579.                 line = self.propstrip(line, 'content')
  580.                 set.append(line.strip())
  581.         if line.startswith("</advmark>"):
  582.             elem = 0
  583.             
  584.     if len(set) >= 1:
  585.         self.draw_header(set)
  586.         if self.donetxt:
  587.             self.donetxt.hide()
  588.         if not set[1].startswith("Comments") and \
  589.             not set[1].endswith("Test") and \
  590.             not set[1].startswith("Video") and \
  591.             not set[1].startswith("Your") and \
  592.             not set[1].startswith("Assembling"):
  593.             self.devdata.append('null')
  594.             self.draw_content(set)
  595.             self.draw_yesno(set)
  596.         elif set[1].startswith("Video"):
  597.             set[2] = set[2]+self.get_xorgdata()
  598.             self.draw_content(set)
  599.             self.draw_yesno(set)
  600.         elif set[1].endswith("Test"):
  601.             self.test(set)
  602.         elif set[1].startswith("Assembling"):
  603.             self.draw_content(set)
  604.             self.assemble()
  605.         else:
  606.             self.draw_content(set)
  607.             self.draw_commentwin()
  608.             self.devdata.append('null')
  609.  
  610. if __name__ == "__main__":
  611.  
  612.     localesApp="hwdb-client"
  613.     localesDir="/usr/share/locale"
  614.     locale.setlocale(locale.LC_ALL, '')
  615.     gettext.bindtextdomain(localesApp, localesDir)
  616.     gettext.textdomain(localesApp)
  617.     
  618.     base = Collector()
  619.     base.main()
  620.