From ac199038a93bdb0c0d010fa8862bf1c677bec0c2 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sun, 29 Dec 2013 23:41:35 +0530 Subject: Added src/gns_wiki.py. This has functions that pushes a wiki page to a wiki using XML-RPC. Functions in gns_wiki.py: update, generate_wiki_page. --- src/differences-with-debian.txt | 9 +++++++ src/gns_wiki.py | 57 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/differences-with-debian.txt create mode 100644 src/gns_wiki.py (limited to 'src') diff --git a/src/differences-with-debian.txt b/src/differences-with-debian.txt new file mode 100644 index 0000000..063cec7 --- /dev/null +++ b/src/differences-with-debian.txt @@ -0,0 +1,9 @@ += Differences With Debian = + +/* This page is generated by a script. Don't manually edit this page.*/ + +This page documents the differences between Debian squeeze and gNewSense Parkes. + +{{{#!wiki caution +This page is not complete yet. [[https://savannah.nongnu.org/task/?12794|Work in progress]]. +}}} diff --git a/src/gns_wiki.py b/src/gns_wiki.py new file mode 100644 index 0000000..aee41ac --- /dev/null +++ b/src/gns_wiki.py @@ -0,0 +1,57 @@ +# Copyright 2013 rsiddharth +# +# This work is free. You can redistribute it and/or modify it under +# the terms of the Do What The Fuck You Want To Public License, +# Version 2, as published by Sam Hocevar. See the COPYING file or +# for more details. + +import xmlrpclib as xmlrpc +from xmlrpclib import Fault + +def update(table): + """ + Generates wiki page using table and pushes it to the wiki using XML-RPC. + """ + + # Code below adapted from + # http://moinmo.in/MoinAPI/Examples#xmlrpc.putPage.28.29 + + name = raw_input("username> ") + password = raw_input("pass> ") + wikiurl = "http://localhost/m" + homewiki = xmlrpc.ServerProxy(wikiurl + "?action=xmlrpc2", + allow_none=True) + auth_token = homewiki.getAuthToken(name, password) + mc = xmlrpc.MultiCall(homewiki) + mc.applyAuthToken(auth_token) + pagename = "Documentation/3/DifferencesWithDebian" + page_content = generate_wiki_page(table) + mc.putPage(pagename, page_content) + result = mc() + + try: + sucess, raw = tuple(result) + + if sucess: + print "Updated %s" % pagename + else: + print "Something went wrong. Please report this issue." + + except Fault: + print "Nothing new. %s/%s was not updated" % (wikiurl, + pagename) + +def generate_wiki_page(table): + """ + Generates the wiki page using the table. + + `differences-with-debian.txt' file, used by this function, + contains text that precedes the table. + """ + + page_content = open("src/differences-with-debian.txt", "r").read() + "\n" + + for row in table: + page_content += row + "\n" + + return page_content -- cgit v1.2.3