summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <rsiddharth@ninthfloor.org>2013-12-29 23:41:35 +0530
committerrsiddharth <rsiddharth@ninthfloor.org>2013-12-29 23:41:35 +0530
commitac199038a93bdb0c0d010fa8862bf1c677bec0c2 (patch)
tree50e48412ec9e2e668dfbb6361a9ca82520f87f46
parentbcb2aa5be7096182c0aea754d9f592ea846a0282 (diff)
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.
-rw-r--r--src/differences-with-debian.txt9
-rw-r--r--src/gns_wiki.py57
2 files changed, 66 insertions, 0 deletions
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 <rsiddharth@ninthfloor.org>
+#
+# 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
+# <http://www.wtfpl.net/> 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