diff options
author | Claire Revillet <grenoya@zarb.org> | 2015-05-12 23:37:49 +0200 |
---|---|---|
committer | Claire Revillet <grenoya@zarb.org> | 2015-05-12 23:37:49 +0200 |
commit | a3521bab8491afadcd6f5d1c6fd2815f624b73d6 (patch) | |
tree | 208c9b683414824a64a3c9d44421838d41970d15 /autodownload.py | |
parent | c19ab1418a438e20b3785e9a928a86f57565fe6a (diff) | |
download | doc-a3521bab8491afadcd6f5d1c6fd2815f624b73d6.tar doc-a3521bab8491afadcd6f5d1c6fd2815f624b73d6.tar.gz doc-a3521bab8491afadcd6f5d1c6fd2815f624b73d6.tar.bz2 doc-a3521bab8491afadcd6f5d1c6fd2815f624b73d6.tar.xz doc-a3521bab8491afadcd6f5d1c6fd2815f624b73d6.zip |
modify autodownload script to take arguments
Diffstat (limited to 'autodownload.py')
-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) |