#!/usr/bin/env python import sys import os import time import pwd from cache import cache # TODO: command line options processing # sys.argv[1] is now ignored and assummed to be 'get', but 'check' should be also supported if len(sys.argv) < 3: sys.exit('Usage: %s get ' % sys.argv[0]) urls = {sys.argv[2] : sys.argv[3]} if 'ARC_CACHE_SERVICE' in os.environ: endpoint = os.environ['ARC_CACHE_SERVICE'] else: sys.exit('ERROR: There in no ARC_CACHE_SERVICE defined') if 'X509_USER_PROXY' in os.environ: proxy = os.environ['X509_USER_PROXY'] else: sys.exit('ERROR: There in no X509_USER_PROXY defined') username = pwd.getpwuid(os.getuid())[0] # job id from GRID_GLOBAL_JOBID or cwd if 'GRID_GLOBAL_JOBID' in os.environ: gridid = os.environ['GRID_GLOBAL_JOBID'] # EMI-ES already provides non-URL id # for GridFTP - strip URL part jobid = gridid[gridid.rfind('/')+1:] else: cwd = os.getcwd() jobid = cwd[cwd.rfind('/')+1:] stage = True try: cacheurls = cache.cacheLink(endpoint, proxy, username, jobid, urls, stage) except cache.CacheException, e : sys.exit('Error calling cacheLink: ' + str(e))