Skip to content
Snippets Groups Projects
Commit 2b604bde authored by Frede H's avatar Frede H :speech_balloon:
Browse files

renamed internal `mirror_dir`

since it no longer is mirror_dir but `work_dir`
for status.json and custom-mirrors.json
parent a28dc81e
No related branches found
No related tags found
No related merge requests found
...@@ -65,13 +65,13 @@ def build_config(): ...@@ -65,13 +65,13 @@ def build_config():
custom = False custom = False
# default config # default config
config = { config = {
"to_be_removed": conf.TO_BE_REMOVED, "to_be_removed": conf.TO_BE_REMOVED, # long after 2017-04-18
"branch": "stable", "branch": "stable",
"branches": conf.BRANCHES, "branches": conf.BRANCHES,
"config_file": conf.CONFIG_FILE, "config_file": conf.CONFIG_FILE,
"custom_file": conf.CUSTOM_FILE, "custom_file": conf.CUSTOM_FILE,
"method": "rank", "method": "rank",
"mirror_dir": conf.MIRROR_DIR, "work_dir": conf.WORK_DIR,
"mirror_file": conf.MIRROR_FILE, "mirror_file": conf.MIRROR_FILE,
"mirror_list": conf.MIRROR_LIST, "mirror_list": conf.MIRROR_LIST,
"no_update": False, "no_update": False,
...@@ -104,7 +104,7 @@ def build_config(): ...@@ -104,7 +104,7 @@ def build_config():
custom = True custom = True
config["only_country"] = value.split(",") config["only_country"] = value.split(",")
elif key == "MirrorlistsDir": elif key == "MirrorlistsDir":
config["mirror_dir"] = value config["work_dir"] = value
elif key == "OutputMirrorlist": elif key == "OutputMirrorlist":
config["mirror_list"] = value config["mirror_list"] = value
elif key == "NoUpdate": elif key == "NoUpdate":
......
...@@ -26,7 +26,7 @@ URL_STATUS_JSON = "http://repo.manjaro.org/status.json" ...@@ -26,7 +26,7 @@ URL_STATUS_JSON = "http://repo.manjaro.org/status.json"
CONFIG_FILE = "/etc/pacman-mirrors.conf" CONFIG_FILE = "/etc/pacman-mirrors.conf"
MIRROR_LIST = "/etc/pacman.d/mirrorlist" MIRROR_LIST = "/etc/pacman.d/mirrorlist"
# pacman-mirrors dir/files # pacman-mirrors dir/files
MIRROR_DIR = "/var/lib/pacman-mirrors/" WORK_DIR = "/var/lib/pacman-mirrors/"
CUSTOM_FILE = "/var/lib/pacman-mirrors/custom-mirrors.json" CUSTOM_FILE = "/var/lib/pacman-mirrors/custom-mirrors.json"
MIRROR_FILE = "/usr/share/pacman-mirrors/mirrors.json" MIRROR_FILE = "/usr/share/pacman-mirrors/mirrors.json"
STATUS_FILE = "/var/lib/pacman-mirrors/status.json" STATUS_FILE = "/var/lib/pacman-mirrors/status.json"
......
...@@ -178,7 +178,7 @@ class PacmanMirrors: ...@@ -178,7 +178,7 @@ class PacmanMirrors:
self.quiet = True self.quiet = True
if args.mirror_dir: if args.mirror_dir:
self.config["mirror_dir"] = args.mirror_dir self.config["work_dir"] = args.mirror_dir
if args.output: if args.output:
if args.output[0] == "/": if args.output[0] == "/":
...@@ -230,8 +230,8 @@ class PacmanMirrors: ...@@ -230,8 +230,8 @@ class PacmanMirrors:
prefix + self.config["custom_file"] prefix + self.config["custom_file"]
self.config["to_be_removed"] = \ self.config["to_be_removed"] = \
prefix + self.config["to_be_removed"] prefix + self.config["to_be_removed"]
self.config["mirror_dir"] = \ self.config["work_dir"] = \
prefix + self.config["mirror_dir"] prefix + self.config["work_dir"]
self.config["mirror_file"] = \ self.config["mirror_file"] = \
prefix + self.config["to_be_removed"] prefix + self.config["to_be_removed"]
self.config["mirror_list"] = \ self.config["mirror_list"] = \
...@@ -482,7 +482,7 @@ class PacmanMirrors: ...@@ -482,7 +482,7 @@ class PacmanMirrors:
def run(self): def run(self):
"""Run""" """Run"""
(self.config, self.custom) = configfn.build_config() (self.config, self.custom) = configfn.build_config()
filefn.dir_must_exist(self.config["mirror_dir"]) filefn.dir_must_exist(self.config["work_dir"])
self.command_line_parse() self.command_line_parse()
self.network = httpfn.is_connected("https://manjaro.org") self.network = httpfn.is_connected("https://manjaro.org")
if self.network: if self.network:
......
...@@ -5,7 +5,7 @@ URL_STATUS_JSON = "http://repo.manjaro.org/status.json" ...@@ -5,7 +5,7 @@ URL_STATUS_JSON = "http://repo.manjaro.org/status.json"
CONFIG_FILE = "tests/mock/etc/pacman-mirrors.conf" CONFIG_FILE = "tests/mock/etc/pacman-mirrors.conf"
MIRROR_LIST = "tests/mock/etc/mirrorlist" MIRROR_LIST = "tests/mock/etc/mirrorlist"
# pacman-mirrors # pacman-mirrors
MIRROR_DIR = "tests/mock/var/" WORK_DIR = "tests/mock/var/"
CUSTOM_FILE = "tests/mock/var/custom-mirrors.json" CUSTOM_FILE = "tests/mock/var/custom-mirrors.json"
MIRROR_FILE = "tests/mock/usr/mirrors.json" MIRROR_FILE = "tests/mock/usr/mirrors.json"
STATUS_FILE = "tests/mock/var/status.json" STATUS_FILE = "tests/mock/var/status.json"
...@@ -23,7 +23,7 @@ test_conf = { ...@@ -23,7 +23,7 @@ test_conf = {
"config_file": CONFIG_FILE, "config_file": CONFIG_FILE,
"custom_file": CUSTOM_FILE, "custom_file": CUSTOM_FILE,
"method": "rank", "method": "rank",
"mirror_dir": MIRROR_DIR, "work_dir": WORK_DIR,
"mirror_file": MIRROR_FILE, "mirror_file": MIRROR_FILE,
"mirror_list": MIRROR_LIST, "mirror_list": MIRROR_LIST,
"no_update": False, "no_update": False,
......
...@@ -79,7 +79,7 @@ class TestCommandLineParse(unittest.TestCase): ...@@ -79,7 +79,7 @@ class TestCommandLineParse(unittest.TestCase):
app.config["config_file"] = conf.CONFIG_FILE app.config["config_file"] = conf.CONFIG_FILE
app.config = configfn.build_config() app.config = configfn.build_config()
app.command_line_parse() app.command_line_parse()
assert app.config["mirror_dir"] == "/another/dir/" assert app.config["work_dir"] == "/another/dir/"
@patch("os.getuid") @patch("os.getuid")
@patch.object(configfn, "build_config") @patch.object(configfn, "build_config")
......
...@@ -60,12 +60,12 @@ class TestDefaultConfig(unittest.TestCase): ...@@ -60,12 +60,12 @@ class TestDefaultConfig(unittest.TestCase):
"-g"]): "-g"]):
app = PacmanMirrors() app = PacmanMirrors()
app.config = configfn.build_config() app.config = configfn.build_config()
assert app.config["mirror_dir"] == "tests/mock/var/" assert app.config["work_dir"] == "tests/mock/var/"
@patch("os.getuid") @patch("os.getuid")
@patch.object(configfn, "build_config") @patch.object(configfn, "build_config")
def test_default_mirrorfile(self, mock_build_config, mock_os_getuid): def test_default_mirrorfile(self, mock_build_config, mock_os_getuid):
"""TEST: config[mirror_file] = tests/mock/var/mirrors.json""" """TEST: config[mirror_file] = tests/mock/usr/mirrors.json"""
mock_os_getuid.return_value = 0 mock_os_getuid.return_value = 0
mock_build_config.return_value = conf.test_conf mock_build_config.return_value = conf.test_conf
with unittest.mock.patch("sys.argv", with unittest.mock.patch("sys.argv",
...@@ -73,7 +73,7 @@ class TestDefaultConfig(unittest.TestCase): ...@@ -73,7 +73,7 @@ class TestDefaultConfig(unittest.TestCase):
"-g"]): "-g"]):
app = PacmanMirrors() app = PacmanMirrors()
app.config = configfn.build_config() app.config = configfn.build_config()
assert app.config["mirror_file"] == "tests/mock/var/mirrors.json" assert app.config["mirror_file"] == "tests/mock/usr/mirrors.json"
@patch("os.getuid") @patch("os.getuid")
@patch.object(configfn, "build_config") @patch.object(configfn, "build_config")
......
...@@ -35,7 +35,7 @@ class TestPacmanMirrors(unittest.TestCase): ...@@ -35,7 +35,7 @@ class TestPacmanMirrors(unittest.TestCase):
"-m", "random"]): "-m", "random"]):
app = PacmanMirrors() app = PacmanMirrors()
app.config = configfn.build_config() app.config = configfn.build_config()
filefn.dir_must_exist(app.config["mirror_dir"]) filefn.dir_must_exist(app.config["work_dir"])
app.command_line_parse() app.command_line_parse()
app.load_all_mirrors() app.load_all_mirrors()
# network check # network check
...@@ -63,7 +63,7 @@ class TestPacmanMirrors(unittest.TestCase): ...@@ -63,7 +63,7 @@ class TestPacmanMirrors(unittest.TestCase):
"-f", "5"]): "-f", "5"]):
app = PacmanMirrors() app = PacmanMirrors()
app.config = configfn.build_config() app.config = configfn.build_config()
filefn.dir_must_exist(app.config["mirror_dir"]) filefn.dir_must_exist(app.config["work_dir"])
app.command_line_parse() app.command_line_parse()
app.load_all_mirrors() app.load_all_mirrors()
# network check # network check
...@@ -92,7 +92,7 @@ class TestPacmanMirrors(unittest.TestCase): ...@@ -92,7 +92,7 @@ class TestPacmanMirrors(unittest.TestCase):
"-c", "all"]): "-c", "all"]):
app = PacmanMirrors() app = PacmanMirrors()
app.config = configfn.build_config() app.config = configfn.build_config()
filefn.dir_must_exist(app.config["mirror_dir"]) filefn.dir_must_exist(app.config["work_dir"])
app.command_line_parse() app.command_line_parse()
# network check # network check
app.network = httpfn.is_connected("https://manjaro.org", 2) app.network = httpfn.is_connected("https://manjaro.org", 2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment