<commit_before>#!/bin/env python
#
# Description:
#   This tool displays the status of the glideinWMS pool
#   in a text format
#
# Arguments:
#   [-pool collector_node] Entries|Sites|Gatekeepers
#
# Author:
#   <NAME> (May 9th 2007)
#

import string
import os.path
import sys
sys.path.append(os.path.join(sys.path[0],"../factory"))
sys.path.append(os.path.join(sys.path[0],"../frontend"))
sys.path.append(os.path.join(sys.path[0],"../lib"))

#import glideFactoryInterface
import glideinFrontendInterface

pool_name=None
remove_condor_stats=True
remove_internals=True
txt_type='Entries'

# parse arguments
alen=len(sys.argv)
i=1
while (i<alen):
    ael=sys.argv[i]
    if ael=='-pool':
        i=i+1
        pool_name=sys.argv[i]
    elif ael in ('Entries','Sites','Gatekeepers'):
        txt_type=ael
    elif ael=='-help':
        print "Usage:"
        print "wmsTxtView.py [-pool <node>[:<port>]] [Entries|Sites|Gatekeepers] [-help]"
        sys.exit(1)
    else:
        raise RuntimeError,"Unknown option '%s', try -help"%ael
    i=i+1

# get data
glideins_obj=glideinFrontendInterface.findGlideins(pool_name,None,None,None,get_only_matching=False)

# Get a dictionary of
#  RequestedIdle
#  Idle
#  Running
txt_data={}

# extract data
glideins=glideins_obj.keys()
for glidein in glideins:
    glidein_el=glideins_obj[glidein]

    if txt_type=='Entries':
        key=glidein
    elif txt_type=='Sites':
        key=glidein_el['attrs']['GLIDEIN_Site']
    elif txt_type=='Gatekeepers':
        key=glidein_el['attrs']['GLIDEIN_Gatekeeper']
    else:
        raise RuntimeError, "Unknwon type '%s'"%txt_type
    <commit_msg>Add -factory option - merge from v2plus<commit_after>#!/bin/env python
#
# Description:
#   This tool displays the status of the glideinWMS pool
#   in a text format
#
# Arguments:
#   [-pool collector_node] Entries|Sites|Gatekeepers
#
# Author:
#   <NAME> (May 9th 2007)
#

import string
import os.path
import sys
sys.path.append(os.path.join(sys.path[0],"../factory"))
sys.path.append(os.path.join(sys.path[0],"../frontend"))
sys.path.append(os.path.join(sys.path[0],"../lib"))

#import glideFactoryInterface
import glideinFrontendInterface

pool_name=None
factory_name=None
remove_condor_stats=True
remove_internals=True
txt_type='Entries'

# parse arguments
alen=len(sys.argv)
i=1
while (i<alen):
    ael=sys.argv[i]
    if ael=='-pool':
        i=i+1
        pool_name=sys.argv[i]
    elif ael=='-factory':
        i=i+1
        factory_name=sys.argv[i]
    elif ael in ('Entries','Sites','Gatekeepers'):
        txt_type=ael
    elif ael=='-help':
        print "Usage:"
        print "wmsTxtView.py [-pool <node>[:<port>]] [-factory <factory>] [Entries|Sites|Gatekeepers] [-help]"
        sys.exit(1)
    else:
        raise RuntimeError,"Unknown option '%s', try -help"%ael
    i=i+1

# get data
factory_constraints=None
if factory_name!=None:
    farr=factory_name.split('@')
    if len(farr)==1:
        # just the generic factory name
        factory_constraints='FactoryName=?="%s"'%factory_name
    elif len(farr)==2:
        factory_constraints='(FactoryName=?="%s")&&(GlideinName=?="%s")'%(farr[1],farr[0])
    elif len(farr)==3:
        factory_constraints='(FactoryName=?="%s")&&(GlideinName=?="%s")&&(EntryName=?="%s")'%(farr[2],farr[1],farr[0])
    else:
        raise RuntimeError, "Invalid factory name; more than 2 @'s found"

glideins_obj=glideinFrontendInterface.findGlideins(pool_name,None,None,factory_constraints,get_only_matching=False)

# Get a dictionary of
#  RequestedIdle
#  Idle
#  Running
txt_data={}

# extract data
glideins=glideins_obj.keys()
for glidein in glideins:
    glidein_el=glideins_obj[glidein]

    if txt_type=='Entries':
        key=glidein
    elif txt_type=='Sites':
        key=glidein_el['attrs']['GLIDEIN_Site']
    elif txt_type=='Gatekeepers':
        key=glidein_el['attrs']['GLIDEIN_Gatekeeper']
    else:
        raise RuntimeError, "Unknwon type '%s'"%txt_type
    
{'fraction_non_alphanumeric': 0.15495449949443882, 'fraction_numerical': 0.00884732052578362, 'mean_word_length': 4.079589216944801, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2182941', 'n_tokens_mistral': 1499, 'n_tokens_neox': 1454, 'n_words': 263}