Python client for PMEase QuickBuild
Package supports sync and async syntax with same code base.
from quickbuild import AsyncQBClient, QBClient
Official REST API documentation
pip3 install quickbuild
Get server version:
from quickbuild import QBClient
client = QBClient('https://server', 'user', 'password')
version = client.system.get_version()
print(version)
Get server version in async way (be careful AsyncQBClient
must be called inside async function):
import asyncio
from quickbuild import AsyncQBClient
async def main():
client = AsyncQBClient('https://server', 'user', 'password')
version = await client.system.get_version()
print(version)
await client.close()
asyncio.run(main())
Stop build:
from quickbuild import QBClient
client = QBClient('https://server', 'user', 'password')
client.builds.stop(123)
Update credentials handler:
import asyncio
import aiohttp
from quickbuild import AsyncQBClient
async def get_credentials():
async with aiohttp.ClientSession() as session:
async with session.get('...') as resp:
response = await resp.json()
return response['user'], response['password']
async def main():
client = AsyncQBClient('http://server', 'user', 'password',
auth_update_callback=get_credentials)
# let's suppose credentials are valid now
print(await client.builds.get_status(12345))
# now, after some time, password of user somehow changed, so our callback
# will be called, new credentials will be using for retry and future here
# we get also correct build info instead of QBUnauthorizedError exception
print(await client.builds.get_status(12345))
await client.close()
asyncio.run(main())
By default QuickBuild returns XML content, but starting from 10 version it also has native support of JSON content, usually it's much more convenient to use native Python types (parsed XML) instead of pure XML string.
So, that is why three types of content were indtoduced, this type and behavior can be set globally for client instances, and can be rewritten for some methods.
- PARSE (using by default)
- GET: parse XML to native Python types.
- POST: pure XML string.
- XML
- GET: return native XML without any transformations.
- POST: pure XML string.
- JSON (QuickBuild 10+)
- GET: parsed JSON string.
- POST: dumps object to JSON string.
It's possible to run QuickBuild community edition locally using docker:
Build locally:
docker build . -f docker/QB10.Dockerfile -t quickbuild:10
docker run --restart always --name qb10 -d -p 8810:8810 quickbuild:10
Or run prepared image:
docker run --restart always --name qb10 -d -p 8810:8810 pbelskiy/quickbuild:10
Then open http://localhost:8810/
Prerequisites: tox
Then just run tox, all dependencies and checks will run automatically
tox
Feel free for any contributions.