Commit 1453060e authored by FH's avatar FH

change the receiving list

in  mirror_list_interactive
parent a31a2d0c
#!/usr/bin/env python3
"""Handler module"""
"""File functions module"""
import json
from collections import OrderedDict
class Handler():
"""Handler class"""
def close(self):
"""Close program"""
print("Closing ....")
exit()
class FileFunctions():
"""File functions class"""
def write_json(self, data, filename):
"""
......
......@@ -74,7 +74,7 @@ class GraphicalUI(Gtk.Window):
self.button_done = Gtk.Button(txt.I_CONFIRM)
self.button_done.set_sensitive(False)
self.button_done.connect("clicked", self.done)
grid = Gtk.Grid(column_homogeneous=True,
column_spacing=10,
row_spacing=10)
......
#/usr/bin/env python3
#!/usr/bin/env python3
"""Manjaro Mirrors fetcher"""
import json
import urllib.request
from collections import OrderedDict
from http_conf import MIRRORS_URL, STATUS_URL
from .http_conf import MIRRORS_URL, STATUS_URL
class Fetcher():
......
......@@ -59,6 +59,7 @@ _ = i18n.language.gettext
DEFAULT = "default"
CUSTOM = "custom"
class PacmanMirrors:
"""Class PacmanMirrors"""
......@@ -174,7 +175,8 @@ class PacmanMirrors:
self.config["mirror_dir"] = args.mirror_dir
self.default_mirror_dir = self.config["mirror_dir"]
self.available_countries = sorted(os.listdir(self.config["mirror_dir"]))
self.available_countries = sorted(
os.listdir(self.config["mirror_dir"]))
if args.geoip:
self.geolocation = True
......@@ -187,7 +189,8 @@ class PacmanMirrors:
self.config["only_country"] = []
else:
try:
self.validate_country_list(country, self.available_countries)
self.validate_country_list(
country, self.available_countries)
self.config["only_country"] = country
except argparse.ArgumentTypeError as err:
parser.error(err)
......@@ -253,7 +256,7 @@ class PacmanMirrors:
txt.ERROR, txt.SEP, txt.ERR_FILE_READ, txt.SEP,
err.filename, txt.SEP, err.strerror))
return config
def gen_mirror_list_common(self):
"""Generate common mirrorlist"""
if len(self.good_servers) >= 3: # Avoid an empty mirrorlist
......@@ -291,16 +294,16 @@ class PacmanMirrors:
from . import graphical_ui
interactive = graphical_ui.run(server_list)
server_list = interactive.custom_list
new_list = interactive.custom_list
if not interactive.is_done:
return
if server_list:
if new_list:
print(txt.NEWLINE + txt.DCS + txt.INF_INTERACTIVE_LIST)
print("--------------------------")
self.output_custom_mirror_file(server_list)
self.output_mirror_list(server_list, write_file=True)
self.output_mirror_file(new_list)
self.output_mirror_list(new_list, write_file=True)
self.modify_config(CUSTOM)
print(txt.DCS + txt.INF_INTERACTIVE_LIST_SAVED + txt.SEP +
"{path}".format(path=self.custom_mirror_file))
......@@ -354,7 +357,7 @@ class PacmanMirrors:
self.write_config_to_file(
self.config_file, self.config["only_country"], config_type)
def output_custom_mirror_file(self, servers):
def output_mirror_file(self, servers):
"""Write a custom mirror file in custom mirror dir"""
os.makedirs(self.custom_mirror_dir, mode=0o755, exist_ok=True)
try:
......@@ -420,7 +423,8 @@ class PacmanMirrors:
# create a ref point for calculation
point_in_time = datetime.datetime.now()
try:
with open(os.path.join(mirror_dir, country), "r") as mirrorfile:
with open(os.path.join(
mirror_dir, country), "r") as mirrorfile:
for line in mirrorfile:
mirror_country = self.get_mirror_country(line)
if mirror_country:
......@@ -649,7 +653,8 @@ class PacmanMirrors:
except HTTPException:
if not quiet:
print(txt.NEWLINE + txt.ERROR + txt.SEP +
txt.ERR_SERVER_HTTP_EXCEPTION + txt.SEP + txt.HTTP_EXCEPTION)
txt.ERR_SERVER_HTTP_EXCEPTION + txt.SEP +
txt.HTTP_EXCEPTION)
return content
@staticmethod
......@@ -716,8 +721,8 @@ class PacmanMirrors:
"""
handle.write("##\n")
handle.write("## Manjaro Linux repository mirrorlist\n")
handle.write("## Generated on {}\n".format(datetime.datetime.now()
.strftime("%d %B %Y %H:%M")))
handle.write("## Generated on {}\n".format(
datetime.datetime.now().strftime("%d %B %Y %H:%M")))
handle.write("##\n")
handle.write("## Use pacman-mirrors to modify\n")
if custom:
......
......@@ -143,7 +143,8 @@ class TestPacmanMirrors(unittest.TestCase):
mock_timestamp.return_value = "2017-02-06T07:18:43Z"
app = pacman_mirrors.PacmanMirrors()
mock_data = "date=2017-02-06T07:18:43Z"
assert app.get_mirror_branch_timestamp(mock_data) == "2017-02-06T07:18:43Z"
assert app.get_mirror_branch_timestamp(
mock_data) == "2017-02-06T07:18:43Z"
def tearDown(self):
pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment