Esempio n. 1
0
def cms_jobs(arg=None):
    """
    cmssh jobs command lists local job queue or provides information
    about jobs at give site or for given user. It accepts the following
    list of options:

    - list, which lists local transfer jobs
    - site, which lists jobs at given site
    - dashboard, which lists jobs of current user
    - user, which lists jobs of given user

    Examples:
        cmssh> jobs
        cmssh> jobs list
        cmssh> jobs site=T2_US_UCSD
        cmssh> jobs dashboard
        cmssh> jobs user=my_cms_user_name
    """
    res = None
    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
    if arg:
        arg = arg.strip()
    if not arg or arg == 'list':
        print_info('Local data transfer')
        dqueue(arg)
    elif arg == 'dashboard':
        userdn = os.environ.get('USER_DN', None)
        if userdn:
            user = get_dashboardname(userdn)
            print_info('Dashboard information, user=%s' % user)
            res = jobsummary({'user': user})
    elif pat_site.match(arg):
        site = arg.replace('site=', '')
        print_info('Dashboard information, site=%s' % site)
        res = jobsummary({'site': site})
    elif pat_user.match(arg):
        user = arg.replace('user='******'')
        print_info('Dashboard information, user=%s' % user)
        res = jobsummary({'user': user})
    if res:
        RESMGR.assign(res)
        list_results(res, debug=True, flt=flt)
Esempio n. 2
0
def cms_jobs(arg=None):
    """
    cmssh jobs command lists local job queue or provides information
    about jobs at give site or for given user. It accepts the following
    list of options:

    - list, which lists local transfer jobs
    - site, which lists jobs at given site
    - dashboard, which lists jobs of current user
    - user, which lists jobs of given user

    Examples:
        cmssh> jobs
        cmssh> jobs list
        cmssh> jobs site=T2_US_UCSD
        cmssh> jobs dashboard
        cmssh> jobs user=my_cms_user_name
    """
    res = None
    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
    if  arg:
        arg = arg.strip()
    if  not arg or arg == 'list':
        print_info('Local data transfer')
        dqueue(arg)
    elif arg == 'dashboard':
        userdn = os.environ.get('USER_DN', None)
        if  userdn:
            user = get_dashboardname(userdn)
            print_info('Dashboard information, user=%s' % user)
            res  = jobsummary({'user': user})
    elif  pat_site.match(arg):
        site = arg.replace('site=', '')
        print_info('Dashboard information, site=%s' % site)
        res  = jobsummary({'site': site})
    elif  pat_user.match(arg):
        user = arg.replace('user='******'')
        print_info('Dashboard information, user=%s' % user)
        res  = jobsummary({'user': user})
    if  res:
        RESMGR.assign(res)
        list_results(res, debug=True, flt=flt)
Esempio n. 3
0
def lookup(arg):
    """
    Perform lookup of given query in CMS data-services.
    """
    arg = arg.strip()
    debug = get_ipython().debug
    args = arg.split('|')
    if len(args) == 1:  # no filter
        res = CMSMGR.lookup(arg)
    else:
        gen = CMSMGR.lookup(args[0].strip())
        for flt in args[1:]:
            res = apply_filter(flt.strip(), gen)
    RESMGR.assign(res)
    list_results(res, debug)
Esempio n. 4
0
def lookup(arg):
    """
    Perform lookup of given query in CMS data-services.
    """
    arg = arg.strip()
    debug = get_ipython().debug
    args  = arg.split('|')
    if  len(args) == 1: # no filter
        res = CMSMGR.lookup(arg)
    else:
        gen = CMSMGR.lookup(args[0].strip())
        for flt in args[1:]:
            res = apply_filter(flt.strip(), gen)
    RESMGR.assign(res)
    list_results(res, debug)
Esempio n. 5
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)
Esempio n. 6
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)