Crab Client API

crab.client module

class crab.client.CrabClient(command=None, crabid=None)

Crab client class, used for interaction with the server.

__init__(command=None, crabid=None)

Constructor for CrabClient.

This causes the client to configure itself, by looking for the crab.ini file. If the environment variables CRABHOST or CRABPORT exist, these override settings from the configuration files.

If the client has been started to report on the status of a job, then the command must be supplied, and the crabid should be given if known.

start()

Notify the server that the job is starting.

Return the decoded server response, which may include an inhibit dictionary item.

finish(status=2, stdoutdata='', stderrdata='')

Notify the server that the job is finishing.

send_crontab(crontab, timezone=None)

Takes the crontab as a string, breaks it into lines, and transmits it to the server.

Returns a list of warnings.

fetch_crontab(raw=False)

Retrieves crontab lines from the server, and returns them as a single string.

get_info(timezone=None)
__dict__ = mappingproxy({'__module__': 'crab.client', '__doc__': 'Crab client class, used for interaction with the server.', '__init__': <function CrabClient.__init__>, 'start': <function CrabClient.start>, 'finish': <function CrabClient.finish>, 'send_crontab': <function CrabClient.send_crontab>, 'fetch_crontab': <function CrabClient.fetch_crontab>, 'get_info': <function CrabClient.get_info>, '_get_url': <function CrabClient._get_url>, '_get_conn': <function CrabClient._get_conn>, '_read_json': <function CrabClient._read_json>, '_write_json': <function CrabClient._write_json>, '_read_error': <function CrabClient._read_error>, '__dict__': <attribute '__dict__' of 'CrabClient' objects>, '__weakref__': <attribute '__weakref__' of 'CrabClient' objects>, '__annotations__': {}})
__module__ = 'crab.client'
__weakref__

list of weak references to the object (if defined)

crab module

exception crab.CrabError

Base class for exceptions raised internally by crab.

Library functions should re-raise expected exceptions as a CrabError to allow them to be trapped conveniently without accidentally trapping other errors.

class crab.CrabStatus

Helper class for status codes.

The crab libraries should refer to codes by the symbolic names given in this class.

VALUES is the set of status codes which should be accepted from a client. Other codes are for internal use, such as those generated by the monitor.

SUCCESS = 0
FAIL = 1
UNKNOWN = 2
COULDNOTSTART = 3
ALREADYRUNNING = 4
WARNING = 5
INHIBITED = 6
WATCHDOG = 7
VALUES = {0, 1, 2, 3, 4, 5, 6, 7}
LATE = -1
MISSED = -2
TIMEOUT = -3
CLEARED = -4
INTERNAL_VALUES = {-4, -3, -2, -1}
static get_name(status)

Returns a readable name for the given status code.

static is_trivial(status)

Determines whether a status code is trivial and should mostly be ignored.

static is_ok(status)

Returns true if the code does not indicate any kind of problem.

static is_warning(status)

True if the given status is some kind of warning.

static is_error(status)

True if the given status is an error, i.e. not OK and not a warning.

class crab.CrabEvent

Helper class for crab events.

Currently just provides symbolic names for the event types.

START = 1
ALARM = 2
FINISH = 3
static get_name(event)

Returns a readable name for the given event type code.