From 32186ffb00e0d8ca6c9855f78f692e685b26d658 Mon Sep 17 00:00:00 2001 From: fhdk <fh@uex.dk> Date: Fri, 17 Mar 2017 14:10:43 +0100 Subject: [PATCH] corrected error -c all did not reset list added -l/--list argument updated CHANGELOG generated pot-file --- CHANGELOG.md | 1 + locale/pacman_mirrors.pot | 98 +++++++++++++++++--------------- pacman_mirrors/pacman_mirrors.py | 44 +++++++++----- 3 files changed, 83 insertions(+), 60 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bf69dad..c791837a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ All notable changes to this project will be documented in this file. ## [4.0.0] 2017-03-14 +- Add: -l/--list Print available mirror countries - Add: Network check; do not run rank if no internet. - Add: -f/--fasttrack [n] argument. - Modified GUI and TUI to reflect rank/random method. diff --git a/locale/pacman_mirrors.pot b/locale/pacman_mirrors.pot index 68a98c7a..5a5a7379 100644 --- a/locale/pacman_mirrors.pot +++ b/locale/pacman_mirrors.pot @@ -7,9 +7,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: pacman-mirrors 3.3.0b4\n" +"Project-Id-Version: pacman-mirrors 4.0.0\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2017-02-27 08:23+0100\n" +"POT-Creation-Date: 2017-03-17 14:09+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -111,178 +111,182 @@ msgid "Print the pacman-mirrors version" msgstr "" #: pacman_mirrors/txt.py:58 -msgid "A quick mirrorlist. Overrides -cim --geoip" +msgid "A quick mirrorlist. Overrides" msgstr "" -#: pacman_mirrors/txt.py:60 -msgid "Available countries are" +#: pacman_mirrors/txt.py:59 +msgid "List all available countries" msgstr "" #: pacman_mirrors/txt.py:61 -msgid "Could not download from" +msgid "Available countries are" msgstr "" #: pacman_mirrors/txt.py:62 -msgid "Cannot read file" +msgid "Could not download from" msgstr "" #: pacman_mirrors/txt.py:63 -msgid "Cannot write file" +msgid "Cannot read file" msgstr "" #: pacman_mirrors/txt.py:64 -msgid "Converting custom mirror file to new format" +msgid "Cannot write file" msgstr "" #: pacman_mirrors/txt.py:65 -msgid "Custom mirror file" +msgid "Converting custom mirror file to new format" msgstr "" #: pacman_mirrors/txt.py:66 -msgid "Custom mirror file saved" +msgid "Custom mirror file" msgstr "" #: pacman_mirrors/txt.py:67 -msgid "User generated mirror list" +msgid "Custom mirror file saved" msgstr "" #: pacman_mirrors/txt.py:68 -msgid "doesn't exist." +msgid "User generated mirror list" msgstr "" #: pacman_mirrors/txt.py:69 -msgid "Downloading mirrors from repo.manjaro.org" +msgid "doesn't exist." msgstr "" #: pacman_mirrors/txt.py:70 -msgid "Falling back to" +msgid "Downloading mirrors from" msgstr "" #: pacman_mirrors/txt.py:71 -msgid "is missing" +msgid "Falling back to" msgstr "" #: pacman_mirrors/txt.py:72 -msgid "The mirror file" +msgid "is missing" msgstr "" #: pacman_mirrors/txt.py:73 -msgid "Mirrorlist generated and saved to" +msgid "The mirror file" msgstr "" #: pacman_mirrors/txt.py:74 -msgid "Mirror ranking is not available" +msgid "Mirrorlist generated and saved to" msgstr "" #: pacman_mirrors/txt.py:75 -msgid "Must have root privileges" +msgid "Mirror ranking is not available" msgstr "" #: pacman_mirrors/txt.py:76 -msgid "Internet connection appears to be down" +msgid "Must have root privileges" msgstr "" #: pacman_mirrors/txt.py:77 -msgid "Internet access is required to proceed" +msgid "Internet connection appears to be down" msgstr "" #: pacman_mirrors/txt.py:78 -msgid "Pacman needs a mirrorlist. Use -m random to create a it without network" +msgid "Internet access is required to proceed" msgstr "" #: pacman_mirrors/txt.py:79 +msgid "Pacman needs a mirrorlist. Use -m random to create a it without network" +msgstr "" + +#: pacman_mirrors/txt.py:81 msgid "The mirror list is not changed" msgstr "" -#: pacman_mirrors/txt.py:80 +#: pacman_mirrors/txt.py:82 msgid "No mirrors in selection" msgstr "" -#: pacman_mirrors/txt.py:81 +#: pacman_mirrors/txt.py:83 msgid "Option" msgstr "" -#: pacman_mirrors/txt.py:82 +#: pacman_mirrors/txt.py:84 msgid "Writing mirror list" msgstr "" -#: pacman_mirrors/txt.py:83 +#: pacman_mirrors/txt.py:85 msgid "Querying mirrors" msgstr "" -#: pacman_mirrors/txt.py:84 +#: pacman_mirrors/txt.py:86 msgid "Randomizing mirror list" msgstr "" -#: pacman_mirrors/txt.py:85 -msgid "To reset custom config run `pacman-mirrors -c all`" +#: pacman_mirrors/txt.py:87 +msgid "To reset custom config run " msgstr "" -#: pacman_mirrors/txt.py:86 +#: pacman_mirrors/txt.py:88 msgid "This may take some time" msgstr "" -#: pacman_mirrors/txt.py:87 +#: pacman_mirrors/txt.py:89 msgid "unknown country" msgstr "" -#: pacman_mirrors/txt.py:88 +#: pacman_mirrors/txt.py:90 msgid "Using all mirrors" msgstr "" -#: pacman_mirrors/txt.py:89 +#: pacman_mirrors/txt.py:91 msgid "Using custom mirror file" msgstr "" -#: pacman_mirrors/txt.py:90 +#: pacman_mirrors/txt.py:92 msgid "Using default mirror file" msgstr "" -#: pacman_mirrors/txt.py:92 +#: pacman_mirrors/txt.py:94 msgid "Manjaro mirrors by response time" msgstr "" -#: pacman_mirrors/txt.py:93 +#: pacman_mirrors/txt.py:95 msgid "Manjaro mirrors in random order" msgstr "" -#: pacman_mirrors/txt.py:94 +#: pacman_mirrors/txt.py:96 msgid "Check mirrors for your personal list" msgstr "" -#: pacman_mirrors/txt.py:95 +#: pacman_mirrors/txt.py:97 msgid "Use" msgstr "" -#: pacman_mirrors/txt.py:96 +#: pacman_mirrors/txt.py:98 msgid "Country" msgstr "" -#: pacman_mirrors/txt.py:97 +#: pacman_mirrors/txt.py:99 msgid "Resp" msgstr "" -#: pacman_mirrors/txt.py:98 +#: pacman_mirrors/txt.py:100 msgid "Sync" msgstr "" -#: pacman_mirrors/txt.py:99 +#: pacman_mirrors/txt.py:101 msgid "URL" msgstr "" -#: pacman_mirrors/txt.py:100 +#: pacman_mirrors/txt.py:102 msgid "Cancel" msgstr "" -#: pacman_mirrors/txt.py:101 +#: pacman_mirrors/txt.py:103 msgid "OK" msgstr "" -#: pacman_mirrors/txt.py:102 +#: pacman_mirrors/txt.py:104 msgid "Confirm selections" msgstr "" -#: pacman_mirrors/txt.py:103 +#: pacman_mirrors/txt.py:105 msgid "I want to use these mirrors" msgstr "" diff --git a/pacman_mirrors/pacman_mirrors.py b/pacman_mirrors/pacman_mirrors.py index 63be32b2..400dcc96 100644 --- a/pacman_mirrors/pacman_mirrors.py +++ b/pacman_mirrors/pacman_mirrors.py @@ -122,6 +122,9 @@ class PacmanMirrors: type=int, metavar=txt.DIGIT, help="{} {}".format(txt.HLP_ARG_FASTTRACK, txt.OVERRIDE_OPT)) + parser.add_argument("-l", "--list", + action="store_true", + help=txt.HLP_ARG_LIST) args = parser.parse_args() @@ -134,14 +137,18 @@ class PacmanMirrors: print("pacman-mirrors {}".format(__version__)) exit(0) - if os.getuid() != 0: - print(".: {} {}".format(txt.ERR_CLR, txt.MUST_BE_ROOT)) - exit(1) - if args.no_update: if self.config["no_update"] == "True": exit(0) + if args.list: + self.list_all_countries() + exit(0) + + if os.getuid() != 0: + print(".: {} {}".format(txt.ERR_CLR, txt.MUST_BE_ROOT)) + exit(1) + if args.method: self.config["method"] = args.method @@ -176,6 +183,8 @@ class PacmanMirrors: if args.fasttrack: self.fasttrack = args.fasttrack + self.geoip = False + self.config["only_country"] = [] def build_common_mirror_list(self): """Generate common mirrorlist""" @@ -188,11 +197,12 @@ class PacmanMirrors: shuffle(worklist) filefn.output_mirror_list(self.config, worklist, quiet=self.quiet) - if self.custom or \ - self.config["only_country"] != self.mirrors.mirrorlist: - configfn.modify_config(self.config, custom=True) + # if self.custom or \ + # self.config["only_country"] != self.mirrors.mirrorlist: + if self.custom: + configfn.modify_config(self.config, custom=self.custom) else: - configfn.modify_config(self.config) + configfn.modify_config(self.config, custom=self.custom) def build_fasttrack_mirror_list(self, number): """Fast-track the mirrorlist by filtering only up2date mirrors""" @@ -299,6 +309,13 @@ class PacmanMirrors: self.config["only_country"] = [] self.custom = False + def list_all_countries(self): + """List all available countries""" + self.load_default_mirrors() + print(".: {}{}{}:".format(txt.GS, txt.AVAILABLE_COUNTRIES, txt.CE)) + print("{}".format(", ".join(self.mirrors.countrylist))) + print("") + def load_all_mirrors(self): """Load mirrors""" if self.config["only_country"] == ["all"]: @@ -306,19 +323,20 @@ class PacmanMirrors: # decision on custom or default if self.config["only_country"] == ["Custom"]: - if not validfn.custom_config_is_valid(): - self.disable_custom_config() - else: + if validfn.custom_config_is_valid(): self.custom = True + else: + self.disable_custom_config() else: self.selected_countries = self.config["only_country"] + # decision on custom vs countries from conf or argument if self.custom and not self.selected_countries: self.load_custom_mirrors() self.selected_countries = self.mirrors.countrylist else: self.load_default_mirrors() - # build country list + # validate selection and build country list self.selected_countries = mirrorfn.build_country_list( self.selected_countries, self.mirrors.countrylist, self.geoip) @@ -373,7 +391,7 @@ class PacmanMirrors: self.config = configfn.build_config() filefn.dir_must_exist(self.config["mirror_dir"]) self.command_line_parse() - self.network = httpfn.ping_host("google.com", 3) + self.network = httpfn.ping_host("google.com", 1) if self.network: # all methods is available httpfn.update_mirrors(self.config) -- GitLab