Ejemplo n.º 1
0
def report():
    style = "pretty"
    parser = argparse.ArgumentParser()
    parser.add_argument("report")
    group = parser.add_mutually_exclusive_group()
    group.add_argument("--json", action="store_true")
    group.add_argument("--raw", action="store_true")
    parser.add_argument("--products")
    parser.add_argument("--productIDs")
    parser.add_argument("gav")
    args = parser.parse_args()
    if (not matchGAV(args.gav)):
        exit()
    groupId, artifactId, version = args.gav.split(":",3)
    if args.raw:
        style = "raw"
    if args.json:
        style = "json"

    products = ""
    if (args.products != None):
        products = args.products
        products = products.replace(",","\",\"")
        products = "\""+products+"\""
        products = "[" + products + "]"
    else:
        products = "[]"
        
    query = "{\"jsonrpc\": \"2.0\",  \"method\":\"reports.gav\", \"id\": \"request_0\" ,  \"params\":"   
    query += "{"
    query += formatGAVjsonRequest(groupId, artifactId, version)
        
    query += ",\"productNames\":" + products 

    if (args.productIDs != None):
        productIDs = "[" + args.productIDs + "]"
    else:
        productIDs = "[]"
    query += ",\"productVersionIds\":" + productIDs 
 
    query += "}"
    query += "}"
    
    output = asyncio.get_event_loop().run_until_complete(get_response(query))

    if style == "pretty":
        if "errorType" in output:
            print(output['errorMessage'])
            exit()
        pretty_out = pretty.report(output)
        print(pretty_out)
    elif style == "raw":
        print(pretty.reportRaw(output))
    else:
        print(json.dumps(output))
Ejemplo n.º 2
0
def report():
    style = "pretty"
    parser = argparse.ArgumentParser()
    parser.add_argument("report")
    group = parser.add_mutually_exclusive_group()
    group.add_argument("--json", action="store_true")
    group.add_argument("--raw", action="store_true")
    parser.add_argument("--products")
    parser.add_argument("--productIDs")
    parser.add_argument("gav")
    args = parser.parse_args()
    if (not matchGAV(args.gav)):
        exit()
    groupId, artifactId, version = args.gav.split(":", 3)
    if args.raw:
        style = "raw"
    if args.json:
        style = "json"

    products = ""
    if (args.products != None):
        products = args.products
        products = products.replace(",", "\",\"")
        products = "\"" + products + "\""
        products = "[" + products + "]"
    else:
        products = "[]"

    query = "{\"jsonrpc\": \"2.0\",  \"method\":\"reports.gav\", \"id\": \"request_0\" ,  \"params\":"
    query += "{"
    query += formatGAVjsonRequest(groupId, artifactId, version)

    query += ",\"productNames\":" + products

    if (args.productIDs != None):
        productIDs = "[" + args.productIDs + "]"
    else:
        productIDs = "[]"
    query += ",\"productVersionIds\":" + productIDs

    query += "}"
    query += "}"

    output = asyncio.get_event_loop().run_until_complete(get_response(query))

    if style == "pretty":
        if "errorType" in output:
            print(output['errorMessage'])
            exit()
        pretty_out = pretty.report(output)
        print(pretty_out)
    elif style == "raw":
        print(pretty.reportRaw(output))
    else:
        print(json.dumps(output))
Ejemplo n.º 3
0
def scm_report():
    style = "pretty"
    parser = argparse.ArgumentParser()
    parser.add_argument("scm-report")
    group = parser.add_mutually_exclusive_group()
    group.add_argument("--json", action="store_true")
    group.add_argument("--raw", action="store_true")
    parser.add_argument("--products")
    parser.add_argument("--productIDs")
    parser.add_argument("--repository")
    parser.add_argument("scm")
    parser.add_argument("tag")
    parser.add_argument("pom_path",metavar="pom-path")
    args = parser.parse_args()

    if args.raw:
        style = "raw"
    if args.json:
        style = "json"

    products = ""
    repositories = ""
    if (args.products != None):
        products = args.products
        products = products.replace(",","\",\"")
        products = "\""+products+"\""
        products = "[" + products + "]"
    else:
        products = "[]"
        
    if (args.repository != None):
        repositories = args.repository
        repositories = repositories.replace(",","\",\"")
        repositories = "\""+repositories+"\""
        repositories = "[" + repositories + "]"
    else:
        repositories = "[]"
        
    
    query = "{\"jsonrpc\": \"2.0\",  \"method\":\"reports.scm\", \"id\": \"request_0\" ,  \"params\":"   
    query += "{"
    query += "\"productNames\":" + products 

    if (args.productIDs != None):
        productIDs = "[" + args.productIDs + "]"
    else:
        productIDs = "[]"
    query += ",\"productVersionIds\":" + productIDs 
    
    query += ", \"scml\" : {" + "\"scmUrl\" :\"" +args.scm + "\",\"revision\":\"" + args.tag + "\",\"pomPath\": \"" + args.pom_path + "\",\"repositories\": " + repositories + "}" 
    query += "}"
    query += "}"
    
    output = asyncio.get_event_loop().run_until_complete(get_response(query))

    if style == "pretty":
        if "errorType" in output:
            print(output['errorMessage'])
            exit()
        pretty_out = pretty.report(output)
        print(pretty_out)
    elif style == "raw":
        print(pretty.reportRaw(output))
    else:
        print(json.dumps(output))
Ejemplo n.º 4
0
def scm_report():
    style = "pretty"
    parser = argparse.ArgumentParser()
    parser.add_argument("scm-report")
    group = parser.add_mutually_exclusive_group()
    group.add_argument("--json", action="store_true")
    group.add_argument("--raw", action="store_true")
    parser.add_argument("--products")
    parser.add_argument("--productIDs")
    parser.add_argument("--repository")
    parser.add_argument("scm")
    parser.add_argument("tag")
    parser.add_argument("pom_path", metavar="pom-path")
    args = parser.parse_args()

    if args.raw:
        style = "raw"
    if args.json:
        style = "json"

    products = ""
    repositories = ""
    if (args.products != None):
        products = args.products
        products = products.replace(",", "\",\"")
        products = "\"" + products + "\""
        products = "[" + products + "]"
    else:
        products = "[]"

    if (args.repository != None):
        repositories = args.repository
        repositories = repositories.replace(",", "\",\"")
        repositories = "\"" + repositories + "\""
        repositories = "[" + repositories + "]"
    else:
        repositories = "[]"

    query = "{\"jsonrpc\": \"2.0\",  \"method\":\"reports.scm\", \"id\": \"request_0\" ,  \"params\":"
    query += "{"
    query += "\"productNames\":" + products

    if (args.productIDs != None):
        productIDs = "[" + args.productIDs + "]"
    else:
        productIDs = "[]"
    query += ",\"productVersionIds\":" + productIDs

    query += ", \"scml\" : {" + "\"scmUrl\" :\"" + args.scm + "\",\"revision\":\"" + args.tag + "\",\"pomPath\": \"" + args.pom_path + "\",\"repositories\": " + repositories + "}"
    query += "}"
    query += "}"

    output = asyncio.get_event_loop().run_until_complete(get_response(query))

    if style == "pretty":
        if "errorType" in output:
            print(output['errorMessage'])
            exit()
        pretty_out = pretty.report(output)
        print(pretty_out)
    elif style == "raw":
        print(pretty.reportRaw(output))
    else:
        print(json.dumps(output))