当前位置: 首页>>代码示例>>Python>>正文


Python logging.make_logger函数代码示例

本文整理汇总了Python中mast.logging.make_logger函数的典型用法代码示例。如果您正苦于以下问题:Python make_logger函数的具体用法?Python make_logger怎么用?Python make_logger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了make_logger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle

def handle(plugin):
    """main funcion which will be routed to the plugin's endpoint"""
    logger = make_logger("mast.plugin_functions")
    import urllib
    if flask.request.method == 'GET':
        logger.info("GET Request received")
        name = flask.request.args.get('callable')
        logger.debug("name: {}".format(name))
        appliances = flask.request.args.getlist('appliances[]')
        logger.debug("appliances: {}".format(str(appliances)))
        credentials = [xordecode(urllib.unquote(_), key=xorencode(
                        flask.request.cookies["9x4h/mmek/j.ahba.ckhafn"]))
                        for _ in flask.request.args.getlist('credentials[]')]

        logger.debug("getting form")
        try:
            form = get_form(plugin.replace("mast.", ""), name, appliances, credentials)
        except:
            logger.exception("An unhandled exception occurred during execution.")
            raise
        logger.debug("Got form")
        return form
    elif flask.request.method == 'POST':
        logger.info("Received POST request for {}".format(plugin))
        try:
            return flask.Markup(str(call_method(plugin, flask.request.form)))
        except:
            logger.exception("An unhandled exception occurred during processing of request.")
            raise
开发者ID:McIndi,项目名称:mast.plugin_utils,代码行数:29,代码来源:plugin_functions.py

示例2: clone_svn

def clone_svn(server, base_uri, vcs_creds, vcs_uri, export_dir):
    logger = make_logger("mast.datapower.deploy")
    if not os.path.exists(export_dir):
        os.makedirs(export_dir)
    url = "'https://{}{}{}'".format(
        server,
        base_uri,
        vcs_uri).replace("//", "/")
    username, password = vcs_creds.split(":")
    command = [
        "svn",
        "export",
        url,
        "--force",
        "--no-auth-cache",
        "--non-interactive",
        "--username",
        "'{}'".format(username),
        "--password",
        "'{}'".format(re.escape(password))
    ]
    with cd(export_dir):
        out, err = system_call(command)
    if err:
        logger.err("Error received from svn: {}".format(err))
        print "Error received from svn: {}".format(err)
        sys.exit(-1)
    return export_dir
开发者ID:McIndi,项目名称:mast.datapower.deploy,代码行数:28,代码来源:deploy.py

示例3: upload_file

def upload_file(appl, domain, f, overwrite, create_dir, ignore_errors, filestore=None):
    logger = make_logger("fs-sync")

    dirname = "/".join(f[1].split("/")[:-1])
    location = dirname.split(":")[0] + ":"
    if filestore is None:
        filestore = appl.get_filestore(domain=domain,
                                       location=location)

    if create_dir:
        if (not appl.directory_exists(dirname, domain, filestore)) and (not appl.location_exists(dirname, domain, filestore)):
            print "\t\t\tCreating Directory {}".format(dirname)
            resp = appl.CreateDir(domain=domain, Dir=dirname)
            if "<error-log>" in resp.text:
                logger.error("An error occurred creating directory {} on {}:{}".format(dirname, appl.hostname, domain))
                print "\t\t\t\tERROR Creating directory, stack trace can be found in the logs"
                if not ignore_errors:
                    raise datapower.AuthenticationFailure
            filestore = appl.get_filestore(domain=domain,
                                           location=location)
    else:
        if (not appl.directory_exists(dirname, domain, filestore)) and (not appl.location_exists(dirname, domain, filestore)):
            logger.error(
                "Directory {} does not exist in {} domain on {}".format(
                    dirname, domain, appl.hostname))
            _exit()
    resp = appl.set_file(f[0], f[1], domain, overwrite, filestore)
    if not resp:
        print "\t\t\tNot overwriting {}".format(f[1])
    return filestore
