From 77e0060f62ccd3b88d1de5b4cc90d5d06816d72d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 15 Nov 2017 17:37:30 -0500 Subject: [PATCH] enable logging in validate command Turn on logging output, to the console, and add some log statements in gitutils. Change-Id: I63c80c9b2d6674d64dbc8b341a36ad51248aa19c Signed-off-by: Doug Hellmann --- openstack_releases/cmds/validate.py | 10 ++++++++++ openstack_releases/gitutils.py | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/openstack_releases/cmds/validate.py b/openstack_releases/cmds/validate.py index 2e9f163ad4..92e9caca86 100644 --- a/openstack_releases/cmds/validate.py +++ b/openstack_releases/cmds/validate.py @@ -21,11 +21,13 @@ from __future__ import print_function import argparse import atexit import glob +import logging import os import os.path import pkgutil import re import shutil +import sys import tempfile import jsonschema @@ -945,6 +947,14 @@ def main(): ) args = parser.parse_args() + # Set up logging, including making some loggers quiet. + logging.basicConfig( + format='%(levelname)s:%(name)s: %(message)s', + stream=sys.stdout, + level=logging.DEBUG, + ) + logging.getLogger('urllib3.connectionpool').setLevel(logging.WARNING) + filenames = args.input or gitutils.find_modified_deliverable_files() if not filenames: print('no modified deliverable files and no arguments, ' diff --git a/openstack_releases/gitutils.py b/openstack_releases/gitutils.py index 31062593f0..51fb6e4af4 100644 --- a/openstack_releases/gitutils.py +++ b/openstack_releases/gitutils.py @@ -106,6 +106,7 @@ def clone_repo(workdir, repo, ref=None, branch=None): if branch: cmd.extend(['--branch', branch]) cmd.append(repo) + LOG.info(' '.join(cmd)) subprocess.check_call(cmd) @@ -190,7 +191,10 @@ def check_branch_sha(workdir, repo, series, sha): ) # If the patch is on the named branch, everything is fine. if remote_match in containing_branches: + LOG.debug('found %s branch', remote_match) return True + LOG.debug('did not find %s in branches containing %s: %s', + remote_match, sha, containing_branches) # If the expected branch does not exist yet, this may be a # late release attempt to create that branch or just a project # that hasn't branched, yet, and is releasing from master for @@ -203,10 +207,12 @@ def check_branch_sha(workdir, repo, series, sha): ).decode('utf-8') ) if (remote_match not in all_branches) and ('master' in containing_branches): + LOG.debug('did not find %s but SHA is on master', remote_match) return True # At this point we know the release is not from the required # branch and it is not from master, which means it is the # wrong branch and should not be allowed. + LOG.debug('did not find SHA on %s or master', remote_match) return False except subprocess.CalledProcessError as e: LOG.error('failed checking SHA on branch: %s [%s]' % (e, e.output.strip()))