HookWorker API

Rest API

class HookWorker.api.WorkerAPI(prefix='/hook', secret='', workers=5, redis='127.0.0.1', hooktest_path='./', app=None, name=None)[source]

Worker API for Capitains Hook

Parameters:
  • prefix – Prefix for the WorkerAPI
  • secret – Salt to use in encrypting the body
  • workers – Number of workers to use in HookTest
  • redis – Redis Connection URL
  • hooktest_path – Path where to clone the data
  • app – Application object
  • name – Name of the Blueprint
Variables:

routes – Liste of tuples to store routes (url, function name, [Methods])

WorkerAPI.init_app(app)[source]

Register the blueprint to the app

Parameters:app – Flask Application
Returns:Blueprint for HookWorker registered in app
Return type:Blueprint

Controller

WorkerAPI.get_queue()[source]

Get Redis’ queue

Returns:Queue of Redis
WorkerAPI.check_signature(body, foreign_signature)[source]

Check the signature sent by a request with the body

Parameters:
  • body – Raw body of the request
  • foreign_signature – Signature sent by Hook
Returns:

Security check status

Return type:

bool

Routes

WorkerAPI.r_delete(id)[source]

Remove a test from the testing queue

Parameters:id – Job id to cancel
Returns:Json response with status and message
WorkerAPI.r_submit()[source]

Dispatch a test to the redis queue

Returns:Response with a status and the job_id if everything worked

Server Helper

HookWorker.api.set_logging(level, name, path, logger)[source]

Reroute logging of tornado into specified file with a RotatingFileHandler

Parameters:
  • level (str) – Level of logging
  • name – Name of logs file
  • path – Path where to store the logs file
  • logger – logging.logger object of Tonardo
HookWorker.api.run(secret='', debug=False, port=5000, path='./hook.worker.api.log/', level='WARNING', git='./hooktest', workers=5)[source]

Set up a Tornado process around a flask app for quick run of the WorkerAPI Blueprint

Parameters:
  • secret – Salt to use in encrypting the body
  • debug – Set Flask App in debug Mode
  • port – Port to use for Flask App
  • path – Path where to store the logs
  • level – Level of Log
  • git – Pather where to clone the data
  • workers – Number of worker to use for HookTest runs

Worker

The worker is a simpler Python RQ based worker

HookWorker.worker.worker(redis_url='localhost:6379')[source]

Run a work for python-rq

Parameters:redis_url (str) – Redis URI (redis://{redis_url})