Exemple #1
0
    def doPost(self):
        """Missing DocString

        :return:
        """
        post_cmds = []

        if not afcommon.checkBlockFlag( self.taskInfo['block_flags'],'skipthumbnails'):
            post_cmds.extend(self.generateThumbnail( False))

        # post_cmds.extend(['ls -la > ' + self.taskInfo['store_dir'] + '/afile'])

        return post_cmds
Exemple #2
0
    def doPost(self):
        """Missing DocString

        :return:
        """
        post_cmds = []

        if not afcommon.checkBlockFlag( self.taskInfo['block_flags'],'skipthumbnails'):
            post_cmds.extend(self.generateThumbnail( False))

        # post_cmds.extend(['ls -la > ' + self.taskInfo['store_dir'] + '/afile'])

        return post_cmds
Exemple #3
0
 def isSkippingExistingFiles(self):
     return afcommon.checkBlockFlag( self.taskInfo['block_flags'], 'skipexistingfiles')
Exemple #4
0
 def isSkippingExistingFiles(self):
     return afcommon.checkBlockFlag(self.taskInfo['block_flags'],
                                    'skipexistingfiles')
Exemple #5
0
 def setSlaveLostIgnore(self):
     if not afcommon.checkBlockFlag(self.data['flags'], 'multihost'):
         print('Block::setSlaveLostIgnore: Block is not multihost.')
         return
     self.data['flags'] = afcommon.setBlockFlag(self.data['flags'], 'slavelostignore')
Exemple #6
0
 def setSlaveLostIgnore(self):
     if not afcommon.checkBlockFlag(self.data['flags'], 'multihost'):
         print('Block::setSlaveLostIgnore: Block is not multihost.')
         return
     self.data['flags'] = afcommon.setBlockFlag(self.data['flags'], 'slavelostignore')
Exemple #7
0
    def __init__(self, taskInfo, i_verbose):
        self.taskInfo = taskInfo
        self.verbose = i_verbose
        self.log = None

        self.numeric = afcommon.checkBlockFlag(taskInfo['block_flags'],
                                               'numeric')
        if self.verbose: print(taskInfo)

        self.pm = cgrupathmap.PathMap()

        self.str_capacity = str_capacity
        self.str_hosts = str_hosts
        self.str_hostsprefix = str_hostsprefix
        self.str_hostseparator = str_hostseparator

        # Transfer working folder:
        taskInfo['wdir'] = self.pm.toClient(taskInfo['wdir'])

        # Process command:
        command = self.processCommandPattern()

        # Transfer command:
        command = self.pm.toClient(command)

        # Apply capacity:
        if self.taskInfo['capacity'] > 0:
            command = self.applyCmdCapacity(command)

        # Apply hosts (multihosts tasks):
        if len(self.taskInfo['hosts']):
            command = self.applyCmdHosts(command)

        taskInfo['command'] = command
        if self.verbose:
            print('Processed task command:\n' + command)

        # Process files:
        taskInfo['files'] = self.processFilesPattern()
        if self.verbose:
            print('Processed task files:')
            for afile in taskInfo['files']:
                print(afile)

        # Transfer paths in files:
        for i in range(0, len(self.taskInfo['files'])):
            self.taskInfo['files'][i] = \
                self.pm.toClient(self.taskInfo['files'][i])

        # Check files:
        if self.isSkippingExistingFiles() and len(self.taskInfo['files']):
            self.checkExistingFiles()

        # Transfer paths in environment:
        for name in self.taskInfo['environment']:
            self.taskInfo['environment'][name] = self.pm.toClient(
                self.taskInfo['environment'][name])

        # When GUI receives task exec to show files,
        # server sends exec with parsed files.
        for i in range(0, len(self.taskInfo['parsed_files'])):
            self.taskInfo['parsed_files'][i] = \
                self.pm.toClient(self.taskInfo['parsed_files'][i])

        # Initialize parser:
        self.parser = None
        parser = cgruutils.toStr(taskInfo['parser'])
        if len(taskInfo['parser']):
            try:
                mod = __import__('parsers', globals(), locals(), [parser])
                cmd = 'mod.%s.%s()' % (parser, parser)
                self.parser = eval(cmd)
                self.parser.setTaskInfo(taskInfo)
            except:  # TODO: too broad exception clause
                self.parser = None
                print('ERROR: Failed to import parser "%s"' % parser)
                traceback.print_exc(file=sys.stdout)

        if self.verbose and self.log and len(self.log):
            print(self.log)
Exemple #8
0
 def hasAppendedTasks(self):
     return afcommon.checkBlockFlag(self.flags, 'appendedtasks')
Exemple #9
0
 def isNumeric(self):
     return bool(afcommon.checkBlockFlag(self.flags, 'numeric'))