Separate SSH login name from list of change users

Don't overload the '-u' option to refer to both the gerrit
login name and the list of users whose changes to query.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Rewrite query engine to be extendable

Don't hardcode requirement for at least one user, or list of
status codes. By default query all open changes, and allow
this to be optionally filtered by user.

To achieve this, rewrite the query engine to allow an arbitrary
set of terms to be passed in.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Rewrite output printer to be more configurable

Instead of hardcoding the fields to be output, create a data
table listing desired fields. This makes the 'print_results'
method be metadata driven.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Make list of fields and sort ordering configurable

Allow use of '-f fieldname' to control fields displayed in
output table. Also allow a ':NN' suffix to override truncation
length.

Sort ordering is controlled by a '-t fieldname' arg, and is
done based on original data, not formatted data, to fix sorting
of dates.

eg

$ qgerrit -t url -f status -f url -f subject:100
+----------------+------------------------------------+---------------------------------------------------------------------------------------------------------+
|     Status     |                URL                 |                                                 Subject                                                 |
+----------------+------------------------------------+---------------------------------------------------------------------------------------------------------+
|      NEW       | https://review.openstack.org/27160 |                            Normalize the weights instead of using raw values                            |
|      NEW       | https://review.openstack.org/30755 |                                      The use of the class variables                                     |
|      NEW       | https://review.openstack.org/33409 |                                  Adding image multiple location support                                 |
|      NEW       | https://review.openstack.org/33831 |                            Automatic retry db.api query if db connection lost                           |
|      NEW       | https://review.openstack.org/35303 |                     Stop, Rescue, and Delete should give guest a chance to shutdown                     |
....

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Left align table output

Centering output is not very readable, particularly for the
subject string.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Add ability to specify status to filter on

Add support for '-s STATUS' eg '-s abandoned' to override
default of 'open'.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Add support for filtering on commit message string

Add '-m SUBSTRING' arg to filter based on substring in the
commit message

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Add support for filtering based on the project name

Add support for '-p PROJECT' to filter on the project
name.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Add support for filtering based on approvals

Add '-a APPROVAL' option to filter based on approvals

"-a v1" requires verification >= 1 for all
verification approvals.

"-a c2" requires code review >= 2 for all
verification approvals.

Also display approvals in the output data

eg

$ qgerrit -t url -f status -f url -f subject:100 -f approvals -s abandoned -a c2
+-----------+------------------------------------+-----------------------------------------------------------------------------+----------------+
| Status    | URL                                | Subject                                                                     | Approvals      |
+-----------+------------------------------------+-----------------------------------------------------------------------------+----------------+
| ABANDONED | https://review.openstack.org/48747 | Added horizon_listen_ssl parameter to controller                            | v=-2 c=2,2 a=1 |
| ABANDONED | https://review.openstack.org/50762 | Bump wait_for overcloud to configure br-ctlplane to 20 minutes              | v=1 c=2        |
| ABANDONED | https://review.openstack.org/51093 | version bumps of cookbook dependencies                                      | v=-2 c=2 a=1   |

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Add support for filtering based on filename match

Use positional args as a regex filter match against the
filenames being changed. eg to watch all libvirt changes

 $ qgerrit -t url -f status -f url -f subject:100 libvirt
+----------------+------------------------------------+-----------------------------------------------------------------------+
| Status         | URL                                | Subject                                                               |
+----------------+------------------------------------+-----------------------------------------------------------------------+
| NEW            | https://review.openstack.org/33409 | Adding image multiple location support                                |
| NEW            | https://review.openstack.org/35303 | Stop, Rescue, and Delete should give guest a chance to shutdown       |
| NEW            | https://review.openstack.org/35760 | Added monitor (e.g. CPU) to monitor and collect data                  |
| NEW            | https://review.openstack.org/38872 | Allow _sync_power_states periodic task to hit slave DB                |
| WORKINPROGRESS | https://review.openstack.org/39929 | Port to oslo.messaging                                                |

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Make date format display more friendly

Instead of displaying an absolute date / time string, use
'10 days', or '4 hours', or '2 minutes' or 'just now' to
make it clear how old reviews arg

$ qgerrit libvirt
+----------------+-------------------------+------------------------------------+----------------+-------------------------------------------------------+----------+----------+---------------+
| Status         | Topic                   | URL                                | Project        | Subject                                               | Created  | Updated  | Approvals     |
+----------------+-------------------------+------------------------------------+----------------+-------------------------------------------------------+----------+----------+---------------+
| NEW            |                         | https://review.openstack.org/33409 | openstack/nova | Adding image multiple location support                | 127 days | 16 hours | v=1 c=-1,1    |
| NEW            | bp/user-defined-shut... | https://review.openstack.org/35303 | openstack/nova | Stop, Rescue, and Delete should give guest a chanc... | 112 days | 1 hour   | v=1,1 c=-1    |
| NEW            | bp/utilization-aware... | https://review.openstack.org/35760 | openstack/nova | Added monitor (e.g. CPU) to monitor and collect da... | 110 days | 18 hours | v=1,1 c=-1,-1 |
| NEW            | bp/periodic-tasks-to... | https://review.openstack.org/38872 | openstack/nova | Allow _sync_power_states periodic task to hit slav... | 88 days  | 15 hours | v=1           |
| WORKINPROGRESS | bp/oslo-messaging       | https://review.openstack.org/39929 | openstack/nova | Port to oslo.messaging                                | 82 days  | 7 hours  | v=1,1         |

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Merge pull request #2 from berrange/qgerrit-better-filtering

Qgerrit better filtering
Various style and code cleanups
Gerrit queries don't always seem to work

This fix makes it so that query operators seem
to actually work when multiple of them are specified,
probably a bug in gerrit query logic somewhere.
Push out 0.1.1
Fix the dec type 'stats' check

The existing 'rowCount' will be
triggered anyway but we should
use the right string anyway.
Add a zuul viewer
Reduce log level
Use lowercase pipeline name checking
Update with zuul requirement and doc