From a40c32948f3064af491f1c20cf925b8f04758f30 Mon Sep 17 00:00:00 2001 From: bionel Date: Sun, 25 Mar 2018 11:52:28 +0300 Subject: add mirror selection to cli frontend --- src/frontend/cli/sisyphus-cli.py | 34 ++++++++++++++++++++++++++++++++++ src/frontend/gui/mirrors.conf.sample | 4 +--- 2 files changed, 35 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/frontend/cli/sisyphus-cli.py b/src/frontend/cli/sisyphus-cli.py index c8a8bd9..97e5017 100755 --- a/src/frontend/cli/sisyphus-cli.py +++ b/src/frontend/cli/sisyphus-cli.py @@ -5,6 +5,30 @@ from libsisyphus import * check_system_mode() +def listRepo(): + mirrorList = getMirrors() + for i, line in enumerate(mirrorList): + if line['isActive']: + print(i+1,'*',line['Url']) + else: + print(i+1,' ',line['Url']) + +def setRepo(mirror): + mirror = int(mirror[0]) + mirrorList = getMirrors() + newMirrorList = [] + if mirror not in range(1,len(mirrorList)+1): + print('mirror index is wrong, please check with "sisyphus mirror list"') + else: + for i, line in enumerate(mirrorList): + indx = i+1 + if indx == mirror : + line['isActive'] = True + else: + line['isActive'] = False + newMirrorList.append(line) + setActiveMirror(newMirrorList) + PKGLIST = sys.argv[2:] if "__main__" == __name__: @@ -28,6 +52,16 @@ if "__main__" == __name__: sisyphus_db_rescue() elif "sysinfo" in sys.argv[1:]: sisyphus_pkg_sysinfo() + elif "mirror" in sys.argv[1:]: + if not sys.argv[2:]: + sisyphus_pkg_help() + elif "list" in sys.argv[2]: + listRepo() + elif "set" in sys.argv[2:]: + if not sys.argv[3:]: + sisyphus_pkg_help() + else: + setRepo(sys.argv[3:]) elif "help" in sys.argv[1:]: sisyphus_pkg_help() elif not sys.argv[1:]: diff --git a/src/frontend/gui/mirrors.conf.sample b/src/frontend/gui/mirrors.conf.sample index 6be0b29..8180c87 100644 --- a/src/frontend/gui/mirrors.conf.sample +++ b/src/frontend/gui/mirrors.conf.sample @@ -3,11 +3,9 @@ # Uncomment only one mirror from the list bellow # ####################################################### -# Princeton University (USA) mirror # PORTAGE_BINHOST="http://mirror.math.princeton.edu/pub/redcorelinux/packages/" -# Alpix.eu (Germany) mirror PORTAGE_BINHOST="http://mirror.alpix.eu/redcorelinux/packages/" -# Yandex.ru (Russia) mirror # PORTAGE_BINHOST="http://mirror.yandex.ru/mirrors/redcorelinux/packages/" + -- cgit v1.2.3