zephir.monitor.agentmanager.zephir_tap

Package zephir :: Package monitor :: Package agentmanager :: Module zephir_tap |
[frames] | no frames]

# Source Code for Module zephir.monitor.agentmanager.zephir_tap

     1  # -*- coding: UTF-8 -*-
     2  ###########################################################################
     3  # Eole NG - 2007
     4  # Copyright Pole de Competence Eole  (Ministere Education - Academie Dijon)
     5  # Licence CeCill  cf /root/LicenceEole.txt
     6  # eole@ac-dijon.fr
     7  ###########################################################################
     8
     9  """
    10  Plugin pour TwistedMatrix et C{mktap}/C{twistd}.
    11  """
    12
    13  import gettext, locale, os, sys
    14  from twisted.python import usage   # twisted command-line processing & logging
    15
    16  # install locales early
    17  from zephir.monitor.agentmanager import ZEPHIRAGENTS_DATADIR
    18  APP = 'zephir-agents'
    19  DIR = os.path.join(ZEPHIRAGENTS_DATADIR, 'i18n')
    20  gettext.install(APP, DIR, unicode=False)
    21
    22  from zephir.monitor.agentmanager import config as cfg
    23  from zephir.monitor.agentmanager.util import expand_dirname
    24  from zephir.monitor.agentmanager.zephirservice import ZephirService
    25
    26
    27 -class Options(usage.Options):
    28      optParameters = [
    29          ["config", None, cfg.DEFAULT_CONFIG['config_dir'],
    30           _("Directory to search for configurations when loading agents")],
    31          ["data", None, cfg.DEFAULT_CONFIG['state_dir'],
    32           _("Directory where state data will be stored")],
    33          ["archive", None, cfg.DEFAULT_CONFIG['uucp_dir'],
    34           _("Directory where the upload archive will be created")],
    35          ["static", None, cfg.DEFAULT_CONFIG['static_web_dir'],
    36           _("Directory for static web data (graphics, stylesheets...)")],
    37          ["actions", None, cfg.DEFAULT_CONFIG['action_dir'],
    38           _("Directory for agent action files")],
    39          ["static-base", None, cfg.DEFAULT_CONFIG['static_base_url'],
    40           _("Base URL path for static web data")],
    41          ["tmp", None, cfg.DEFAULT_CONFIG['tmp_data_dir'],
    42           _("Temporary folder for archiving data")],
    43          ]
    44
    45
    46 -def makeService(commandline_config):
    47      config = setup_config(commandline_config)
    48      # setup_filesystem_env()
    49      return ZephirService(config,serve_static=True).with_updater_and_publisher()
    50
    51
    52 -def setup_config(commandline_config):
    53      """Change stuff in C{cfg}"""
    54
    55      config = cfg.DEFAULT_CONFIG.copy()
    56      # this could use some os.path.expanduser() and os.path.expandvars()
    57      config['config_dir'] = expand_dirname(commandline_config["config"])
    58      config['state_dir'] = expand_dirname(commandline_config["data"])
    59      config['uucp_dir'] = expand_dirname(commandline_config["archive"])
    60      config['static_web_dir'] = expand_dirname(commandline_config["static"])
    61      config['action_dir'] = expand_dirname(commandline_config["actions"])
    62      config['tmp_data_dir'] = expand_dirname(commandline_config["tmp"])
    63      config['static_base_url'] = commandline_config["static-base"]
    64      return config
    65
    66
    67  #startLogging est géré par twistd
    68  #def startService():
    69  #    log.startLogging(sys.stdout)
    70