def releases(rel_name=None, rfilter=None): "Return information about CMS releases" if rel_name: if not pat_release.match(rel_name): msg = 'Wrong CMSSW release name' raise ValueError(msg) args = {'release_name': rel_name} else: args = {} url = tc_url('getReleasesInformation') rel_info = get_data(url, args) columns = rel_info['columns'] pat = re.compile('CMSSW_[1-9]_[0-9]_X\.*') for key, val in rel_info['data'].iteritems(): if rfilter == 'list': if pat.match(key) or not key.find('CMSSW') != -1 or \ key.find('EXPERIMENTAL') != -1 or \ key.find('CLANG') != -1 or \ key.find('_X_') != -1 or \ key.find('FORTIFIED') != -1: continue row = {} pairs = zip(columns['release_name'], val) for kkk, vvv in pairs: if isinstance(kkk, basestring): row[kkk] = vvv elif isinstance(kkk, list): for item in vvv: row.setdefault('architectures', []).append(dict(zip(kkk, item))) row['release_name'] = key for item in row['architectures']: if match_platform(item['architecture_name']): yield row
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)