예제 #1
0
def parse_options(args=None):
    """wrapper function for option parsing"""
    if os.environ.get("DEBUG_EASYBUILD_OPTIONS", "0").lower() in ("1", "true", "yes", "y"):
        # very early debug, to debug the generaloption itself
        fancylogger.logToScreen(enable=True)
        fancylogger.setLogLevel("DEBUG")

    usage = "%prog [options] easyconfig [...]"
    description = (
        "Builds software based on easyconfig (or parse a directory).\n"
        "Provide one or more easyconfigs or directories, use -H or --help more information."
    )

    try:
        eb_go = EasyBuildOptions(
            usage=usage,
            description=description,
            prog="eb",
            envvar_prefix=CONFIG_ENV_VAR_PREFIX,
            go_args=args,
            error_env_options=True,
            error_env_option_method=raise_easybuilderror,
        )
    except Exception, err:
        raise EasyBuildError("Failed to parse configuration options: %s" % err)
예제 #2
0
 def set_go_debug(self):
     """Check if debug options are on and then set fancylogger to debug.
     This is not the default way to set debug, it enables debug logging
     in an earlier stage to debug generaloption itself.
     """
     if self.options is None:
         if self.DEBUG_OPTIONS_BUILD:
             setLogLevel('DEBUG')
예제 #3
0
def parse_options(args=None):
    """wrapper function for option parsing"""
    if os.environ.get('DEBUG_EASYBUILD_OPTIONS', '0').lower() in ('1', 'true', 'yes', 'y'):
        # very early debug, to debug the generaloption itself
        fancylogger.logToScreen(enable=True)
        fancylogger.setLogLevel('DEBUG')

    usage = "%prog [options] easyconfig [...]"
    description = ("Builds software based on easyconfig (or parse a directory).\n"
                   "Provide one or more easyconfigs or directories, use -H or --help more information.")

    eb_go = EasyBuildOptions(usage=usage, description=description, prog='eb', envvar_prefix='EASYBUILD', go_args=args)
    return eb_go
예제 #4
0
 def __init__(self, hostname, port, log_dir, filename, pidfile):
     """Constructor"""
     stdin = '/dev/null'
     stdout = os.path.join(log_dir, 'logging_error.log')
     stderr = os.path.join(log_dir, 'logging_error.log')
     Daemon.__init__(self, pidfile, stdin, stdout, stderr)
     self.hostname = hostname
     self.port = port
     #Set up logging
     # get logger, we will log to file
     fancylogger.logToScreen(False)
     # we want to log absolutely everything that's comming at us
     fancylogger.setLogLevel(0)
     self.logfile = os.path.join(log_dir, filename)
     fancylogger.logToFile(self.logfile)
     self.logger = fancylogger.getLogger()
     self.socket_ = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
예제 #5
0
 def __init__(self, hostname, port, log_dir, filename, pidfile):
     """Constructor"""
     stdin = '/dev/null'
     stdout = os.path.join(log_dir, 'logging_error.log')
     stderr = os.path.join(log_dir, 'logging_error.log')
     Daemon.__init__(self, pidfile, stdin, stdout, stderr)
     self.hostname = hostname
     self.port = port
     #Set up logging
     # get logger, we will log to file
     fancylogger.logToScreen(False)
     # we want to log absolutely everything that's comming at us
     fancylogger.setLogLevel(0)
     self.logfile = os.path.join(log_dir, filename)
     fancylogger.logToFile(self.logfile)
     self.logger = fancylogger.getLogger()
     self.socket_ = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
예제 #6
0
    def take_action(self, action, dest, opt, value, values, parser):
        """Extended take_action"""
        orig_action = action  # keep copy

        if action == 'shorthelp':
            parser.print_shorthelp()
            parser.exit()
        elif action in ('store_true', 'store_false',) + self.EXTOPTION_LOG:
            if action in self.EXTOPTION_LOG:
                action = 'store_true'

            if opt.startswith("--%s-" % self.ENABLE):
                # keep action
                pass
            elif opt.startswith("--%s-" % self.DISABLE):
                # reverse action
                if action in ('store_true',) + self.EXTOPTION_LOG:
                    action = 'store_false'
                elif action in ('store_false',):
                    action = 'store_true'

            if orig_action in('store_debuglog', 'store_infolog', 'store_warninglog') and action == 'store_true':
                setLogLevel(orig_action.split('_')[1][:-3].upper())

            Option.take_action(self, action, dest, opt, value, values, parser)
        elif action in self.EXTOPTION_EXTRA_OPTIONS:
            if action == "extend":
                # comma separated list convert in list
                lvalue = value.split(self.EXTEND_SEPARATOR)
                values.ensure_value(dest, []).extend(lvalue)
            elif action == "date":
                lvalue = date_parser(value)
                setattr(values, dest, lvalue)
            elif action == "datetime":
                lvalue = datetime_parser(value)
                setattr(values, dest, lvalue)
            else:
                raise(Exception("Unknown extended option action %s (known: %s)" %
                                (action, self.EXTOPTION_EXTRA_OPTIONS)))
        else:
            Option.take_action(self, action, dest, opt, value, values, parser)

        # set flag to mark as passed by action (ie not by default)
        # - distinguish from setting default value through option
        if hasattr(values, '_action_taken'):
            values._action_taken[dest] = True
