Example #1
0
def cms_releases(arg=None):
    """
    List available CMS releases. Optional parameters either <list> or <all>
    Examples:
        cmssh> releases      # show installed CMSSW releases
        cmssh> releases list # list available CMSSW releases on given platform
        cmssh> releases all  # show all known CMS releases, including online, tests, etc.
    """
    if arg:
        print "CMSSW releases for %s platform" % platform()
        res = release_info(release=None, rfilter=arg)
        RESMGR.assign(res)
        releases = [str(r) for r in res]
        releases = list(set(releases))
        releases.sort()
        for rel in releases:
            print rel
    installed_releases()
Example #2
0
def cms_releases(arg=None):
    """
    List available CMS releases. Optional parameters either <list> or <all>
    Examples:
        cmssh> releases      # show installed CMSSW releases
        cmssh> releases list # list available CMSSW releases on given platform
        cmssh> releases all  # show all known CMS releases, including online, tests, etc.
    """
    if  arg:
        print "CMSSW releases for %s platform" % platform()
        res = release_info(release=None, rfilter=arg)
        RESMGR.assign(res)
        releases = [str(r) for r in res]
        releases = list(set(releases))
        releases.sort()
        for rel in releases:
            print rel
    installed_releases()
Example #3
0
def cms_ls(arg):
    """
    cmssh ls command lists local files/dirs/CMS storate elements or
    CMS entities (se, site, dataset, block, run, release, file).
    Examples:
        cmssh> ls # UNIX command
        cmssh> ls -l local_file
        cmssh> ls T3_US_Cornell:/store/user/valya
        cmssh> ls run=160915
    """
    arg = arg.strip()
    res = []
    try:
        debug = get_ipython().debug
    except:
        debug = 0
    orig_arg = arg
    if orig_arg.find('|') != -1:
        arg, flt = orig_arg.split('|', 1)
        arg = arg.strip()
    else:
        flt = None
    startswith = None
    entities = \
        ['se', 'site', 'lfn', 'dataset', 'block', 'run', 'release', 'file']
    for item in entities:
        if arg.startswith(item + '='):
            startswith = item
    if os.path.isfile(orig_arg) or os.path.isdir(orig_arg):
        cmd = 'ls ' + orig_arg
        run(cmd, shell=True)
    elif pat_se.match(arg):
        arg = arg.replace('site=', '')
        res = list_se(arg, debug)
    elif pat_site.match(arg):
        arg = arg.replace('site=', '')
        res = site_info(arg, debug)
    elif pat_lfn.match(arg):
        arg = arg.replace('file=', '')
        arg = arg.replace('lfn=', '')
        res = file_info(arg, debug)
    elif pat_block.match(arg):
        arg = arg.replace('block=', '')
        res = block_info(arg, debug)
    elif pat_dataset.match(arg):
        arg = arg.replace('dataset=', '')
        try:
            res = dataset_info(arg, debug)
        except IndexError:
            msg = "Given pattern '%s' does not exist on local filesystem or in DBS" % arg
            print_error(msg)
    elif pat_run.match(arg):
        arg = arg.replace('run=', '')
        res = run_info(arg, debug)
    elif pat_release.match(arg):
        arg = arg.replace('release=', '')
        res = release_info(arg, debug)
    elif startswith:
        msg = 'No pattern is allowed for %s look-up' % startswith
        print_error(msg)
    else:
        cmd = 'ls ' + orig_arg
        run(cmd, shell=True)
    if res:
        RESMGR.assign(res)
        list_results(res, debug=True, flt=flt)
Example #4
0
def cms_ls(arg):
    """
    cmssh ls command lists local files/dirs/CMS storate elements or
    CMS entities (se, site, dataset, block, run, release, file).
    Examples:
        cmssh> ls # UNIX command
        cmssh> ls -l local_file
        cmssh> ls T3_US_Cornell:/store/user/valya
        cmssh> ls run=160915
    """
    arg = arg.strip()
    res = []
    try:
        debug = get_ipython().debug
    except:
        debug = 0
    orig_arg = arg
    if  orig_arg.find('|') != -1:
        arg, flt = orig_arg.split('|', 1)
        arg = arg.strip()
    else:
        flt = None
    startswith = None
    entities = \
        ['se', 'site', 'lfn', 'dataset', 'block', 'run', 'release', 'file']
    for item in entities:
        if  arg.startswith(item + '='):
            startswith = item
    if  os.path.isfile(orig_arg) or os.path.isdir(orig_arg):
        cmd = 'ls ' + orig_arg
        run(cmd, shell=True)
    elif pat_se.match(arg):
        arg = arg.replace('site=', '')
        res = list_se(arg, debug)
    elif  pat_site.match(arg):
        arg = arg.replace('site=', '')
        res = site_info(arg, debug)
    elif pat_lfn.match(arg):
        arg = arg.replace('file=', '')
        arg = arg.replace('lfn=', '')
        res = file_info(arg, debug)
    elif pat_block.match(arg):
        arg = arg.replace('block=', '')
        res = block_info(arg, debug)
    elif pat_dataset.match(arg):
        arg = arg.replace('dataset=', '')
        try:
            res = dataset_info(arg, debug)
        except IndexError:
            msg = "Given pattern '%s' does not exist on local filesystem or in DBS" % arg
            print_error(msg)
    elif pat_run.match(arg):
        arg = arg.replace('run=', '')
        res = run_info(arg, debug)
    elif pat_release.match(arg):
        arg = arg.replace('release=', '')
        res = release_info(arg, debug)
    elif startswith:
        msg = 'No pattern is allowed for %s look-up' % startswith
        print_error(msg)
    else:
        cmd = 'ls ' + orig_arg
        run(cmd, shell=True)
    if  res:
        RESMGR.assign(res)
        list_results(res, debug=True, flt=flt)