<commit_before>#!/usr/bin/env python
import requests
import json
import sys
import argparse

parser = argparse.ArgumentParser('Queries Monorail to get the services and deployNotes where a list of Pull requests will be deployed')
parser.add_argument('--monorail', help='URL where Monorail is located')
parser.add_argument('--pullrequests', help='Comma or space separated list of pull requests we will ask for')
args = parser.parse_args()

curl_uri = '/deploy-info?pr='

if (args.monorail):
    if args.monorail.startswith('http'):
        request_url = args.monorail+curl_uri
    else:
        request_url = 'http://'+args.monorail+curl_uri
else:
    print 'We need an URL'
    exit(1)

if (args.pullrequests):
    pull_requests = args.pullrequests.split()
    pull_requests = ",".join(pull_requests)
else:
    print 'A list of PRs is needed'
    exit(1)

try:
    r = requests.get(request_url+pull_requests)
except:
    print 'Something went wrong querying Monorail'
    exit(2)

data = r.json()
deployNotes = data['deployNotes']
services = data['services']

if deployNotes == True:
    print 'There are deployNotes so we cannot continue'
    exit(3)

if len(services) == 0:
    print 'There are not services defined so we cannot continue'<commit_msg>Add support to print services to be deployed<commit_after>#!/usr/bin/env python
import requests
import json
import sys
import argparse

parser = argparse.ArgumentParser('Queries Monorail to get the services and deployNotes where a list of Pull requests will be deployed')
parser.add_argument('--monorail', help='URL where Monorail is located')
parser.add_argument('--pullrequests', help='Comma or space separated list of pull requests we will ask for')
parser.add_argument('--showServices', help='Prints the services related to the pullrequests', action='store_true')
args = parser.parse_args()

curl_uri = '/deploy-info?pr='

if (args.monorail):
    if args.monorail.startswith('http'):
        request_url = args.monorail+curl_uri
    else:
        request_url = 'http://'+args.monorail+curl_uri
else:
    print 'We need an URL'
    exit(1)

if (args.pullrequests):
    pull_requests = args.pullrequests.split()
    pull_requests = ",".join(pull_requests)
else:
    print 'A list of PRs is needed'
    exit(1)

try:
    r = requests.get(request_url+pull_requests)
except:
    print 'Something went wrong querying Monorail'
    exit(2)

data = r.json()
deployNotes = data['deployNotes']
services = data['services']

if (args.showServices):
    for batch_same_node_version in services:
        services_list = set()
        for service in batch_same_node_version['deploy']:
            services_list.add(service)
        print "Node version: %s" % batch_same_node_version['nodeVersion']
        print "Services: %s" % ', '.join(services_list)

if deployNotes == True:
    print 'There are deployNotes so we cannot continue'
    exit(3)

if len(services) == 0:
    print 'There are not services defined so we cannot continue'
{'fraction_non_alphanumeric': 0.10857142857142857, 'fraction_numerical': 0.0033613445378151263, 'mean_word_length': 4.11340206185567, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7467586', 'n_tokens_mistral': 934, 'n_tokens_neox': 906, 'n_words': 289}