Beispiel #1
0
    def __init__(self, taskInfo, i_verbose):
        self.taskInfo = taskInfo
        self.verbose = i_verbose

        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 command and working folder:
        command = taskInfo['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
        taskInfo['wdir'] = self.pm.toClient(taskInfo['wdir'])

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

        # 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:
            print(taskInfo)
Beispiel #2
0
    def __init__(self, taskInfo):
        self.wdir = taskInfo['wdir']
        self.command = taskInfo['command']
        self.capacity = taskInfo['capacity']
        self.hosts = taskInfo['hosts']

        self.files = taskInfo.get('files', '')

        self.taskInfo = 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
Beispiel #3
0
    def __init__(self, taskInfo):
        self.taskInfo = 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 command and working folder:
        command = taskInfo['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
        taskInfo['wdir'] = self.pm.toClient(taskInfo['wdir'])
        for i in range(0, len(self.taskInfo['files'])):
            self.taskInfo['files'][i] = self.pm.toClient(
                self.taskInfo['files'][i])
        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
        cmd = taskInfo['parser']
        if len(taskInfo['parser']):
            try:
                mod = __import__('parsers', globals(), locals(),
                                 [taskInfo['parser']])
                reload(mod)
                cmd = 'mod.%s.%s()' % (taskInfo['parser'], taskInfo['parser'])
                self.parser = eval(cmd)
                self.parser.setTaskInfo(taskInfo)
            except:
                self.parser = None
                print('ERROR: Failed to import parser "%s"' % cmd)
                traceback.print_exc(file=sys.stdout)
Beispiel #4
0
    def __init__(self, taskInfo, i_verbose):
        self.taskInfo = taskInfo
        self.verbose = i_verbose
        self.log = None

        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 command and working folder:
        command = taskInfo['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
        taskInfo['wdir'] = self.pm.toClient(taskInfo['wdir'])

        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():
            allFilesExist = True
            for i in range(0, len(self.taskInfo['files'])):
                afile = self.taskInfo['files'][i]
                afile = os.path.join(taskInfo['wdir'], afile)
                if not os.path.isfile(afile):
                    allFilesExist = False
                    break
                # Check files size:
                file_size_min = self.taskInfo['file_size_min']
                file_size_max = self.taskInfo['file_size_max']
                if file_size_min > 0 or file_size_max > 0:
                    size = os.path.getsize(afile)
                    if file_size_min > 0 and size < file_size_min:
                        allFilesExist = False
                        break
                    if file_size_max > 0 and size > file_size_max:
                        allFilesExist = False
                        break

            if allFilesExist:
                self.log = 'Task file(s) exits.'
                self.taskInfo['command'] = ''

        # 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:
            print(taskInfo)
Beispiel #5
0
# -*- coding: utf-8 -*-

import json
import os
import re
import sys
import time

import cgruconfig
import cgrupathmap

import afcommon
import afnetwork
import services

Pathmap = cgrupathmap.PathMap()


def checkRegExp(pattern):
    """Missing DocString

    :param pattern:
    :return:
    """
    if len(pattern) == 0:
        return False

    result = True
    try:
        re.compile(pattern)
    except re.error:
Beispiel #6
0
import os, sys
import shutil
import socket

import cgrupathmap
import cgruconfig

import nuke

PathMap = cgrupathmap.PathMap( UnixSeparators = True)

PMaps = dict()
if 'platforms' in cgruconfig.VARS:
	for platform in cgruconfig.VARS['platforms']:
		if ('OS_'+platform) in cgruconfig.VARS:
			if 'pathsmap' in cgruconfig.VARS['OS_'+platform]:
				pm = cgrupathmap.PathMap( UnixSeparators = True)
				pm.init( cgruconfig.VARS['OS_'+platform]['pathsmap'])
				if pm.initialized:
					PMaps[platform] = pm

SearchStrings = ['file ','font ', 'project_directory ']

def pmFilenameFilter( filename):
#	print('FilenameFilter before:\n'+filename)
	# Transfer scene paths to server from all patforms:
	for key in PMaps:
		filename = PMaps[key].toServer( filename)
	# Transfer scene paths from server clinet native patform:
	if PathMap.initialized:
		filename = PMaps[key].toClient( filename)
Beispiel #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)