jenkins-bot has submitted this change and it was merged.
Change subject: editor depends on tkinter and idlelib
......................................................................
editor depends on tkinter and idlelib
Catch import error loading tkinter and idlelib.
Bug: 70703
Change-Id: I867c39d3666aef92d9a689caf66dae1567bd8bbb
---
M pywikibot/editor.py
M scripts/upload.py
2 files changed, 21 insertions(+), 7 deletions(-)
Approvals:
Nullzero: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/editor.py b/pywikibot/editor.py
index fd00b12..440dadc 100644
--- a/pywikibot/editor.py
+++ b/pywikibot/editor.py
@@ -109,9 +109,19 @@
newcontent = temp_file.read()
os.unlink(tempFilename)
return self.restoreLinebreaks(newcontent)
- else:
- return self.restoreLinebreaks(
- pywikibot.ui.editText(
- text,
- jumpIndex=jumpIndex,
- highlight=highlight))
+
+ try:
+ import gui # noqa
+ except ImportError as e:
+ raise pywikibot.Error(
+ 'Could not load GUI modules: %s\nNo editor available.\n'
+ 'Set your favourite editor in user-config.py "editor", '
+ 'or install python packages tkinter and idlelib, which '
+ 'are typically part of Python but may be packaged separately '
+ 'on your platform.\n' % e)
+
+ return self.restoreLinebreaks(
+ pywikibot.ui.editText(
+ text,
+ jumpIndex=jumpIndex,
+ highlight=highlight))
diff --git a/scripts/upload.py b/scripts/upload.py
index 90cb164..398d84d 100755
--- a/scripts/upload.py
+++ b/scripts/upload.py
@@ -218,7 +218,11 @@
default=not self.description):
from pywikibot import editor as editarticle
editor = editarticle.TextEditor()
- newDescription = editor.edit(self.description)
+ try:
+ newDescription = editor.edit(self.description)
+ except Exception as e:
+ pywikibot.error(e)
+ continue
# if user saved / didn't press Cancel
if newDescription:
self.description = newDescription
--
To view, visit https://gerrit.wikimedia.org/r/172119
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I867c39d3666aef92d9a689caf66dae1567bd8bbb
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: Nullzero <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits