Python API¶
Modules¶
accelize_drm¶
Accelize DRM Python Library
Copyright 2018 Accelize
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
class
accelize_drm.
DrmManager
¶ Manage Accelize DRM by handling communication with DRM controller IP and Accelize Web service.
The DrmManager require callback functions to access FPGA register.
- Parameters
conf_file_path (path-like object) – Path to the DRM configuration JSON file.
cred_file_path (path-like object) – Path to the user Accelize credential JSON file.
read_register (function) – FPGA read register callback function. The function needs to return an int and accept following arguments: register_offset (int), returned_data (int). The function can’t be a non static method. register_offset is relative to first register of DRM controller This function must be thread-safe in case of concurrency on the register bus.
write_register (function) – FPGA write register callback function. The function needs to return an int and accept following arguments: register_offset (int), data_to_write (int). The function can’t be a non static method. register_offset is relative to first register of DRM controller This function must be thread-safe in case of concurrency on the register bus.
async_error (function) – Asynchronous error handling callback function. This function is called in case of asynchronous error during operation. The function needs to return None and accept following argument: error_message (bytes). The function can’t be a non static method. If not specified, use default callback that raises “accelize_drm.exceptions.DRMException” or its subclasses.
-
activate
(self, bool resume_session_request=False)¶ Activate DRM session.
This function activate/unlocks the hardware by unlocking the protected IPs in the FPGA and opening a DRM session.
If a session is still pending the behavior depends on “resume_session_request” argument. If true the session is reused. Otherwise the session is closed and a new session is created.
This function will start a thread that keeps the hardware unlocked by automatically updating the license when necessary.
Any error during this thread execution will be reported asynchronously through the “async_error” function, if provided in constructor.
When this function returns and the license is valid, the protected IPs are guaranteed to be unlocked.
- Parameters
resume_session_request (bool) – If True, the pending session is reused. If no pending session is found, create a new one. If False and a pending session is found, close it and create a new one. Default to False.
-
deactivate
(self, bool pause_session_request=False)¶ Deactivate DRM session.
This function deactivates/locks the hardware back and close the session unless the “pause_session_request” argument is True. In this case, the session is kept opened for later use.
This function will join the thread keeping the hardware unlocked.
When the function returns, the hardware are guaranteed to be locked.
- Parameters
pause_session_request (bool) – If True, the current session is kept open for later usage. Otherwise, the current session is closed. Default to False.
-
get
(self, *keys)¶ Get information from the DRM system.
This function gives access to the internal parameter of the DRM system.
- Parameters
keys (str) – Parameters names requested.
- Returns
- If multiple keys are specified, return a dict with
parameters names as keys else return a single value.
- Return type
dict or object
-
set
(self, **values)¶ Set information of the DRM system.
This function overwrites an internal parameter of the DRM system.
- Parameters
values – Parameters to set as keyword arguments
-
accelize_drm.
get_api_version
()¶ Get version as named tuple containing :
C/C++ library version as major, minor, revision, prerelease, build.
Python library version as py_major, py_minor, py_revision, py_prerelease, py_build
C/C++ backend library name.
- Returns
Containing following values: major, minor, revision, prerelease, build, version, py_major, py_minor, py_revision, py_prerelease, py_build, backend
- Return type
namedtuple
accelize_drm.exceptions¶
DRM exceptions
-
exception
accelize_drm.exceptions.
DRMAssert
¶ Assertion failed internally (Please contact Accelize)
-
error_code
= 30002¶ Error code
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
accelize_drm.exceptions.
DRMBadArg
¶ Bad argument provided
-
error_code
= 1¶ Error code
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
accelize_drm.exceptions.
DRMBadFormat
¶ Bad format of provided input or config file
-
error_code
= 2¶ Error code
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
accelize_drm.exceptions.
DRMBadFrequency
¶ DRM frequency defined in configuration script differs from real one detected automatically by the DRMLib
-
error_code
= 5¶ Error code
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
accelize_drm.exceptions.
DRMBadUsage
¶ Wrong usage of the DRMLib
-
error_code
= 4¶ Error code
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
accelize_drm.exceptions.
DRMCtlrError
¶ An error happened on a command on the DRM controller
-
error_code
= 20001¶ Error code
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
accelize_drm.exceptions.
DRMDebug
¶ Generated for debug and testing only
-
error_code
= 40001¶ Error code
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
accelize_drm.exceptions.
DRMException
¶ Accelize DRM Base exception
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
accelize_drm.exceptions.
DRMExternFail
¶ Fail happened in an external library
-
error_code
= 3¶ Error code
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
accelize_drm.exceptions.
DRMFatal
¶ Fatal error, unknown error (Please contact Accelize)
-
error_code
= 30001¶ Error code
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
accelize_drm.exceptions.
DRMWSError
¶ Error returned from Accelize WebService
-
error_code
= 10003¶ Error code
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
accelize_drm.exceptions.
DRMWSMayRetry
¶ Error with request to Accelize Webservice, retry advised
-
error_code
= 10004¶ Error code
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
accelize_drm.exceptions.
DRMWSReqError
¶ Failed during HTTP request to Accelize WebService
-
error_code
= 10002¶ Error code
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
Cython headers¶
The Accelize DRM Python library provides following Cython headers (.pxd
) to be used
directly from Cython code.
accelize_drm.libaccelize_drm.pxd
: Accelize DRM C++ library header.accelize_drm.libaccelize_drmc.pxd
: Accelize DRM C library header.