开发者ID:McIndi,项目名称:mast.installer,代码行数:30,代码来源:fs-sync.py

示例4: ensure_config_file_exists

def ensure_config_file_exists():
    logger = make_logger("mast.datapower.deploy")
    config_file_default = os.path.join(
        mast_home, "etc", "default", "deploy.conf"
    )
    config_file_local = os.path.join(
        mast_home, "etc", "local", "deploy.conf"
    )
    error = False
    if not os.path.exists(config_file_default):
        # The default config doesn't exist
        with open(config_file_default, "w") as fout:
            fout.write(_get_data_file("deploy.conf"))
        msg = " ".join((
            "default config file not found.",
            "A blank config file was placed created for you",
            "Please follow the instructions within this file",
            "to configure this script.",
            "The file can be found here: {}".format(config_file_default)
        ))
        logger.error(msg)
        error = True
    elif not os.path.exists(config_file_local):
        # The default config exists, the user needs to configure the
        # local config
        logger.error(
            "Configuration not found please follow the instructions "
            "here {} to configure this script".format(config_file_default))
        error = True
    if error:
        print "Error: Config file does not exists, see log for details"
        sys.exit(-1)
开发者ID:McIndi,项目名称:mast.datapower.deploy,代码行数:32,代码来源:deploy.py

示例5: list_checkpoints

def list_checkpoints(appliances=[],
                     credentials=[],
                     timeout=120,
                     no_check_hostname=False,
                     Domain="",
                     web=False):
    """Lists the checkpoints which are currently in the
    specified domain

Parameters:

* `-a, --appliances`: The hostname(s), ip address(es), environment name(s)
or alias(es) of the appliances you would like to affect. For details
on configuring environments please see the comments in
`environments.conf` located in `$MAST_HOME/etc/default`. For details
on configuring aliases, please see the comments in `hosts.conf` located in
`$MAST_HOME/etc/default`. To pass multiple arguments to this parameter,
use multiple entries of the form `[-a appliance1 [-a appliance2...]]`
* `-c, --credentials`: The credentials to use for authenticating to the
appliances. Should be either one set to use for all appliances
or one set for each appliance. Credentials should be in the form
`username:password`. To pass multiple credentials to this parameter, use
multiple entries of the form `[-c credential1 [-c credential2...]]`.
When referencing multiple appliances with multiple credentials,
there must be a one-to-one correspondence of credentials to appliances:
`[-a appliance1 [-a appliance2...]] [-c credential1 [-c credential2...]]`
If you would prefer to not use plain-text passwords,
you can use the output of `$ mast-system xor <username:password>`.
* `-t, --timeout`: The timeout in seconds to wait for a response from
an appliance for any single request. __NOTE__ Program execution may
halt if a timeout is reached.
* `-n, --no-check-hostname`: If specified SSL verification will be turned
off when sending commands to the appliances.
* `-D, --Domain`: The domain to list the checkpoints for
* `-w, --web`: __For Internel Use Only, will be removed in future versions.
DO NOT USE.__"""
    logger = make_logger("mast.backups")
    check_hostname = not no_check_hostname
    env = datapower.Environment(
        appliances,
        credentials,
        timeout,
        check_hostname=check_hostname)
    logger.info(
        "Attempting to list checkpoints for {} in {} domain".format(
            str(env.appliances), Domain))

    resp = env.perform_action("get_existing_checkpoints", domain=Domain)
    logger.debug("Responses received: {}".format(str(resp)))
    if web:
        return (util.web_list_checkpoints(resp, Domain),
                util.render_history(env))

    for host, d in resp.items():
        print host, '\n', '=' * len(host)
        for key, value in d.items():
            print key, "-".join(value["date"]), ":".join(value["time"])
        print
开发者ID:McIndi,项目名称:mast.datapower.backups,代码行数:58,代码来源:backups.py

示例6: flush_rbm_cache

