diff options
-rw-r--r-- | autodownload.py | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/autodownload.py b/autodownload.py index e77288df..24108656 100644 --- a/autodownload.py +++ b/autodownload.py @@ -11,6 +11,11 @@ and modify the last line of the script to tell which kind of manual it is ("installer" or "mcc") + .. warning:: IT SHOULD NOT BE RUN IN THE GIT CLONE!!! + + To use the update script, you need a clean git clone, so you must not + polluate it with the downloaded manuals + """ from urllib.request import urlopen, urlretrieve from urllib.error import HTTPError @@ -18,9 +23,16 @@ from html.parser import HTMLParser manual_name_prefix = {"installer": "DrakX-", - "mcc": "MCC-"} + "MCC": "MCC-"} manual_name_suffix = "WebHelp-zipped.zip" + +def usage(): + print("python3 autodownlaod.py <manual> [<server_url>]") + print("\t <manual>: MCC or installer") + print("\t <server_url>: (optional) if not given: " + + "http://docteam.mageia.nl/zipped/ will be used") + class ArchivePageHTMLParser(HTMLParser): def __init__(self): HTMLParser.__init__(self) @@ -58,9 +70,23 @@ def getZip(url, manual, lang): if __name__ == "__main__": - base_url = "http://waesvanm.home.xs4all.nl/Mageia_4_documentation/zipped/installer/" - language_list = getPage(base_url) - for elem in language_list: - getZip(base_url, "installer", elem) + import sys + if len(sys.argv) not in (2, 3): + usage() + else: + # check manual + manual = sys.argv[1] + if manual not in manual_name_prefix.keys(): + usage() + else: + if len(sys.argv) == 3: + base_url = sys.argv[2] + else: + base_url = "http://docteam.mageia.nl/zipped/" + base_url = base_url + "/" + manual + "/" + print(base_url) + language_list = getPage(base_url) + for elem in language_list: + getZip(base_url, manual, elem) |