Giter VIP home page Giter VIP logo

gerritssh's Introduction

gerritssh

https://badge.fury.io/py/gerritssh.png https://travis-ci.org/kdopen/gerritssh.png?branch=master https://coveralls.io/repos/kdopen/gerritssh/badge.png https://pypip.in/d/gerritssh/badge.png?version=latest

Python package wrapping the Gerrit command line API.

This is very much a work in progress, and intended to be the basis for building more sophisticated scripts and applications, for example automating complex work flows in large projects.

Rationale

This project was started as a test-bed for me to explore the wider world of Python, such as:

  • Unit testing
  • Continuous Integration
  • Sphinx rst documentation
  • tox, flake8, etc.
  • Supporting multiple versions of Python.
  • Pythonic style

Basically, everything that goes into making an industrial-strength Python library or application. So you are going to see novice mistakes and code which is not idiomatic.

All contributions and suggestions are welcome, and indeed that's the logic behind making this open source. I want to learn from the experience of those who've been there before me.

Features

  • Handles the low-level details of the gerrit SSH command line syntax.
  • Makes the results of those commands available to the programmer in a format which is more natural for Python programmers to manipulate.
  • Is aware of which combinations of commands and versions are supported for versions of Gerrit from 2.4 through 2.8.
  • Supports Python 2.6, 2.7, 3.3, and 3.4

Planned Features

  • Support a broad range of commands including the latest commands for Gerrit v2.8 (such as ls-members)
  • Add a module to operate on sets of Review objects to perform more complex searches, such as building dependency graphs of open reviews.
  • Add support for the administrators gsql command
    • Implement queries such as examining the audit trail on group membership
    • Wrapping generation of properly quoted SQL statements
    • Extract the SCHEMA information with a \d command and dynamically clone the database into a memory-resident sqlite database.
  • Implement support for the stream-events command, serving up events using an observer-pattern approach to allow many threads to consume events.

Feedback

If you have any suggestions or questions about gerritssh feel free to email me at [email protected].

If you encounter any errors or problems with gerritssh, please let me know! Open an Issue at the GitHub http://github.com/kdopen/gerritssh main repository.

gerritssh's People

Contributors

kdopen avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

gerritssh's Issues

gsshcli.py requires __version__ attribute

v0.1.1 moved the version string out of gerritssh/__init__.py into VERSION.py, but the example script requires it to set up the ArgumentParser object.

Hence it fails with an exception

Unit tests are not sufficient

  • This library talks via ssh to remote systems.
  • Unit tests necessarily mock out that communication so that they have few dependencies
  • But the remote systems can change independently
  • And the mocking may not represent reality, anyway

The net result is that things can break, without unit tests catching them.

That means we need some end-to-end tests as well, and these probably can't be run on travis-ci because: it won't have ssh keys for any public gerrit instances; I don't want to include a private key in the repo - even for testing; and, if they have any sense, they will limit what the tests can actually do in terms of contacting external systems. Without the latter, running a 'test' on travis-ci.org could be an easy way to create spambots, or DDOS attacks on third party sites.

So, this needs a second set of tests which are run only on the developer's machine. Options include

  • Testing against a known, public, instance such as review.openstack.org
  • Setting up a local gerrit instance (either on localhost, or a VM)

However, tests would need to run under tox so that we can python-version-specific bugs (like #3)

Possibly the tests should be in a separate project.

Query command throws TypeError under Python2.7

Performing any query which returns results gives:

Traceback (most recent call last):
  File "./gsshcli.py", line 239, in <module>
    execute(args)
  File "./gsshcli.py", line 123, in execute
    cmds[args.operation](site, args)
  File "./gsshcli.py", line 91, in query_cmd
    qry.execute_on(site)
  File "/Users/keith/PyProjects/gerritssh/gerritssh/query.py", line 123, in execute_on
    partial = partial_query()
  File "/Users/keith/PyProjects/gerritssh/gerritssh/query.py", line 118, in partial_query
    lines = self.text_to_json(raw)
  File "/Users/keith/PyProjects/gerritssh/gerritssh/gerritsite.py", line 555, in text_to_json
    raise TypeError('Argument must be one or more strings')
TypeError: Argument must be one or more strings

The problem is related to unicode translation. Looks like paramiko returns unicode strings in python 2, so it needs to be decoded

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.