def flush_rbm_cache(appliances=[],
                    credentials=[],
                    timeout=120,
                    no_check_hostname=False,
                    Domain="",
                    web=False):
    """Flush the RBM Cache in the specified Domain

Parameters:

* `-a, --appliances`: The hostname(s), ip address(es), environment name(s)
or alias(es) of the appliances you would like to affect. For details
on configuring environments please see the comments in
`environments.conf` located in `$MAST_HOME/etc/default`. For details
on configuring aliases, please see the comments in `hosts.conf` located in
`$MAST_HOME/etc/default`. To pass multiple arguments to this parameter,
use multiple entries of the form `[-a appliance1 [-a appliance2...]]`
* `-c, --credentials`: The credentials to use for authenticating to the
appliances. Should be either one set to use for all appliances
or one set for each appliance. Credentials should be in the form
`username:password`. To pass multiple credentials to this parameter, use
multiple entries of the form `[-c credential1 [-c credential2...]]`. 
When referencing multiple appliances with multiple credentials, 
there must be a one-to-one correspondence of credentials to appliances:
`[-a appliance1 [-a appliance2...]] [-c credential1 [-c credential2...]]` 
If you would prefer to not use plain-text passwords, 
you can use the output of `$ mast-system xor <username:password>`.
* `-t, --timeout`: The timeout in seconds to wait for a response from
an appliance for any single request. __NOTE__ Program execution may
halt if a timeout is reached.
* `-n, --no-check-hostname`: If specified SSL verification will be turned
off when sending commands to the appliances.
* `-D, --Domain`: The domain for which to flush the RBM Cache
* `-w, --web`: __For Internel Use Only, will be removed in future versions.
DO NOT USE.__"""
    logger = make_logger("mast.accounts")
    check_hostname = not no_check_hostname
    env = datapower.Environment(
        appliances,
        credentials,
        timeout,
        check_hostname=check_hostname)
    msg = "Attempting to flush RBM cache on {}".format(str(env.appliances))
    logger.info(msg)
    if not web:
        print msg

    responses = env.perform_action('FlushRBMCache', **{'domain': Domain})
    logger.debug("Responses received {}".format(str(responses)))

    if not web:
        for host, resp in responses.items():
            print "{}\n{}".format(host, "="*len(host))
            pprint_xml(resp.xml)
    else:
        return util.render_boolean_results_table(
            responses, suffix="flush_rbm_cache"), util.render_history(env)
开发者ID:McIndi,项目名称:mast.datapower.accounts,代码行数:57,代码来源:accounts.py

示例7: create_inprogress_file

def create_inprogress_file(environment):
    logger = make_logger("mast.datapower.deploy")
    fname = os.path.join(mast_home, "tmp", "{}.inprogress".format(environment))
    if os.path.exists(fname):
        logger.error("Deployment already in progress, aborting!")
        print "Deployment already in progress, aborting!"
        sys.exit(-1)
    else:
        with open(fname, "w") as fout:
            fout.write(Timestamp().timestamp)
开发者ID:McIndi,项目名称:mast.datapower.deploy,代码行数:10,代码来源:deploy.py

示例8: run

    def run(self):
        """
        _method_: `mast.datapower.web.Plugin.run(self)`

        This method is responsible for starting the web gui. It will log
        to `mast.datapower.web.log` When starting and/or stopping.
        """
        logger = make_logger("mast.datapower.web")
        logger.info("Attempting to start web gui.")
        main()
        logger.info("web gui stopped")
开发者ID:McIndi,项目名称:mast,代码行数:11,代码来源:__init__.py

示例9: main

