Skip to content

Commit

Permalink
Show the xml parsing error if it encounters it, so the user can
Browse files Browse the repository at this point in the history
double check the output the next time they run the dialog and
click the gear icon so they can fix the code in their pipemenu
scripts.
  • Loading branch information
ShadowKyogre committed Sep 7, 2015
1 parent 4492c17 commit 26fd4c9
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions new-editor/cb-editor
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,25 @@ class CBEditor(gtk.Window):
if response==gtk.RESPONSE_ACCEPT:
process=subprocess.Popen(shlex.split(os.path.expanduser(input.entry.props.text)), \
stdout=subprocess.PIPE)
dummy_menu=etree.fromstring("<menu name='Dummy'>%s</menu>" % process.communicate()[0])
self.recursive_generate(widget, dummy_menu)
dialog.destroy()
try:
stdout = process.communicate()[0]
dummy_txt = "<menu name='Dummy'>{}</menu>".format(stdout)
dummy_menu=etree.fromstring("<menu name='Dummy'>{}</menu>".format(stdout))
self.recursive_generate(widget, dummy_menu)
dialog.destroy()
except etree.XMLSyntaxError as e:
message = gtk.MessageDialog(parent=self, flags=0,
type=gtk.MESSAGE_ERROR,
buttons=gtk.BUTTONS_OK, message_format=None)
msg = ("{}\n\nClick the gear icon in the dialog to check"
" pipe output.").format(e.msg)
message.set_markup(msg)
message.run()
message.destroy()
finally:
dialog.destroy()
else:
dialog.destroy()

def make_new_item(self, widget, element_type, nd=None, parent=None):
if element_type != 'Menu File':
Expand Down

0 comments on commit 26fd4c9

Please sign in to comment.