<commit_before>#!/usr/bin/python
import requests
import json
import time
import os
import utilLCM as lcm

def runningJob(jobs):
    running = False
    for r in jobs['results']:
      if r['status'] == 'RUNNING' or r['status'] == 'PENDING':
          running = True
    return running

def main():
    lcm.opsc_url = 'localhost:8888'
    lcm.waitForOpsC(pause=6, trys=200)  # Block waiting for OpsC to spin up
    pause = 60
    trys = 100
    count = 0

    while (True):
        count += 1
        if(count>trys):
            print "Timeout, exiting"
            exit()
        jobs = requests.get("http://{url}/api/v1/lcm/jobs/".format(url=lcm.opsc_url)).json()
        if(jobs['count']==0):
            print "No jobs found on try {c}, sleeping {p} sec...".format(c=count,p=pause)
            time.sleep(pause)
            continue
        if(runningJob(jobs)):
            print "Job running/pending on try {c}, sleeping {p} sec...".format(c=count,p=pause)
            time.sleep(pause)
        else:
            print "No jobs running/pending on try {c}, exiting".format(c=count)
            break



# ----------------------------
if __name__ == "__main__":
    main()
<commit_msg>add args, ability to wait for num jobs<commit_after>#!/usr/bin/python
import requests
import json
import time
import os
import utilLCM as lcm
import argparse

def setupArgs():
    parser = argparse.ArgumentParser(description='Add calling instance to an LCM managed DSE cluster.')
    parser = argparse.ArgumentParser(description='Add calling instance to an LCM managed DSE cluster.')
    parser.add_argument('--num', type=int, default=1, help='Expected number of jobs')
    parser.add_argument('--opsc-ip', type=str, default='localhost',
                          help='IP/hostname of OpsCenter instance, default localhost. REST calls made to this host:8888')
    return parser

def runningJob(jobs):
    running = False
    for r in jobs['results']:
      if r['status'] == 'RUNNING' or r['status'] == 'PENDING':
          running = True
    return running

def main():
    parser = setupArgs()
    args = parser.parse_args()
    lcm.opsc_url = args.opsc_ip + ':8888'
    lcm.waitForOpsC(pause=6, trys=200)  # Block waiting for OpsC to spin up
    pause = 60
    trys = 100
    count = 0

    while (True):
        count += 1
        if(count>trys):
            print "Timeout, exiting"
            exit()
        jobs = requests.get("http://{url}/api/v1/lcm/jobs/".format(url=lcm.opsc_url)).json()
        if(jobs['count']==0):
            print "No jobs found on try {c}, sleeping {p} sec...".format(c=count,p=pause)
            time.sleep(pause)
            continue
        if(runningJob(jobs)):
            print "Jobs running/pending on try {c}, sleeping {p} sec...".format(c=count,p=pause)
            time.sleep(pause)
            continue
        if((not runningJob(jobs)) and (jobs['count'] < args.num)):
            print "Jobs found on try {c} but num {j} < {n}, sleeping {p} sec...".format(c=count,j=jobs['count'],n=args.num,p=pause)
            time.sleep(pause)
            continue
        if((not runningJob(jobs)) and (jobs['count'] >= args.num)):
            print "No jobs running/pending and num >= {n} on try {c}, exiting".format(n=args.num,c=count)
            break



# ----------------------------
if __name__ == "__main__":
    main()

{'fraction_non_alphanumeric': 0.15458072217248583, 'fraction_numerical': 0.011638316920322292, 'mean_word_length': 2.315529179030663, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 7, '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': '1642286', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1035, 'n_words': 286}