示例#1
0
def _setup_logging(args):
    # Set environment to standard to use periods for decimals and avoid localization
    os.environ["LC_ALL"] = "C"
    os.environ["LC"] = "C"
    os.environ["LANG"] = "C"
    config = None
    if len(args) == 1 and isinstance(args[0], (list, tuple)):
        args = args[0]
    for arg in args:
        if config_utils.is_nested_config_arg(arg):
            config = arg["config"]
            break
        elif config_utils.is_std_config_arg(arg):
            config = arg
            break
        elif isinstance(arg,
                        (list, tuple)) and config_utils.is_nested_config_arg(
                            arg[0]):
            config = arg[0]["config"]
            break
    if config is None:
        raise NotImplementedError("No config found in arguments: %s" % args[0])
    handler = setup_local_logging(config, config.get("parallel", {}))
    try:
        yield config
    except:
        logger.exception("Unexpected error")
        raise
    finally:
        if hasattr(handler, "close"):
            handler.close()
示例#2
0
def _setup_logging(args):
    config = None
    if len(args) == 1 and isinstance(args[0], (list, tuple)):
        args = args[0]
    for arg in args:
        if config_utils.is_nested_config_arg(arg):
            config = arg["config"]
            break
        elif config_utils.is_std_config_arg(arg):
            config = arg
            break
        elif isinstance(arg, (list, tuple)) and config_utils.is_nested_config_arg(arg[0]):
            config = arg[0]["config"]
            break
    if config is None:
        raise NotImplementedError("No config found in arguments: %s" % args[0])
    handler = setup_local_logging(config, config.get("parallel", {}))
    try:
        yield config
    except:
        logger.exception("Unexpected error")
        raise
    finally:
        if hasattr(handler, "close"):
            handler.close()
示例#3
0
def _setup_logging(args):
    config = None
    if len(args) == 1 and isinstance(args[0], (list, tuple)):
        args = args[0]
    for arg in args:
        if config_utils.is_nested_config_arg(arg):
            config = arg["config"]
            break
        elif config_utils.is_std_config_arg(arg):
            config = arg
            break
        elif isinstance(arg,
                        (list, tuple)) and config_utils.is_nested_config_arg(
                            arg[0]):
            config = arg[0]["config"]
            break
    if config is None:
        raise NotImplementedError("No config found in arguments: %s" % args[0])
    handler = setup_local_logging(config, config.get("parallel", {}))
    try:
        yield config
    except:
        logger.exception("Unexpected error")
        raise
    finally:
        if hasattr(handler, "close"):
            handler.close()
示例#4
0
 def wrapper(*args, **kwargs):
     config = None
     for arg in args:
         if config_utils.is_std_config_arg(arg):
             config = arg
             break
         elif config_utils.is_nested_config_arg(arg):
             config = arg["config"]
         elif isinstance(
                 arg,
             (list, tuple)) and config_utils.is_nested_config_arg(arg[0]):
             config = arg[0]["config"]
             break
     assert config, "Could not find config dictionary in function arguments."
     if config.get("parallel", {}).get("log_queue") and not config.get(
             "parallel", {}).get("wrapper"):
         handler = setup_local_logging(config, config["parallel"])
     else:
         handler = None
     try:
         out = f(*args, **kwargs)
     finally:
         if handler and hasattr(handler, "close"):
             handler.close()
     return out
def _setup_logging(args):
    # Set environment to standard to use periods for decimals and avoid localization
    os.environ["LC_ALL"] = "C"
    os.environ["LC"] = "C"
    os.environ["LANG"] = "C"
    config = None
    if len(args) == 1 and isinstance(args[0], (list, tuple)):
        args = args[0]
    for arg in args:
        if config_utils.is_nested_config_arg(arg):
            config = arg["config"]
            break
        elif config_utils.is_std_config_arg(arg):
            config = arg
            break
        elif isinstance(arg, (list, tuple)) and config_utils.is_nested_config_arg(arg[0]):
            config = arg[0]["config"]
            break
    if config is None:
        raise NotImplementedError("No config found in arguments: %s" % args[0])
    handler = setup_local_logging(config, config.get("parallel", {}))
    try:
        yield config
    except:
        logger.exception("Unexpected error")
        raise
    finally:
        if hasattr(handler, "close"):
            handler.close()
示例#6
0
 def wrapper(*args, **kwargs):
     config = None
     for arg in args:
         if config_utils.is_std_config_arg(arg):
             config = arg
             break
         elif config_utils.is_nested_config_arg(arg):
             config = arg["config"]
             break
     assert config, "Could not find config dictionary in function arguments."
     if config.get("parallel", {}).get("log_queue") and not config.get("parallel", {}).get("wrapper"):
         handler = setup_local_logging(config, config["parallel"])
     else:
         handler = None
     try:
         out = f(*args, **kwargs)
     finally:
         if handler and hasattr(handler, "close"):
             handler.close()
     return out