Example #1
0
def loadCache(mydir, logger):
    requestarea, dummyRequestname = getWorkArea(mydir)
    cachename = os.path.join(requestarea, '.requestcache')
    #Check if the directory exists.
    if not os.path.isdir(requestarea):
        msg = "%s is not a valid CRAB project directory." % (requestarea)
        raise TaskNotFoundException(msg)
    #If the .requestcache file exists open it!
    if os.path.isfile(cachename):
        loadfile = open(cachename, 'r')
    else:
        msg = "Cannot find .requestcache file in CRAB project directory %s" % (requestarea)
        raise CachefileNotFoundException(msg)
    logfile = changeFileLogger(logger, workingpath = requestarea)
    return cPickle.load(loadfile), logfile
Example #2
0
def loadCache(task, logger):
    requestarea, requestname = getWorkArea(task)
    cachename = os.path.join(requestarea, '.requestcache')
    taskName = task.split('/')[
        -1]  #Contains only the taskname without the path
    #Check if the task directory exists
    if not os.path.isdir(requestarea):
        msg = 'Working directory for task %s not found ' % taskName
        raise TaskNotFoundException(msg)
    #If the .requestcache file exists open it!
    if os.path.isfile(cachename):
        loadfile = open(cachename, 'r')
    else:
        msg = 'Cannot find .requestcache file inside the working directory for task %s' % taskName
        raise CachefileNotFoundException(msg)

    logfile = changeFileLogger(logger, workingpath=requestarea)
    return cPickle.load(loadfile), logfile
Example #3
0
def loadCache(mydir, logger):
    requestarea, dummyRequestname = getWorkArea(mydir)
    cachename = os.path.join(requestarea, '.requestcache')
    #Check if the directory exists.
    if not os.path.isdir(requestarea):
        msg = "%s is not a valid CRAB project directory." % (requestarea)
        raise TaskNotFoundException(msg)
    #If the .requestcache file exists open it!
    if os.path.isfile(cachename):
        loadfile = open(cachename, PKL_R_MODE)
    else:
        msg = "Cannot find .requestcache file in CRAB project directory %s" % (
            requestarea)
        raise CachefileNotFoundException(msg)
    #TODO should catch ValueError: unsupported pickle protocol: 4 in following line and flag it
    # as using python3 environment on a task created in python2 env.
    logfile = changeFileLogger(logger, workingpath=requestarea)
    return pickle.load(loadfile), logfile