Alon Bar-Lev has uploaded a new change for review. Change subject: api: do not expose internal constants ......................................................................
api: do not expose internal constants Change-Id: I7ba5d684b5a51b2d609f21359974bd1bd899ca49 Signed-off-by: Alon Bar-Lev <alo...@redhat.com> --- M src/otopi/constants.py M src/otopi/dialog.py M src/otopi/main.py M src/plugins/otopi/core/config.py M src/plugins/otopi/core/log.py M src/plugins/otopi/packagers/yumpackager.py M src/plugins/otopi/system/command.py 7 files changed, 29 insertions(+), 21 deletions(-) git pull ssh://gerrit.ovirt.org:29418/otopi refs/changes/08/10108/1 diff --git a/src/otopi/constants.py b/src/otopi/constants.py index 91d9778..dc9b7e9 100644 --- a/src/otopi/constants.py +++ b/src/otopi/constants.py @@ -25,6 +25,28 @@ @util.export +class Defaults(object): + LOG_FILE_PREFIX = 'otopi' + CONFIG_FILE = '/etc/otopi.conf' + COMMAND_SEARCH_PATH = ":".join( + ( + '/usr/local/sbin', + '/usr/local/bin', + '/usr/sbin', + '/usr/bin', + '/sbin', + '/bin', + ) + ) + PACKAGER_KEEP_ALIVE_INTERVAL = 30 + + +@util.export +class Log(object): + LOGGER_BASE = 'otopi' + + +@util.export @util.codegen class Types(object): NONE = 'none' @@ -39,25 +61,11 @@ @util.codegen class Const(object): ENVIRONMENT_APPEND_PREFIX = 'APPEND:' - LOGGER_BASE = 'otopi' - LOG_FILE_PREFIX = 'otopi' - DEFAULT_CONFIG_FILE = '/etc/otopi.conf' - DEFAULT_COMMAND_SEARCH_PATH = ":".join( - ( - '/usr/local/sbin', - '/usr/local/bin', - '/usr/sbin', - '/usr/bin', - '/sbin', - '/bin', - ) - ) CONFIG_SECTION_DEFAULT = 'environment:default' CONFIG_SECTION_INIT = 'environment:init' CONFIG_SECTION_OVERRIDES = 'environment:override' DIALOG_DIALECT_MACHINE = 'machine' DIALOG_DIALECT_HUMAN = 'human' - PACKAGER_KEEP_ALIVE_INTERVAL = 30 @util.export diff --git a/src/otopi/dialog.py b/src/otopi/dialog.py index 195f533..3d365af 100644 --- a/src/otopi/dialog.py +++ b/src/otopi/dialog.py @@ -186,14 +186,14 @@ self.__handler.setLevel(logging.INFO) if logFormatter is not None: self.__handler.setFormatter(logFormatter) - l = logging.getLogger(name=constants.Const.LOGGER_BASE) + l = logging.getLogger(name=constants.Log.LOGGER_BASE) l.addHandler(self.__handler) def __restoreStdHandles(self): self.__flush(sys.stdout) self.__flush(sys.stderr) if self.__handler is not None: - l = logging.getLogger(name=constants.Const.LOGGER_BASE) + l = logging.getLogger(name=constants.Log.LOGGER_BASE) l.removeHandler(self.__handler) self.__handler.close() self.__handler = None diff --git a/src/otopi/main.py b/src/otopi/main.py index 1ca4931..6aaecac 100644 --- a/src/otopi/main.py +++ b/src/otopi/main.py @@ -79,7 +79,7 @@ def emit(self, record): pass - logger = logging.getLogger(constants.Const.LOGGER_BASE) + logger = logging.getLogger(constants.Log.LOGGER_BASE) logger.propagate = False logger.setLevel(logging.DEBUG) logger.addHandler(NullHandler()) diff --git a/src/plugins/otopi/core/config.py b/src/plugins/otopi/core/config.py index 2bdd538..972a6f0 100644 --- a/src/plugins/otopi/core/config.py +++ b/src/plugins/otopi/core/config.py @@ -91,7 +91,7 @@ util.getKey( dictionary=os.environ, key=constants.SystemEnvironment.CONFIG, - default=constants.Const.DEFAULT_CONFIG_FILE, + default=constants.Defaults.CONFIG_FILE, ) ) diff --git a/src/plugins/otopi/core/log.py b/src/plugins/otopi/core/log.py index 6b67307..2aaca7c 100644 --- a/src/plugins/otopi/core/log.py +++ b/src/plugins/otopi/core/log.py @@ -95,7 +95,7 @@ self.environment[constants.CoreEnv.LOG_FILTER] = self._MyLoggerFilter() self.environment.setdefault( constants.CoreEnv.LOG_FILE_NAME_PREFIX, - constants.Const.LOG_FILE_PREFIX + constants.Defaults.LOG_FILE_PREFIX ) # diff --git a/src/plugins/otopi/packagers/yumpackager.py b/src/plugins/otopi/packagers/yumpackager.py index 1eef824..b66e477 100644 --- a/src/plugins/otopi/packagers/yumpackager.py +++ b/src/plugins/otopi/packagers/yumpackager.py @@ -71,7 +71,7 @@ try: self.environment.setdefault( constants.PackEnv.KEEP_ALIVE_INTERVAL, - constants.Const.PACKAGER_KEEP_ALIVE_INTERVAL + constants.Defaults.PACKAGER_KEEP_ALIVE_INTERVAL ) from . import miniyumlocal diff --git a/src/plugins/otopi/system/command.py b/src/plugins/otopi/system/command.py index bdd3962..d625eeb 100644 --- a/src/plugins/otopi/system/command.py +++ b/src/plugins/otopi/system/command.py @@ -59,7 +59,7 @@ def _init(self): self.environment.setdefault( constants.SysEnv.COMMAND_PATH, - constants.Const.DEFAULT_COMMAND_SEARCH_PATH + constants.Defaults.COMMAND_SEARCH_PATH ) self.context.registerCommand(command=self) -- To view, visit http://gerrit.ovirt.org/10108 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7ba5d684b5a51b2d609f21359974bd1bd899ca49 Gerrit-PatchSet: 1 Gerrit-Project: otopi Gerrit-Branch: master Gerrit-Owner: Alon Bar-Lev <alo...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches