-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On Sun, 7 Sep 2008 18:18:05 +0200
Sandro Tosi [EMAIL PROTECTED] wrote:
All applied as of r650.
Right after inserting bug text:
Traceback (most recent call last):
File /usr/lib/python2.5/site-packages/reportbug/ui/gtk2_ui.py,
line 1119, in on_prepare
self.showing_page.setup_focus ()
File /usr/lib/python2.5/site-packages/reportbug/ui/gtk2_ui.py,
line 1034, in setup_focus
if self.default:
AttributeError: 'SelectOptionsPage' object has no attribute 'default'
Sandro
I've forgotten the patches again, I'm sorry.
- --
http://syx.googlecode.com - Smalltalk YX
http://lethalman.blogspot.com - Thoughts about computer technologies
http://www.ammazzatecitutti.org - Ammazzateci tutti
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkjEFhgACgkQw9Qj+8Kak3EqZQCeO3JHfKdndN09+PADTnV3Ex7U
6FIAnAv97sEswyya+EV3zqv9FwPvedo+
=bJ0B
-END PGP SIGNATURE-
From 527206e1e97b77ced5bc074283c76ea9dc4db193 Mon Sep 17 00:00:00 2001
From: Luca Bruno [EMAIL PROTECTED]
Date: Sun, 7 Sep 2008 19:51:46 +0200
Subject: [PATCH] Fix handle_bugscript to use the UI.
---
bin/reportbug | 70 +-
handle_bugscript| 54 +---
reportbug/tempfiles.py |7 +
reportbug/ui/gtk2_ui.py |4 +++
4 files changed, 105 insertions(+), 30 deletions(-)
diff --git a/bin/reportbug b/bin/reportbug
index 2414ce4..2f75646 100755
--- a/bin/reportbug
+++ b/bin/reportbug
@@ -47,6 +47,7 @@ from reportbug.utils import (
)
from reportbug.tempfiles import (
TempFile,
+TempFifo,
tempfile_prefix,
cleanup_temp_file,
)
@@ -286,6 +287,72 @@ def handle_editing(filename, dmessage, options, sendto, attachments, package,
return open(filename).read()
+class BugScript (object):
+def __init__ (self, fifo):
+self.fifo = fifo
+self.message =
+
+def yes_no (self, arg):
+default = arg.rsplit(' ', 1)[-1]
+prompt = arg[:-len(default)].strip ()
+prompt = re.sub ('\[[yYnN/yYnN]\]', '', prompt).strip ()
+if prompt[-1] == '?':
+prompt = prompt[:-1]
+res = ui.yes_no (prompt, Yes, No, default=default == 'yep')
+if res:
+return 'yep'
+else:
+return 'nop'
+
+def append_message (self, line):
+self.message += line
+
+def long_message (self, arg=None):
+if self.message:
+ui.long_message (self.message)
+self.message =
+
+def handle_command (self, command):
+op = command.split(' ', 1)[0].strip ()
+arg = command[len(op):].strip ()
+if op == 'end':
+os.unlink (self.fifo)
+return
+if op == 'append_message':
+self.append_message (arg)
+return
+
+# Show the message before each command
+self.long_message ()
+# Run the operation
+result = getattr(self, op)(arg)
+
+if result is not None:
+fifo = os.open (self.fifo, os.O_WRONLY)
+os.write (fifo, result)
+os.close (fifo)
+
+def run (self):
+while True:
+try:
+fifo = os.fdopen (os.open (self.fifo, os.O_RDONLY), r)
+except:
+break
+
+commands = []
+for line in fifo.readlines ():
+commands.append (line)
+
+fifo.close ()
+for command in commands:
+self.handle_command (command)
+
+def handle_bugscript (file, *args):
+# We act as an UI server for the bugscript
+fifo = TempFifo (bugscript)
+os.spawnl (os.P_NOWAIT, file, file, *(args + (fifo,)))
+BugScript(fifo).run ()
+
def find_package_for(filename, notatty=False, pathonly=False):
ewrite(Finding package for '%s'...\n, filename)
(newfilename, packages) = utils.find_package_for(filename, pathonly)
@@ -1684,8 +1751,7 @@ orphaned for a long period of time are often removed from the archive.\n''')
fh, filename = TempFile(prefix=tfprefix)
fh.close()
-system('%s %s %s' % (handler, commands.mkarg(bugexec),
- commands.mkarg(filename)))
+handle_bugscript(handler, bugexec, filename)
addinfo = None
if not self.options.noconf:
diff --git a/handle_bugscript b/handle_bugscript
index 66c89cd..c519021 100755
--- a/handle_bugscript
+++ b/handle_bugscript
@@ -14,14 +14,32 @@
set -e
+export FIFO=$3
+
+# Replace the original cat for backward compatibility
+cat()
+{
+if [ -n $1 ]; then
+/usr/bin/env cat $@
+return
+fi
+
+while [ $? -eq 0 ]; do
+read -r WE
+if [ -z $WE ]; then
+return
+fi
+echo $WE
+echo append_message $WE $FIFO
+done
+}
+
+export -f cat
+
# Wait for a keypress and put it in $KEY