Пример #1
0
    def configure(self, config, steps=()):
        if not(type(config) == type({})):
            raise TypeError("Expected dictionary as 'config' argument")

        #        if not(type(steps) == type(())):
        #            raise TypeError("Expected tuple as 'steps' argument")

        id = config['id']
        port = config['port']
        self.jobdirectory = config['jobdirectory']
        if config.has_key('debug') and config['debug']:
            logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)
        else:
            logging.basicConfig(level=logging.INFO, stream=sys.stdout)
        ensuredir(self.jobdirectory)

        self.id = id
        self.steps = steps
        self.log = []
        self.currentstep = None
        self.currentstepnumber = 0
        self.started = 0
        self.state = []
        self.filesubsystem = filesubsystem(config["storageconfig"])
        self.shuttingdown = False

        # only when everything else's fine
        self.controller = controller(port, self)
Пример #2
0
    def nativecommandargs(self, context):
        path = self._nativecommand.path()

        if self.toitem['storageid'] is not None:
            logging.warn("Storage ID of target item must be None, ignored anyway")

        toitempath = context['tempdirectory'] + "/" + self.toitem['itempath']
        ensuredir(os.path.split(toitempath)[0])
        fromitempath = self._fromitempath(context)

        args = self.transformation['args']
        args = string.replace(args, "${fromitem}", fromitempath)
        args = string.replace(args, "${toitem}", toitempath)
        
        logging.info("Source item: " + fromitempath + "; target item " + toitempath)
        return path + " " + args
Пример #3
0
    def load(self, storageid, itempath):

        # assuming that checking cache is very cheap operation, do it first
        if self.cache.contains(storageid, itempath):
            return self.cache.pathto(storageid, itempath)

        storage = self.storagemanager.storage(storageid)

        if storage.islocal():

            if storage.contains(itempath):
                return {"state": "OK"}
            else:
                raise LookupError("Item %s not found in storage %s " % (itempath, storageid))

        else:

            if storage.contains(itempath):
                cachepath = self.cache.pathto(storageid, itempath)
                ensuredir(os.path.split(cachepath)[0])
                storage.loaditem(itempath, cachepath)
                return {"state": "OK", "out": "Item %s loaded from %s to %s" % (itempath, storageid, cachepath)}

            raise LookupError("Item %s not found in storage %s " % (itempath, storageid))
Пример #4
0
 def __init__(self, dir):
     ensuredir(dir)
     self.directory = dir
     pass