Skip to content

Commit

Permalink
feat: Add SSL/TLS support for QUADS WP Wiki.
Browse files Browse the repository at this point in the history
This adds SSL/TLS support for the Python XMLRPC client used in
regenerate_wiki methods.

fixes: #401

Change-Id: I78ce230623be80c509cf0f95b1e08627c07ee6ad
  • Loading branch information
sadsfae authored and grafuls committed Feb 1, 2022
1 parent 980ae5b commit 1c81c04
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
3 changes: 1 addition & 2 deletions conf/quads.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ ircbot_port: 5050
ircbot_channel: #yourchannel

# wordpress wiki
wp_wiki: http://wiki.example.com/xmlrpc.php
wp_wiki: https://wiki.example.com/xmlrpc.php
wp_username: wikiadmin
wp_password: wikipassword

# you will have to know your wordpress page ID for the main and assignment pages
wp_wiki_main_title: Lab Dashboard
wp_wiki_main_page_id: 4
Expand Down
23 changes: 19 additions & 4 deletions quads/tools/racks_wiki.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
#!/usr/bin/python3
# Update an existing wordpress page with generated markdown
# Assumes you have a markdown file with content you want published
# to an existing wordpress page.
# requires: python-wordpress-xmlrpc or python3-wordpress-xmlrpc

from wordpress_xmlrpc import Client, WordPressPage
from wordpress_xmlrpc.methods.posts import EditPost
from urllib.parse import urlparse

import argparse
import ssl


def update_wiki(url, username, password, _page_title, _page_id, _markdown):
"""
Update an existing wordpress page with generated markdown.
Assumes you have a markdown file with content you want published
to an existing wordpress page.
requires: python-wordpress-xmlrpc or python3-wordpress-xmlrpc
:param url: wordpress xmlrpc endpoint
:param username: wordpress username
:param password: wordpress password
:param _page_title: post page title
:param _page_id: post page id
:param _markdown: path to markdown file for upload
"""
scheme = urlparse(url)[0]
if scheme == "https":
ssl._create_default_https_context = ssl._create_unverified_context

wp = Client(url, username, password)

# define pages variable
Expand Down
5 changes: 3 additions & 2 deletions quads/tools/regenerate_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
wp_wiki_git_manage = conf["wp_wiki_git_manage"]
wp_wiki_git_repo_path = conf["wp_wiki_git_repo_path"]


logger = logging.getLogger(__name__)

if __name__ == "__main__":
Expand All @@ -40,7 +41,7 @@

try:
racks_wiki.update_wiki(
url="http://%s/xmlrpc.php" % wp_wiki,
url=wp_wiki,
username=wp_username,
password=wp_password,
_page_title=wp_wiki_main_title,
Expand Down Expand Up @@ -68,7 +69,7 @@

try:
racks_wiki.update_wiki(
url="http://%s/xmlrpc.php" % wp_wiki,
url=wp_wiki,
username=wp_username,
password=wp_password,
_page_title=wp_wiki_assignments_title,
Expand Down

0 comments on commit 1c81c04

Please sign in to comment.