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.
- 🍰 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
pip install pGerrit
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
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.
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
To find out more about what you can do with pGerrit, see: