Fix incorrect syntax in scripts/check_rabbitmq.py

* This fixes the incorrect syntax in the scripts/check_rabbitmq.py
  file.  Unfortunately, there are no tests for these files.  To
  help with QA, added the 'scripts' directory to the pep8 test to
  validate that they are correct python syntax for future changes.

* Updated .gitigore to exclude __pycache__ directories for py3 and
  removed the __pycache__ directory files from the repo.

Change-Id: I406a70c3d04eb730e1c59189a83cc57495186105
Closes-Bug: #1804126
This commit is contained in:
Alex Kavanagh 2018-11-20 08:38:51 +00:00
parent 757473784f
commit f30b4ac0c6
8 changed files with 17 additions and 6 deletions

1
.gitignore vendored
View File

@ -6,6 +6,7 @@ revision
.testrepository
*.sw[nop]
*.pyc
__pycache__/
.project
.pydevproject
.stestr

View File

@ -50,7 +50,7 @@ def get_connection(host_port, user, password, vhost, ssl, ssl_ca):
ret = amqp.Connection(**params)
except (socket.error, TypeError), e:
except (socket.error, TypeError) as e:
print("ERROR: Could not connect to RabbitMQ server {}:{}"
.format(options.host, options.port))
if options.verbose:
@ -74,7 +74,7 @@ def setup_exchange(conn, exchange_name, exchange_type):
try:
chan.exchange_declare(exchange=exchange_name, type=exchange_type,
passive=True)
except (amqp.AMQPConnectionException, amqp.AMQPChannelException), e:
except (amqp.AMQPConnectionException, amqp.AMQPChannelException) as e:
if e.amqp_reply_code == 404:
must_create = True
# amqplib kills the channel on error.... we dispose of it too

View File

@ -10,6 +10,7 @@ from itertools import chain
import argparse
import sys
def gen_data_lines(filename):
with open(filename, "rb") as fin:
for line in fin:
@ -66,11 +67,20 @@ def check_stats(stats_collated, limits):
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='RabbitMQ queue size nagios check.')
parser.add_argument('-c', nargs=4, action='append', required=True,
parser = argparse.ArgumentParser(
description='RabbitMQ queue size nagios check.')
parser.add_argument(
'-c',
nargs=4,
action='append',
required=True,
metavar=('vhost', 'queue', 'warn', 'crit'),
help=('Vhost and queue to check. Can be used multiple times'))
parser.add_argument('stats_file', nargs='*', type=str, help='file containing queue stats')
parser.add_argument(
'stats_file',
nargs='*',
type=str,
help='file containing queue stats')
args = parser.parse_args()
# Start generating stats from all files given on the command line.

View File

@ -36,7 +36,7 @@ deps = -r{toxinidir}/requirements.txt
basepython = python3
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = flake8 {posargs} hooks unit_tests tests actions lib
commands = flake8 {posargs} hooks unit_tests tests actions lib scripts
charm-proof
[testenv:venv]