chiark / gitweb /
wiki: move checkupdates wiki log to separate function
authorHans-Christoph Steiner <hans@eds.org>
Wed, 17 Jan 2018 20:11:32 +0000 (21:11 +0100)
committerHans-Christoph Steiner <hans@eds.org>
Mon, 22 Jan 2018 12:49:10 +0000 (13:49 +0100)
fdroidserver/checkupdates.py

index 861324ab3ec349986167f7c5551e77a10f9b59f6..876dd2aeb978d6707ea1d90e81f28938fe6e46be 100644 (file)
@@ -511,6 +511,37 @@ def checkupdates_app(app):
                 raise FDroidException("Git commit failed")
 
 
+def update_wiki(gplaylog, locallog):
+    if config.get('wiki_server') and config.get('wiki_path'):
+        try:
+            import mwclient
+            site = mwclient.Site((config['wiki_protocol'], config['wiki_server']),
+                                 path=config['wiki_path'])
+            site.login(config['wiki_user'], config['wiki_password'])
+
+            # Write a page with the last build log for this version code
+            wiki_page_path = 'checkupdates_' + time.strftime('%s', start_timestamp)
+            newpage = site.Pages[wiki_page_path]
+            txt = ''
+            txt += "* command line: <code>" + ' '.join(sys.argv) + "</code>\n"
+            txt += "* started at " + common.get_wiki_timestamp(start_timestamp) + '\n'
+            txt += "* completed at " + common.get_wiki_timestamp() + '\n'
+            txt += "\n\n"
+            txt += common.get_android_tools_version_log()
+            txt += "\n\n"
+            if gplaylog:
+                txt += '== --gplay check ==\n\n'
+                txt += gplaylog
+            if locallog:
+                txt += '== local source check ==\n\n'
+                txt += locallog
+            newpage.save(txt, summary='Run log')
+            newpage = site.Pages['checkupdates']
+            newpage.save('#REDIRECT [[' + wiki_page_path + ']]', summary='Update redirect')
+        except Exception as e:
+            logging.error(_('Error while attempting to publish log: %s') % e)
+
+
 config = None
 options = None
 start_timestamp = time.gmtime()
@@ -568,6 +599,7 @@ def main():
                     else:
                         logging.info("{0} has the same version {1} on the Play Store"
                                      .format(common.getappname(app), version))
+        update_wiki(gplaylog, None)
         return
 
     locallog = ''
@@ -588,34 +620,7 @@ def main():
             logging.error(msg)
             locallog += msg + '\n'
 
-    if config.get('wiki_server') and config.get('wiki_path'):
-        try:
-            import mwclient
-            site = mwclient.Site((config['wiki_protocol'], config['wiki_server']),
-                                 path=config['wiki_path'])
-            site.login(config['wiki_user'], config['wiki_password'])
-
-            # Write a page with the last build log for this version code
-            wiki_page_path = 'checkupdates_' + time.strftime('%s', start_timestamp)
-            newpage = site.Pages[wiki_page_path]
-            txt = ''
-            txt += "* command line: <code>" + ' '.join(sys.argv) + "</code>\n"
-            txt += "* started at " + common.get_wiki_timestamp(start_timestamp) + '\n'
-            txt += "* completed at " + common.get_wiki_timestamp() + '\n'
-            txt += "\n\n"
-            txt += common.get_android_tools_version_log()
-            txt += "\n\n"
-            if gplaylog:
-                txt += '== --gplay check ==\n\n'
-                txt += gplaylog
-            if locallog:
-                txt += '== local source check ==\n\n'
-                txt += locallog
-            newpage.save(txt, summary='Run log')
-            newpage = site.Pages['checkupdates']
-            newpage.save('#REDIRECT [[' + wiki_page_path + ']]', summary='Update redirect')
-        except Exception as e:
-            logging.error(_('Error while attempting to publish log: %s') % e)
+    update_wiki(None, locallog)
 
     logging.info(_("Finished"))