예제 #7
0
def parse_options(args=None):
    """wrapper function for option parsing"""
    if os.environ.get('DEBUG_EASYBUILD_OPTIONS',
                      '0').lower() in ('1', 'true', 'yes', 'y'):
        # very early debug, to debug the generaloption itself
        fancylogger.logToScreen(enable=True)
        fancylogger.setLogLevel('DEBUG')

    usage = "%prog [options] easyconfig [...]"
    description = (
        "Builds software based on easyconfig (or parse a directory).\n"
        "Provide one or more easyconfigs or directories, use -H or --help more information."
    )

    try:
        eb_go = EasyBuildOptions(usage=usage,
                                 description=description,
                                 prog='eb',
                                 envvar_prefix=CONFIG_ENV_VAR_PREFIX,
                                 go_args=args,
                                 error_env_options=True,
                                 error_env_option_method=raise_easybuilderror)
    except Exception, err:
        raise EasyBuildError("Failed to parse configuration options: %s" % err)
예제 #8
0
 def _set_default_loglevel(self):
     """Set the default loglevel if no logging options are set"""
     loglevel_set = sum([getattr(self.options, name, False) for name in self._logopts.keys()])
     if not loglevel_set and self.DEFAULT_LOGLEVEL is not None:
         setLogLevel(self.DEFAULT_LOGLEVEL)
예제 #9
0

# MAIN

try:
    init_build_options()

    options = {
        'backup': ("Backup up easyconfigs before modifying them", None,
                   'store_true', True, 'b'),
    }
    go = FixBrokenEasyconfigsOption(options)
    log = go.log

    fancylogger.logToScreen(enable=True, stdout=True)
    fancylogger.setLogLevel('WARNING')

    try:
        import easybuild.easyblocks.generic.configuremake
    except ImportError, err:
        raise EasyBuildError(
            "easyblocks are not available in Python search path: %s", err)

    for path in go.args:
        if not os.path.exists(path):
            raise EasyBuildError("Non-existing path %s specified", path)

    ec_files = [ec for p in go.args for ec in find_easyconfigs(p)]
    if not ec_files:
        raise EasyBuildError("No easyconfig files specified")
    else:
        log.info("%s: nothing to fix" % ec_file)

# MAIN

try:
    init_build_options()

    options = {
        'backup': ("Backup up easyconfigs before modifying them", None, 'store_true', True, 'b'),
    }
    go = FixBrokenEasyconfigsOption(options)
    log = go.log

    fancylogger.logToScreen(enable=True, stdout=True)
    fancylogger.setLogLevel('WARNING')

    try:
        import easybuild.easyblocks.generic.configuremake
    except ImportError, err:
        raise EasyBuildError("easyblocks are not available in Python search path: %s", err)

    for path in go.args:
        if not os.path.exists(path):
            raise EasyBuildError("Non-existing path %s specified", path)

    ec_files = [ec for p in go.args for ec in find_easyconfigs(p)]
    if not ec_files:
        raise EasyBuildError("No easyconfig files specified")

    log.info("Processing %d easyconfigs" % len(ec_files))
        log.info("%s: fixed" % ec_file)
    else:
        log.info("%s: nothing to fix" % ec_file)


# MAIN

try:
    init_build_options()

    options = {"backup": ("Backup up easyconfigs before modifying them", None, "store_true", True, "b")}
    go = FixBrokenEasyconfigsOption(options)
    log = go.log

    fancylogger.logToScreen(enable=True, stdout=True)
    fancylogger.setLogLevel("WARNING")

    try:
        import easybuild.easyblocks.generic.configuremake
    except ImportError, err:
        raise EasyBuildError("easyblocks are not available in Python search path: %s", err)

    for path in go.args:
        if not os.path.exists(path):
            raise EasyBuildError("Non-existing path %s specified", path)

    ec_files = [ec for p in go.args for ec in find_easyconfigs(p)]
    if not ec_files:
        raise EasyBuildError("No easyconfig files specified")

    log.info("Processing %d easyconfigs" % len(ec_files))