def main():
    """
    _function_: `mast.datapower.web.main()`

    This is the main function which will spin up a server listening
    to the configured port and block until a SIGTERM or equivalent
    (Ctrl + C) is received at which point it will quit.

    Logs to: `gui.main.log`

    Parameters:

    This function does not accept any arguments.
    """
    logger = make_logger("gui.main")
    logger.debug("Running as user {}".format(getpass.getuser()))
    logger.debug("Running in directory {}".format(os.getcwd()))

    cherrypy.tree.graft(app, '/')

    # Set the configuration of the web server
    cherrypy.config.update({
        'engine.autoreload.on': False,
        'log.screen': False,
        'server.socket_port': port,
        'server.socket_host': host,
        'server.max_request_body_size': max_file_upload_size
    })

    if secure:
        logger.debug("Configuring TLS")
        cherrypy.server.ssl_module = 'builtin'
        CherryPyWSGIServer.ssl_adapter = BuiltinSSLAdapter(
            cert,
            key,
            cacert)

    # Start the CherryPy WSGI web server
    try:
        engine = cherrypy.engine
        engine.signal_handler.subscribe()
        if hasattr(engine, "console_control_handler"):
            engine.console_control_handler.subscribe()

        print "MAST Web listening on https://{}:{}".format(host, port)

        cherrypy.engine.start()
        cherrypy.engine.block()
    except KeyboardInterrupt:
        cherrypy.engine.exit()
    except:
        logger.exception(
            "Sorry, an unhandled exception occurred while starting CherryPy")
开发者ID:McIndi,项目名称:mast.datapower.web,代码行数:53,代码来源:gui.py

示例10: run

        def run(self):
            """
            _method_: `mast.daemon.MASTd.run(self)`

            This method will be called when mastd has successfully been
            spawned and forked. This is where most of the logic happens.

            If the plugin's thread is found to be dead, it will be restarted.
            """
            logger = make_logger("mast.daemon")
            os.chdir(mast_home)
            try:
                if not hasattr(self, "named_objects"):
                    self.get_plugins()
                threads = {}

                while True:
                    for key, value in self.named_objects.items():
                        if key in threads.keys():
                            if threads[key].isAlive():
                                continue
                            else:
                                logger.debug("Plugin {} found, but dead, attempting to restart".format(key))
                                try:
                                    threads[key] = value()
                                    threads[key].start()
                                    continue
                                except:
                                    logger.exception(
                                        "An unhandled exception occurred "
                                        "during execution.")
                                    continue
                        else:
                            logger.info(
                                "Plugin "
                                "{} not found. Attempting to start.".format(
                                    key))
                            try:
                                threads[key] = value()
                                threads[key].start()
                                continue
                            except:
                                logger.exception(
                                    "An unhandled exception occurred "
                                    "during execution.")
                                continue
                            continue
                    sleep(60)
            except:
                logger.exception(
                    "An uhhandled exception occurred during execution")
                raise
开发者ID:McIndi,项目名称:mast,代码行数:52,代码来源:mast_daemon.py

示例11: status

    def status(self):
        logger = make_logger("mast.datapower.status")

        t = Timestamp()
        check_hostname = "true" in flask.request.form.get(
            'check_hostname').lower()
        appliances = flask.request.form.getlist('appliances[]')
        credentials = [xordecode(
            _,
            key=xorencode(
                flask.request.cookies["9x4h/mmek/j.ahba.ckhafn"]))
            for _ in flask.request.form.getlist('credentials[]')]
        if not appliances:
            return flask.abort(404)

        env = datapower.Environment(
            appliances,
            credentials,
            check_hostname=check_hostname)

        providers = flask.request.form.getlist("providers[]")

        resp = {
            "appliances": appliances,
            "time": t.short}

        for provider in providers:
            _provider = provider.split(".")[0]
            resp[provider] = []
            for appliance in env.appliances:
                try:
                    _status = appliance.get_status(_provider)
                except datapower.AuthenticationFailure:
                    # This is to handle an intermittent authentication failure
                    # sometimes issued by the DataPower. We will sleep 2
                    # seconds and try again
                    sleep(2)
                    try:
                        return self.status()
                    except:
                        logger.exception(
                            "An unhandled exception occurred during execution")
                        raise
                except:
                    logger.exception(
                        "An unhandled exception occurred during execution")
                    raise
                metric = _status.xml.find(PROVIDER_MAP[provider]).text
                resp[provider].append(metric)
        return flask.jsonify(resp)
