From 1a63a815554352402548aba746b31e2103c2908c Mon Sep 17 00:00:00 2001 From: Matthieu Lamalle Date: Fri, 16 Jul 2021 15:05:43 +0200 Subject: [PATCH] correciton bug --- scripts/module/change_domain.py | 2 +- scripts/zephir/groups.py | 58 +++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 scripts/zephir/groups.py diff --git a/scripts/module/change_domain.py b/scripts/module/change_domain.py index c0d4de2..e5c80eb 100644 --- a/scripts/module/change_domain.py +++ b/scripts/module/change_domain.py @@ -71,7 +71,7 @@ def main(): output = os.popen(cmd) res = output.read().strip() output.close() - + to_save = "" if not save : to_save = raw_input("Souhaitez vous sauvegarder la configuration sur Zephir ? (O/N) ") if to_save == "O": diff --git a/scripts/zephir/groups.py b/scripts/zephir/groups.py new file mode 100644 index 0000000..be7a9a9 --- /dev/null +++ b/scripts/zephir/groups.py @@ -0,0 +1,58 @@ +#!/usr/bin/python + +from zephir.backend.lib_backend import CxPool + +def make_group(): + cx_pool = CxPool() + cu = cx_pool.create() + cu.execute("""select libelle,id from modules""") + infos = {} + variante_infos = {} + filename = 'exportation' + server_infos = [] + for module_name in cu.fetchall(): + module, version = module_name[0].rsplit('-', 1) + infos.setdefault(version, {})[module] = module_name[1] + + versions = infos.keys() + versions.sort() + print('Choix de la version :') + for idx, version in enumerate(versions): + print('{}: {}'.format(idx, version)) + idx = input('> ') + version = versions[int(idx)] + filename += '-' + version + print + print('Choix du module :') + modules = infos[version].keys() + modules.sort() + for idx, module in enumerate(modules): + print('{}: {}'.format(idx, module)) + idx = input('> ') + module = modules[int(idx)] + filename += '-' + module + print + cu.execute("select libelle,id from variantes where module = " + str(infos[version][module])) + for variante_obj in cu.fetchall(): + variante_infos[variante_obj[0]] = variante_obj[1] + print('Choix de la variante :') + variantes = variante_infos.keys() + variantes.sort() + for idx, variante in enumerate(variantes): + print('{}: {}'.format(idx, variante)) + idx_all = idx + 1 + print('{}: toutes les variantes'.format(idx_all)) + idx = input('> ') + if idx == idx_all: + variantes = variante_infos.values() + else: + filename += '-' + variantes[idx] + variantes = [variante_infos[variantes[idx]]] + print + for variante in variantes: + cu.execute('select id,ip_publique,rne,libelle from serveurs where variante=' + str(variante)) + print("Liste des serveurs : ") + for server in cu.fetchall(): + print('{} - {} - {} - {}'.format(server[0], server[1], server[2], server[3])) + server_infos.append((server[0], server[1], server[2], server[3])) + return server_infos