Example #1
0
def Execute(rule, dirObj, pad = None):
    """
    Execute the rule in the given directory
    """

    if pad == 'None':
        pad = ''

    (toProcess, remoteRules,
     optionsToSet, newExportDir) = prepareRule(rule, dirObj)

    # Loop over each directory
    for dirName in toProcess:
        adagio.logInfo(rule, dirObj, 'RECUR: ' + dirName)
        if not os.path.isdir(dirName):
            print i18n.get('not_a_directory').format(dirName)
            sys.exit(1)
        remoteDir = directory.getDirectoryObject(dirName, optionsToSet)

	if remoteDir.rule_list == []:
	    # If rule_list is empty, there is no Properties.dgo in that dir, skip execution
            continue

        # Execute the targets in the remote directory
        remoteDir.Execute(remoteRules, pad + '  ')

    return
Example #2
0
def Execute(rule, dirObj, pad = None):
    """
    Execute the rule in the given directory
    """

    if pad == 'None':
        pad = ''

    (toProcess, remoteRules,
     optionsToSet, newExportDir) = prepareRule(rule, dirObj)

    # Loop over each directory
    for dirName in toProcess:
        adagio.logInfo(rule, dirObj, 'RECUR: ' + dirName)
        if not os.path.isdir(dirName):
            print i18n.get('not_a_directory').format(dirName)
            sys.exit(1)
        remoteDir = directory.getDirectoryObject(dirName, optionsToSet)
        remoteDir.Execute(remoteRules, pad + '  ')

    return
Example #3
0
def clean(rule, dirObj, deepClean = False, pad = None):
    """
    Clean the files produced by this rule
    """

    global module_prefix

    if pad == None:
        pad = ''

    adagio.logInfo(rule, dirObj, 'Cleaning')

    (toProcess, remoteRules,
     optionsToSet, newExportDir) = prepareRule(rule, dirObj)

    # When cleaning, rules should be executed in reversed order
    remoteRules.reverse()

    if deepClean:
        # If the clean is deep, attach .clean suffix to all remote rules
        remoteRules = [x + '.deepclean'
                         for x in remoteRules
                         if not re.match('(.+\.)?help$', x) and \
                             not re.match('(.+\.)?vars$', x)and \
                             not re.match('(.+\.)?clean$', x)]

        # If no rule is obtained, deep clean, means simply execute the clean
        # rule
        if remoteRules == []:
            remoteRules = ['deepclean']
    else:
        # If the clean is not deep, the execution only propagates to those rules
        # of type export and if the newExportDir is this directory (to clean the
        # current directory only). Otherwise, the rule is simply ignored.
        if newExportDir != dirObj.current_dir:
            return

        remoteRules = [x + '.clean'  for x in remoteRules
                         if x.startswith('export')]

    adagio.logInfo(rule, dirObj,
                'Remote Rules = ' + ' '.join(remoteRules))

    # Loop over each directory
    for dirName in toProcess:

        adagio.logInfo(rule, dirObj, 'RECUR: ' + dirName)
        remoteObj = directory.getDirectoryObject(dirName, optionsToSet)

        # If the clean is not deep and there is no given remote rules, we need
        # to select those that start with 'export'
        if (not deepClean) and (remoteRules == []):
            remoteRules = [x + '.clean' for x in remoteObj.rule_list
                             if re.match('^export(\..+)?$',
                                         properties.expandAlias(x,
                                                                remoteObj.alias))]

        # If remoteRules empty, there is nothing to process in the remote
        # directory.
        if remoteRules == []:
            continue

        # Execute the remote rules
        remoteObj.Execute(remoteRules, pad + '  ')

    return