Exemple #1
0
# $Id: utilities.py,v 1.1 2008-07-17 16:40:56 moscicki Exp $
################################################################################

from Ganga.Utility.Plugin import PluginManagerError, allPlugins
from Ganga.GPIDev.Base.Objects import GangaObject
from Ganga.GPIDev.Schema import Schema, Version
from Ganga.GPIDev.Lib.GangaList.GangaList import stripGangaList
from Ganga.GPIDev.Lib.GangaList.GangaList import makeGangaList

import Ganga.Utility.logging

logger = Ganga.Utility.logging.getLogger()

from Ganga.Utility.external.ordereddict import oDict

allConverters = oDict()

################################################################################
# helper to create a dictionary of simpleattributes
# according to the schema from a ganga object from
def serialize(obj):
    """returns a (nested) dictionary of simple job attributes"""
    schema = obj._schema
    attrDict = {}
    attrDict["name"] = schema.name
    attrDict["category"] = schema.category
    attrDict["version"] = (schema.version.major, schema.version.minor)
    attrDict["simple"] = 0
    attrDict["data"] = {}

    def mapper(val):
Exemple #2
0
# 30 Aug 2006 - KH : Modified function getSearchPath, to expand ~ and
#                    environment variables, and to allow paths to be
#                    specified relative to Ganga top directory

# 19 Oct 2006 - KH : Modified function getScriptPath, to expand ~ and
#                    environment variables

# 19 Oct 2006 - KH : Generalised function getSearchPath, allowing
#                    configuration parameter defining search path
#                    to be passed as arument

from Ganga.Utility.util import importName

from Ganga.Utility.external.ordereddict import oDict
allRuntimes = oDict()

import Ganga.Utility.logging
logger = Ganga.Utility.logging.getLogger(modulename=1)

def getScriptPath( name = "", searchPath = "" ):
   """Determine path to a script

      Arguments:
         name       - Name of a script
         searchPath - String of colon-separated directory names,
                      defining locations to be searched for script

      If 'name' already gives the path to the script, then
      'searchPath' is ignored.
Exemple #3
0
def jobSlice(joblist):
    """create a 'JobSlice' from a list of jobs
    example: jobSlice([j for j in jobs if j.name.startswith("T1:")])"""
    slice = JobRegistrySlice("manual slice")
    slice.objects = oDict([(j.fqid, _unwrap(j)) for j in joblist])
    return _wrap(slice)