Skip to content

A decorator design pattern based python Gerrit rest API library

License

Notifications You must be signed in to change notification settings

demonguy/pGerrit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Documentation

PyPI PyPI - Python Versions

Summary

pGerrit is a lightweight Python library for calling Gerrit's REST API. Essentially, pGerrit is designed to make it easy to access the REST API and retrieve relevant data, much like accessing properties of classes and objects.

Complete project documentation can be found at here.

Features

  • 🍰 Clear design: Every REST API endpoint is a class. Every entity of the endpoint is an object
  • 🚀 Easy of use You can access the state of entity by access the property of the object
  • ⚙️ PyCharm Autocomplete Support Adapted for PyCharm's auto-completion. Next step we will support response autocomplete

Quickstart

Installation

pip install pGerrit

Run the code

Run the code below

from pGerrit.client import GerritClient

client = GerritClient("https://android-review.googlesource.com/")
change = client.change("1285870")
detail = change.detail()

print("")
print("branch name: " + detail.branch)
print("project name: " + detail.project)
print("created time: " + detail.created)
print("updated time: " + detail.updated)
print("")
print("Check this url to make sure info above is correct")
print("https://android-review.googlesource.com/c/platform/frameworks/support/+/1285870")
branch name: androidx-master-dev
project name: platform/frameworks/support
created time: 2020-04-15 17:53:11.000000000
updated time: 2020-04-16 16:58:26.000000000

Check this url to make sure info above is correct
https://android-review.googlesource.com/c/platform/frameworks/support/+/1285870

Tips

Chinese users

For Chinese users, Google is blocked by GFW. So you may need a proxy or VPN to get code above to work. If you'd like to try this on your private Gerrit, you may need to pass username and http_password to GerritClient class. Check document here.

The snippet above hangs there

If this code snippet hangs there and return after 2 minutes. You can try wget https://android-review.googlesource.com. If it also hangs there, you probably enabled your ipv6 but your ISP doesn't provide you corresponding services. You can disable ipv6 by following command:

sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1

sudo sysctl -p

Next Steps

To find out more about what you can do with pGerrit, see:

About

A decorator design pattern based python Gerrit rest API library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages