paradrop.backend.pdfcd package¶
Submodules¶
paradrop.backend.pdfcd.apichute module¶
-
class
ChuteAPI
(rest)[source]¶ The Chute API submodule. This class handles all API calls related to actionable items that directly effect chutes.
-
POST_createChute
(theSelf, request, *args, **kwargs)¶
-
POST_deleteChute
(theSelf, request, *args, **kwargs)¶
-
POST_startChute
(theSelf, request, *args, **kwargs)¶
-
POST_stopChute
(theSelf, request, *args, **kwargs)¶
-
paradrop.backend.pdfcd.apiinternal module¶
-
apiWrapper
(target)[source]¶ Add a final line of error and success callbacks before going onto the wire
-
api_provision
(*args, **kwargs)[source]¶ Provision this router with an id and a set of keys.
This is a temporary call until the provisioning process is finalized.
-
castFailure
(failure)[source]¶ Converts an exception (or general failure) into an xmlrpc fault for transmission.
paradrop.backend.pdfcd.apiutils module¶
backend.pdfcd.apiutils. Contains helper functions specific to the backend API code.
-
addressInNetwork
(ipaddr, netTuple)[source]¶ This function allows you to check if on IP belongs to a Network. Arguments:
unpacked IP address (use unpackIPAddr()) tuple of unpacked (addr, netmask) (use unpackIPAddrWithSlash())- Returns:
- True if in network False otherwise
-
getIP
(req)[source]¶ Returns the str IP addr from the request. NOTE: This is required because when we use nginx servers it is used as a proxy, so the REAL IP addr is stored in a HTTP header called ‘X-Real-IP’, so we need to check for this first, otherwise the request.getClientIP() is always going to return ‘localhost’ to us.
paradrop.backend.pdfcd.server module¶
pdfcd.server. Contains the classes required to establish a RESTful API server using Twisted.
-
class
ParadropAPIServer
(*args, **kwargs)[source]¶ Bases:
paradrop.lib.api.pdrest.APIResource
The main API server module.
This sets up all of the submodules which should contain different types of RESTful API calls.
-
complete
(update)[source]¶ Kicks off the properly threaded call to complete the API call that was passed to PDConfigurer. Since the PDConfigurer module has its own thread that runs outside of the main event loop, we have to call back into the event system properly in order to keep any issues of concurrency at bay.
-
failprocess
(ip, request, logFailure, errorStmt, logUsage, errType)[source]¶ If logFailure is not None, Update the failureDict when the request does something wrong If logUsage is not None, log the usage track info.
- Arguments:
ip : IP of client request : the request we received logFailure : If none, we do not log this failure to failure dict. Otherwise it is a tuple of
key : the key to use in the failureDict failureDict : the dict record the failure attempt history- errorStmt : A string to return to the user, looks like ‘Malformed Body: %s’
- so that we can add things like “Number of attempts remaining: 2” to the response
logUsage : A tuple of (tictoc and devid) used for usage tracker errorResponse: The error code to set response code
- Returns:
- String to respond to the client
-
postprocess
(request, key, failureDict, logUsage)[source]¶ If the client is successful in their request, we should: * reset their failure attempts if failureDict is not none. * set success response code * If usage is not none, add usage track info of the api call
-
preprocess
(request, checkThresh, tictoc)[source]¶ Check if failure attempts for the user name has met the threshold. Arguments:
request : checkThresh : If None, no checking. Tuple of arguments for checking thresholds
ip: IP of client in string format token: sessionToken if found, or None username: username if signin, or None failureDict: the dict for failure historyticktoc: If none, do not track the usage. The start time of the API call
- Return:
- str: if threshold is met None: if ok
-