Skip to content

Commit

Permalink
Fixed #288: stop updating wiki in library-maint
Browse files Browse the repository at this point in the history
  • Loading branch information
rgaudin committed Nov 1, 2024
1 parent 4f50f08 commit 81550b2
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 138 deletions.
11 changes: 0 additions & 11 deletions zim/library-mgmt/library-generator.cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,6 @@ spec:
value: "http://library-frontend-service"
- name: MIRRORBRAIN_URL
value: "http://mirrorbrain-web-service"
- name: WIKI_DOMAIN
value: "wiki.kiwix.org"
- name: WIKI_USERNAME
value: "Reg@library-maint"
- name: WIKI_PASSWORD
valueFrom:
secretKeyRef:
name: wiki-credentials
key: password
- name: WIKI_PAGE
value: "Template:ZIMdumps/content"
- name: ZIM_DIRENTLOOKUPCACHE
value: "1"
volumeMounts:
Expand Down
84 changes: 0 additions & 84 deletions zim/library-mgmt/library-maint.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from dataclasses import dataclass
from typing import Any, Dict, Generator, Tuple, List

import mwclient
import requests
from lxml import etree
from humanfriendly import format_size as human_size
Expand Down Expand Up @@ -84,11 +83,6 @@ class Defaults:

VARNISH_URL = "http://localhost"

WIKI_DOMAIN = "wiki.kiwix.org"
WIKI_USERNAME = "bot"
WIKI_PASSWORD = "notset"
WIKI_PAGE = "notset"

OFFSPOT_LIBRARY = "/data/download/library/ideascube.yml"
MIRRORBRAIN_URL = "http://mirrorbrain-web-service"

Expand Down Expand Up @@ -329,7 +323,6 @@ class LibraryMaintainer:
"write-libraries",
"write-offspot",
"purge-varnish",
"update-wiki",
]

# former (old) filename format for ZIMs (period was MM_YYYY)
Expand Down Expand Up @@ -359,10 +352,6 @@ def __init__(
nb_zim_versions_to_keep: int,
nb_zim_versions_exposed: int,
varnish_url: str,
wiki_domain: str,
wiki_username: str,
wiki_password: str,
wiki_page: str,
offspot_library_dest: str,
mirrorbrain_url: str,
log_to: str,
Expand All @@ -387,10 +376,6 @@ def __init__(
self.nb_zim_versions_exposed = nb_zim_versions_exposed

self.varnish_url = varnish_url
self.wiki_domain = wiki_domain
self.wiki_username = wiki_username
self.wiki_password = wiki_password
self.wiki_page = wiki_page

self.offspot_library_dest = pathlib.Path(offspot_library_dest)
self.mirrorbrain_url = mirrorbrain_url
Expand Down Expand Up @@ -693,43 +678,6 @@ def purge_varnish(self):
# headers={"X-Purge-Type": "kiwix-serve"},
# )

def update_wiki(self):

logger.info(
f"[WIKI] Updating {self.wiki_username}@{self.wiki_domain}::{self.wiki_page}"
)

download_dir = self.zim_root.relative_to(self.redirects_root)
content = "<!-- PAGE IS GENERATED AUTOMATICALLY, DO NOT EDIT MANUALLY -->\n"
for entry in sorted(self.exposed_zims.values(), key=human_sort):
ident = without_period(entry["relpath"].stem)
try:
lang_name = get_language_details(entry["lang"])["native"]
except Exception:
lang_name = entry["lang"]
options = " ".join(
[opt.strip() for opt in entry["option"].split("_") if opt.strip()]
)
content += (
r"{{ZIMdumps/row|{{{2|}}}|{{{3|}}}|"
f"{entry['project']} ({lang_name}) | {entry['lang']} | "
f"{human_size(entry['rsize'])} | {entry['year']}-{entry['month']} "
f"| {options} |"
r"8={{DownloadLink|"
f"{ident}|"
r"{{{1}}}|"
f"{download_dir}"
"/}} }}\n"
)

logger.info(f"[WIKI] > OK. generated {len(content.splitlines()) -1 } links")

site = mwclient.Site(self.wiki_domain)
site.login(self.wiki_username, self.wiki_password)
page = site.pages[self.wiki_page]
page.save(content, summary="Auto update following library refresh")
logger.info(f"[WIKI] {self.wiki_page} updated")

def run(self):
if "all" in self.actions:
self.actions = self.ACTIONS
Expand Down Expand Up @@ -764,10 +712,6 @@ def run(self):
if "purge-varnish" in self.actions:
self.purge_varnish()

if "update-wiki" in self.actions:
self.update_wiki()


def entrypoint():
parser = argparse.ArgumentParser(
prog="library-maint",
Expand Down Expand Up @@ -865,34 +809,6 @@ def entrypoint():
f"`VARNISH_URL` environ or {Defaults.VARNISH_URL}",
dest="varnish_url",
)
parser.add_argument(
"--wiki-domain",
default=os.getenv("WIKI_DOMAIN", Defaults.WIKI_DOMAIN),
help="Domain-name of the Mediawiki instance for Wiki Page update. Defaults to "
f"`WIKI_DOMAIN` environ or {Defaults.WIKI_DOMAIN}",
dest="wiki_domain",
)
parser.add_argument(
"--wiki-username",
default=os.getenv("WIKI_USERNAME", Defaults.WIKI_USERNAME),
help="Username to authenticate with on the Wiki to update the page. "
f"`Defaults to WIKI_USERNAME` environ or {Defaults.WIKI_USERNAME}",
dest="wiki_username",
)
parser.add_argument(
"--wiki-password",
default=os.getenv("WIKI_PASSWORD", Defaults.WIKI_PASSWORD),
help="Domain-name of the Mediawiki instance for Wiki Page update. Defaults to "
f"`WIKI_PASSWORD` environ or {Defaults.WIKI_PASSWORD}",
dest="wiki_password",
)
parser.add_argument(
"--wiki-page",
default=os.getenv("WIKI_PAGE", Defaults.WIKI_PAGE),
help="Password to authenticate with on the Wiki to update the page. "
f"`Defaults to WIKI_PAGE` environ or {Defaults.WIKI_PAGE}",
dest="wiki_page",
)
parser.add_argument(
"--offspot-library",
default=os.getenv("OFFSPOT_LIBRARY", Defaults.OFFSPOT_LIBRARY),
Expand Down
11 changes: 0 additions & 11 deletions zim/library-mgmt/maintenance.job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@ spec:
value: "http://library-frontend-service"
- name: MIRRORBRAIN_URL
value: "http://mirrorbrain-web-service"
- name: WIKI_DOMAIN
value: "wiki.kiwix.org"
- name: WIKI_USERNAME
value: "Reg@library-maint"
- name: WIKI_PASSWORD
valueFrom:
secretKeyRef:
name: wiki-credentials
key: password
- name: WIKI_PAGE
value: "Template:ZIMdumps/content"
volumeMounts:
- name: kiwix-download
subPath: library/library_zim.xml
Expand Down
32 changes: 0 additions & 32 deletions zim/library-mgmt/update_wiki_page.py

This file was deleted.

0 comments on commit 81550b2

Please sign in to comment.