开发者ID:McIndi,项目名称:mast,代码行数:50,代码来源:status.py

示例12: run

        def run(self):
            """
            _method_: `mast.daemon.MASTd.run(self)`

            This function does the brunt of the work by looping through
            the plugins and starting them. After that it enters an
            infinite loop checking the status of each plugin. If the
            plugin is found dead it will attempt to restart the plugin.
            """
            logger = make_logger("mast.daemon")
            servicemanager.LogInfoMsg("Inside run")
            global PLUGINS
            servicemanager.LogInfoMsg("Plugins: {}".format(PLUGINS))
            try:
                threads = {}
                servicemanager.LogInfoMsg("Entering main loop")
                while not self.stop_requested:
                    for key, value in PLUGINS.items():
                        if key in threads.keys():
                            if threads[key].isAlive():
                                continue
                            else:
                                logger.debug("Plugin {} found, but dead, attempting to restart".format(key))
                                try:
                                    threads[key] = value()
                                    threads[key].start()
                                    logger.debug("Plugin {} started".format(key))
                                    continue
                                except:
                                    logger.exception("An unhandled exception " "occurred during execution.")
                                    continue
                        else:
                            logger.info("Plugin " "{} not found. Attempting to start.".format(key))
                            try:
                                threads[key] = value()
                                threads[key].start()
                                continue
                            except:
                                logger.exception("An unhandled exception occurred " "during execution.")
                                continue
                            continue
                    rc = win32event.WaitForSingleObject(self.hWaitStop, self.timeout)
                    # Check to see if self.hWaitStop happened
                    if rc == win32event.WAIT_OBJECT_0:
                        # Stop signal encountered
                        servicemanager.LogInfoMsg("SomeShortNameVersion - STOPPED!")
                        break
            except:
                logger.exception("An uhhandled exception occurred during execution")
                raise
开发者ID:McIndi,项目名称:mast.daemon,代码行数:50,代码来源:mast_daemon.py

示例13: clone_repo_from_vcs

def clone_repo_from_vcs(vcs_details):
    logger = make_logger("mast.datapower.deploy")
    vcs_type = vcs_details[0]
    if vcs_type.lower() == "git":
        repo_path = clone_git(*vcs_details[1:])
    elif vcs_type.lower() == "svn":
        repo_path = clone_svn(*vcs_details[1:])
    elif vcs_type.lower() == "tfs":
        repo_path = clone_tfs(*vcs_details[1:])
    else:
        logger.error("Unsupported VCS type defined")
        print "Unsupported VCS type defined"
        sys.exit(-1)
    return repo_path
开发者ID:McIndi,项目名称:mast.datapower.deploy,代码行数:14,代码来源:deploy.py

示例14: __init__

    def __init__(self):
        logger = make_logger("mast.status")
        global mast_home
        logger.debug("found MAST_HOME: {}".format(mast_home))
        self.route = self.status

        config_file = os.path.join(
            mast_home,
            "etc",
            "default",
            "status.conf")
        if not os.path.exists(config_file):
            logger.debug("Config file doesn't exist creating default config")
            with open(config_file, "w") as fout:
                fout.write(get_data_file("plugin.conf"))
开发者ID:McIndi,项目名称:mast,代码行数:15,代码来源:status.py

示例15: get_plugins

        def get_plugins(self):
            """
            _method_: `mast.daemon.MASTd.get_plugins(self)`

            This method uses `pkg_resources.iter_entry_points` to locate
            all `mastd_plugin`s and return them.
            """
            logger = make_logger("mast.daemon")
            self.named_objects = {}
            for ep in pkg_resources.iter_entry_points(group="mastd_plugin"):
                try:
                    self.named_objects.update({ep.name: ep.load()})
                except:
                    logger.exception("An unhandled exception occurred during execution.")
                    pass
            logger.info("Collected plugins {}".format(str(self.named_objects.keys())))
开发者ID:McIndi,项目名称:mast.daemon,代码行数:16,代码来源:mast_daemon.py


注:本文中的mast.logging.make_logger函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。