mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-15 15:32:30 +03:00
wiki: log checkupdates start/stop time and command line for each run
This commit is contained in:
parent
df51a6e999
commit
fc4f5a79a7
2 changed files with 28 additions and 2 deletions
|
@ -23,6 +23,7 @@ import urllib.request
|
||||||
import urllib.error
|
import urllib.error
|
||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
import traceback
|
import traceback
|
||||||
import html
|
import html
|
||||||
|
@ -512,6 +513,7 @@ def checkupdates_app(app):
|
||||||
|
|
||||||
config = None
|
config = None
|
||||||
options = None
|
options = None
|
||||||
|
start_timestamp = time.gmtime()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -580,6 +582,27 @@ def main():
|
||||||
logging.error(_("...checkupdate failed for {appid} : {error}")
|
logging.error(_("...checkupdate failed for {appid} : {error}")
|
||||||
.format(appid=appid, error=e))
|
.format(appid=appid, error=e))
|
||||||
|
|
||||||
|
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"
|
||||||
|
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)
|
||||||
|
|
||||||
logging.info(_("Finished"))
|
logging.info(_("Finished"))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3012,6 +3012,9 @@ def get_examples_dir():
|
||||||
return examplesdir
|
return examplesdir
|
||||||
|
|
||||||
|
|
||||||
def get_wiki_timestamp():
|
def get_wiki_timestamp(timestamp=None):
|
||||||
"""Return current time in the standard format for posting to the wiki"""
|
"""Return current time in the standard format for posting to the wiki"""
|
||||||
return time.strftime("%Y-%m-%d %H:%M:%SZ", time.gmtime())
|
|
||||||
|
if timestamp is None:
|
||||||
|
timestamp = time.gmtime()
|
||||||
|
return time.strftime("%Y-%m-%d %H:%M:%SZ", timestamp)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue