From b88ba2a34f68d39a76403ca66136b78ad17d1ba7 Mon Sep 17 00:00:00 2001 From: Daniel STAN Date: Tue, 10 Nov 2015 20:38:47 +0100 Subject: [PATCH] prise en compte du ~/.dialogrc --- gestion/dialog/CPS.py | 7 +++++-- gestion/dialog/lc.py | 8 +++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gestion/dialog/CPS.py b/gestion/dialog/CPS.py index 1ea88eb7..7d70c000 100644 --- a/gestion/dialog/CPS.py +++ b/gestion/dialog/CPS.py @@ -203,7 +203,7 @@ class Dialog(object): setattr(self, attr, ret) return ret - def __init__(self, debug_enable=False): + def __init__(self, debug_enable=False, dialogrc=False): signal.signal(signal.SIGINT, signal.SIG_IGN) self.debug_enable = debug_enable @@ -211,6 +211,7 @@ class Dialog(object): # On met un timeout à 10min d'innactivité sur dialog self.timeout = 600 self.error_to_raise = (Continue, DialogError, ldap.SERVER_DOWN) + self.dialogrc = dialogrc _dialog = None @property @@ -218,7 +219,9 @@ class Dialog(object): """ Renvois l'objet dialog. """ - if self._dialog is None: + if self.dialogrc: + self._dialog = PythonDialog(DIALOGRC=self.dialogrc) + else: self._dialog = PythonDialog() self.dialog_last_access = time.time() return self._dialog diff --git a/gestion/dialog/lc.py b/gestion/dialog/lc.py index faccb6b3..22c9b886 100644 --- a/gestion/dialog/lc.py +++ b/gestion/dialog/lc.py @@ -6,6 +6,7 @@ Copyright (C) Valentin Samir Licence : GPLv3 """ +import os import sys import time import ldap @@ -27,7 +28,12 @@ from CPS import TailCall, tailcaller, Continue, TailCaller class Dialog(CPS.Dialog): def __init__(self, debug_enable=False, ldap_test=False, custom_user=None): - super(Dialog, self).__init__(debug_enable=debug_enable) + # if os.path.exists(os.path.expanduser('~/.dialogrc')): + if True: + dialogrc='~/.dialogrc' + else: + dialogrc=False + super(Dialog, self).__init__(debug_enable=debug_enable, dialogrc=dialogrc) # On initialise le moteur de rendu en spécifiant qu'on va faire du dialog printing.template(dialog=True) self.ldap_test = ldap_test