From 5ecfb2a37b772c37513a27ac58ae07d584968172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?GOLDERWEB=20=E2=80=93=20Jonathan=20Golder?= Date: Mon, 11 Jul 2016 22:08:27 +0200 Subject: [PATCH] Catch import Error due to change in pywikibot In master branch of pywikibot the logging related stuff is moved to a new module pywikibot.logging. As we want to be compatible to both the master (for use of shared pywikibot on labs) and also the 2.0 branch we need to catch this [https://fs.golderweb.de/index.php?do=details&task_id=58 FS#58] pywikibot-core commit d7d7a14 --- jogobot.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/jogobot.py b/jogobot.py index aa8692d..d0a5628 100644 --- a/jogobot.py +++ b/jogobot.py @@ -30,8 +30,16 @@ from subprocess import Popen, PIPE, TimeoutExpired import pywikibot -from pywikibot.bot import( - DEBUG, INFO, WARNING, ERROR, CRITICAL, STDOUT, VERBOSE, logoutput ) +# Location of logging related stuff in pywikibot was changed with +# commit d7d7a14 on Mon Sep 7 14:41:43 2015 +# This is to be compatible with recent versions as well as 2.0-branch +try: + from pywikibot.logging import( + DEBUG, INFO, WARNING, ERROR, CRITICAL, STDOUT, VERBOSE, logoutput ) +except( ImportError ): + # Legacy support (pywikibot 2.0 branch) + from pywikibot.bot import( + DEBUG, INFO, WARNING, ERROR, CRITICAL, STDOUT, VERBOSE, logoutput ) from jogobot.config import config