id
int64 0
843k
| repository_name
stringlengths 7
55
| file_path
stringlengths 9
332
| class_name
stringlengths 3
290
| human_written_code
stringlengths 12
4.36M
| class_skeleton
stringlengths 19
2.2M
| total_program_units
int64 1
9.57k
| total_doc_str
int64 0
4.2k
| AvgCountLine
float64 0
7.89k
| AvgCountLineBlank
float64 0
300
| AvgCountLineCode
float64 0
7.89k
| AvgCountLineComment
float64 0
7.89k
| AvgCyclomatic
float64 0
130
| CommentToCodeRatio
float64 0
176
| CountClassBase
float64 0
48
| CountClassCoupled
float64 0
589
| CountClassCoupledModified
float64 0
581
| CountClassDerived
float64 0
5.37k
| CountDeclInstanceMethod
float64 0
4.2k
| CountDeclInstanceVariable
float64 0
299
| CountDeclMethod
float64 0
4.2k
| CountDeclMethodAll
float64 0
4.2k
| CountLine
float64 1
115k
| CountLineBlank
float64 0
9.01k
| CountLineCode
float64 0
94.4k
| CountLineCodeDecl
float64 0
46.1k
| CountLineCodeExe
float64 0
91.3k
| CountLineComment
float64 0
27k
| CountStmt
float64 1
93.2k
| CountStmtDecl
float64 0
46.1k
| CountStmtExe
float64 0
90.2k
| MaxCyclomatic
float64 0
759
| MaxInheritanceTree
float64 0
16
| MaxNesting
float64 0
34
| SumCyclomatic
float64 0
6k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
141,448 |
Kane610/axis
|
axis/models/view_area.py
|
axis.models.view_area.GetSupportedVersionsResponseT
|
class GetSupportedVersionsResponseT(TypedDict):
"""Get supported versions response."""
apiVersion: str
context: str
method: str
data: ApiVersionsT
error: NotRequired[ErrorDataT]
|
class GetSupportedVersionsResponseT(TypedDict):
'''Get supported versions response.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.17 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 8 | 1 | 6 | 1 | 5 | 1 | 6 | 1 | 5 | 0 | 1 | 0 | 0 |
141,449 |
Kane610/axis
|
axis/models/view_area.py
|
axis.models.view_area.ListViewAreasDataT
|
class ListViewAreasDataT(TypedDict):
"""List of view areas data."""
viewAreas: list[ViewAreaT]
|
class ListViewAreasDataT(TypedDict):
'''List of view areas data.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 1 | 2 | 1 | 1 | 1 | 2 | 1 | 1 | 0 | 1 | 0 | 0 |
141,450 |
Kane610/axis
|
axis/models/view_area.py
|
axis.models.view_area.ListViewAreasRequest
|
class ListViewAreasRequest(ApiRequest):
"""Request object for listing view areas."""
method = "post"
path = "/axis-cgi/viewarea/info.cgi"
content_type = "application/json"
error_codes = general_error_codes
api_version: str = API_VERSION
context: str = CONTEXT
@property
def content(self) -> bytes:
"""Initialize request data."""
return orjson.dumps(
{
"apiVersion": self.api_version,
"context": self.context,
"method": "list",
}
)
|
class ListViewAreasRequest(ApiRequest):
'''Request object for listing view areas.'''
@property
def content(self) -> bytes:
'''Initialize request data.'''
pass
| 3 | 2 | 9 | 0 | 8 | 1 | 1 | 0.13 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 5 | 21 | 3 | 16 | 9 | 13 | 2 | 9 | 8 | 7 | 1 | 1 | 0 | 1 |
141,451 |
Kane610/axis
|
axis/models/view_area.py
|
axis.models.view_area.Geometry
|
class Geometry:
"""Represent a geometry object."""
horizontal_offset: int
horizontal_size: int
vertical_offset: int
vertical_size: int
@classmethod
def from_dict(cls, data: GeometryT) -> "Geometry":
"""Create geometry object from dict."""
return Geometry(
horizontal_offset=data["horizontalOffset"],
horizontal_size=data["horizontalSize"],
vertical_offset=data["verticalOffset"],
vertical_size=data["verticalSize"],
)
|
class Geometry:
'''Represent a geometry object.'''
@classmethod
def from_dict(cls, data: GeometryT) -> "Geometry":
'''Create geometry object from dict.'''
pass
| 3 | 2 | 8 | 0 | 7 | 1 | 1 | 0.15 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 1 | 17 | 2 | 13 | 3 | 10 | 2 | 7 | 2 | 5 | 1 | 0 | 0 | 1 |
141,452 |
Kane610/axis
|
axis/models/view_area.py
|
axis.models.view_area.ListViewAreasResponse
|
class ListViewAreasResponse(ApiResponse[dict[str, ViewArea]]):
"""Response object for list view areas response."""
api_version: str
context: str
method: str
data: dict[str, ViewArea]
# error: ErrorDataT | None = None
@classmethod
def decode(cls, bytes_data: bytes) -> Self:
"""Prepare response data."""
data: ListViewAreasResponseT = orjson.loads(bytes_data)
return cls(
api_version=data["apiVersion"],
context=data["context"],
method=data["method"],
data=ViewArea.decode_to_dict(data.get("data", {}).get("viewAreas", [])),
)
|
class ListViewAreasResponse(ApiResponse[dict[str, ViewArea]]):
'''Response object for list view areas response.'''
@classmethod
def decode(cls, bytes_data: bytes) -> Self:
'''Prepare response data.'''
pass
| 3 | 2 | 9 | 0 | 8 | 1 | 1 | 0.21 | 1 | 3 | 2 | 0 | 0 | 0 | 1 | 24 | 19 | 2 | 14 | 4 | 11 | 3 | 8 | 3 | 6 | 1 | 6 | 0 | 1 |
141,453 |
Kane610/axis
|
axis/models/stream_profile.py
|
axis.models.stream_profile.ListStreamProfilesDataT
|
class ListStreamProfilesDataT(TypedDict):
"""List of stream profiles."""
maxProfiles: int
streamProfile: list[StreamProfileT]
|
class ListStreamProfilesDataT(TypedDict):
'''List of stream profiles.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.33 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 | 1 | 3 | 1 | 2 | 1 | 3 | 1 | 2 | 0 | 1 | 0 | 0 |
141,454 |
Kane610/axis
|
axis/models/stream_profile.py
|
axis.models.stream_profile.GetSupportedVersionsRequest
|
class GetSupportedVersionsRequest(ApiRequest):
"""Request object for listing supported API versions."""
method = "post"
path = "/axis-cgi/streamprofile.cgi"
content_type = "application/json"
error_codes = error_codes
context: str = CONTEXT
@property
def content(self) -> bytes:
"""Initialize request data."""
return orjson.dumps(
{
"context": self.context,
"method": "getSupportedVersions",
}
)
|
class GetSupportedVersionsRequest(ApiRequest):
'''Request object for listing supported API versions.'''
@property
def content(self) -> bytes:
'''Initialize request data.'''
pass
| 3 | 2 | 8 | 0 | 7 | 1 | 1 | 0.14 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 5 | 19 | 3 | 14 | 8 | 11 | 2 | 8 | 7 | 6 | 1 | 1 | 0 | 1 |
141,455 |
Kane610/axis
|
axis/models/ptz_cgi.py
|
axis.models.ptz_cgi.DeviceDriverRequest
|
class DeviceDriverRequest(ApiRequest):
"""Retrieve name of the device driver."""
method = "post"
path = "/axis-cgi/com/ptz.cgi"
content_type = "text/plain"
@property
def data(self) -> dict[str, str]:
"""Request data."""
return {"whoami": "1"}
|
class DeviceDriverRequest(ApiRequest):
'''Retrieve name of the device driver.'''
@property
def data(self) -> dict[str, str]:
'''Request data.'''
pass
| 3 | 2 | 3 | 0 | 2 | 1 | 1 | 0.29 | 1 | 2 | 0 | 0 | 1 | 0 | 1 | 5 | 11 | 2 | 7 | 6 | 4 | 2 | 6 | 5 | 4 | 1 | 1 | 0 | 1 |
141,456 |
Kane610/axis
|
axis/models/ptz_cgi.py
|
axis.models.ptz_cgi.PtzCommandRequest
|
class PtzCommandRequest(ApiRequest):
"""Retrieve available PTZ commands."""
method = "post"
path = "/axis-cgi/com/ptz.cgi"
content_type = "text/plain"
@property
def data(self) -> dict[str, str]:
"""Request data."""
return {"info": "1"}
|
class PtzCommandRequest(ApiRequest):
'''Retrieve available PTZ commands.'''
@property
def data(self) -> dict[str, str]:
'''Request data.'''
pass
| 3 | 2 | 3 | 0 | 2 | 1 | 1 | 0.29 | 1 | 2 | 0 | 0 | 1 | 0 | 1 | 5 | 11 | 2 | 7 | 6 | 4 | 2 | 6 | 5 | 4 | 1 | 1 | 0 | 1 |
141,457 |
Kane610/axis
|
axis/models/ptz_cgi.py
|
axis.models.ptz_cgi.PtzControlRequest
|
class PtzControlRequest(ApiRequest):
"""Control pan, tilt and zoom behavior of a PTZ unit."""
method = "post"
path = "/axis-cgi/com/ptz.cgi"
content_type = "text/plain"
camera: int | None = None
"""Selects the video channel.
If omitted the default value camera=1 is used.
This argument is only valid for Axis products with
more than one video channel. That is cameras with
multiple view areas and video encoders with multiple video channels.
"""
center: tuple[int, int] | None = None
"""Center the camera on positions x,y.
x,y are pixel coordinates in the client video stream.
"""
area_zoom: tuple[int, int, int] | None = None
"""Centers on positions x,y and zooms by a factor of z/100.
If z is more than 100 the image is zoomed in
(for example; z=300 zooms in to 1/3 of the current field of view).
If z is less than 100 the image is zoomed out
(for example; z=50 zooms out to twice the current field of view).
"""
image_width: int | None = None
"""Required in conjunction with center or areazoom.
If the image width displayed is different from the default size of the image,
which is product-specific.
"""
image_height: int | None = None
"""Required in conjunction with center or areazoom.
If the image height is different from the default size of the image,
which is product-specific.
"""
move: PtzMove | None = None
"""Supported PTZ moves.
Absolute:Moves the image 25 % of the image field width in the specified direction.
Relative: Moves the device approx. 50-90 degrees in the specified direction.
"""
pan: float | None = None
"""-180.0 ... 180.0 Pans the device to the specified absolute coordinates."""
tilt: float | None = None
"""-180.0 ... 180.0 Tilts the device to the specified absolute coordinates."""
zoom: int | None = None
"""1 ... 9999 Zooms the device n steps to the specified absolute position.
A high value means zoom in, a low value means zoom out.
"""
focus: int | None = None
"""1 ... 9999 Moves focus n steps to the specified absolute position.
A high value means focus far, a low value means focus near.
"""
iris: int | None = None
"""1 ... 9999 Moves iris n steps to the specified absolute position.
A high value means open iris, a low value means close iris.
"""
brightness: int | None = None
"""1 ... 9999 Moves brightness n steps to the specified absolute position.
A high value means brighter image, a low value means darker image.
"""
relative_pan: float | None = None
"""-360.0 ... 360.0 Pans the device n degrees relative to the current position."""
relative_tilt: float | None = None
"""-360.0 ... 360.0 Tilts the device n degrees relative to the current position."""
relative_zoom: int | None = None
"""-9999 ... 9999 Zooms the device n steps relative to the current position.
Positive values mean zoom in, negative values mean zoom out.
"""
relative_focus: int | None = None
"""-9999 ... 9999 Moves focus n steps relative to the current position.
Positive values mean focus far, negative values mean focus near.
"""
relative_iris: int | None = None
"""-9999 ... 9999 Moves iris n steps relative to the current position.
Positive values mean open iris, negative values mean close iris.
"""
relative_brightness: int | None = None
"""-9999 ... 9999 Moves brightness n steps relative to the current position.
Positive values mean brighter image, negative values mean darker image.
"""
auto_focus: bool | None = None
"""Enable/disable auto focus."""
auto_iris: bool | None = None
"""Enable/disable auto iris."""
continuous_pantilt_move: tuple[int, int] | None = None
"""-100 ... 100,-100 ... 100 Continuous pan/tilt motion.
Positive values mean right (pan) and up (tilt),
negative values mean left (pan) and down (tilt).
0,0 means stop.
Values as <pan speed>,<tilt speed>.
"""
continuous_zoom_move: int | None = None
"""-100 ... 100 Continuous zoom motion.
Positive values mean zoom in and negative values mean zoom out.
0 means stop.
"""
continuous_focus_move: int | None = None
"""-100 ... 100 Continuous focus motion.
Positive values mean focus far and negative values mean focus near.
0 means stop.
"""
continuous_iris_move: int | None = None
"""-100 ... 100 Continuous iris motion.
Positive values mean iris open and negative values mean iris close.
0 means stop.
"""
continuous_brightness_move: int | None = None
"""-100 ... 100 Continuous brightness motion.
Positive values mean brighter image and negative values mean darker image.
0 means stop.
"""
auxiliary: str | None = None
"""Activates/deactivates auxiliary functions of the device.
<function name> is the name of the device specific function.
Check in driver's documentation or in response to info=1
for information about <function name>.
"""
go_to_server_preset_name: str | None = None
"""Move to the position associated with the <preset name>."""
go_to_server_preset_number: int | None = None
"""Move to the position associated with the specified preset position number."""
go_to_device_preset: int | None = None
"""Bypasses the presetpos interface.
Tells the device togo directly to the preset position number
<preset pos> stored in the device,
where the <preset pos> is a device-specific preset position number.
This may also be a device-specific special function.
"""
speed: int | None = None
"""1 ... 100 Sets the move speed of pan and tilt."""
image_rotation: PtzRotation | None = None
"""Rotate image.
If PTZ command refers to an image stream that is rotated differently
than the current image setup, then the image stream rotation
must be added to each command with this argument to
allow the Axis product to compensate.
"""
ir_cut_filter: PtzState | None = None
"""Control the IR cut filter."""
backlight: bool | None = None
"""Control the backlight compensation."""
@property
def data(self) -> dict[str, str] | None:
"""Request data."""
data = {}
if self.camera:
data["camera"] = str(self.camera)
if self.center:
x, y = self.center
data["center"] = f"{x},{y}"
if self.area_zoom:
x, y, z = self.area_zoom
z = max(z, 1)
data["areazoom"] = f"{x},{y},{z}"
if self.center or self.area_zoom:
if self.image_width:
data["imagewidth"] = str(self.image_width)
if self.image_height:
data["imageheight"] = str(self.image_height)
for key, limit_value, minimum, maximum in (
("pan", self.pan, -180, 180),
("tilt", self.tilt, -180, 180),
("zoom", self.zoom, 1, 9999),
("focus", self.focus, 1, 9999),
("iris", self.iris, 1, 9999),
("brightness", self.brightness, 1, 9999),
("rpan", self.relative_pan, -360, 360),
("rtilt", self.relative_tilt, -360, 360),
("rzoom", self.relative_zoom, -9999, 9999),
("rfocus", self.relative_focus, -9999, 9999),
("riris", self.relative_iris, -9999, 9999),
("rbrightness", self.relative_brightness, -9999, 9999),
("continuouszoommove", self.continuous_zoom_move, -100, 100),
("continuousfocusmove", self.continuous_focus_move, -100, 100),
("continuousirismove", self.continuous_iris_move, -100, 100),
("continuousbrightnessmove", self.continuous_brightness_move, -100, 100),
("speed", self.speed, 1, 100),
):
if limit_value is not None:
data[key] = str(max(min(limit_value, maximum), minimum))
for key, command_bool in (
("autofocus", self.auto_focus),
("autoiris", self.auto_iris),
("backlight", self.backlight),
):
if command_bool is not None:
data[key] = "on" if command_bool else "off"
data |= {
key: command_enum
for key, command_enum in (
("imagerotation", self.image_rotation),
("ircutfilter", self.ir_cut_filter),
("move", self.move),
)
if command_enum is not None
}
if self.continuous_pantilt_move:
pan_speed, tilt_speed = self.continuous_pantilt_move
pan_speed = max(min(pan_speed, 100), -100)
tilt_speed = max(min(tilt_speed, 100), -100)
data["continuouspantiltmove"] = f"{pan_speed},{tilt_speed}"
if self.auxiliary:
data["auxiliary"] = self.auxiliary
if self.go_to_server_preset_name:
data["gotoserverpresetname"] = self.go_to_server_preset_name
if self.go_to_server_preset_number:
data["gotoserverpresetno"] = str(self.go_to_server_preset_number)
if self.go_to_device_preset:
data["gotodevicepreset"] = str(self.go_to_device_preset)
if len(data) == 0 or (len(data) == 1 and "camera" in data):
return None
return data
|
class PtzControlRequest(ApiRequest):
'''Control pan, tilt and zoom behavior of a PTZ unit.'''
@property
def data(self) -> dict[str, str] | None:
'''Request data.'''
pass
| 3 | 2 | 75 | 5 | 69 | 1 | 18 | 0.96 | 1 | 2 | 0 | 0 | 1 | 0 | 1 | 5 | 242 | 32 | 107 | 45 | 104 | 103 | 76 | 44 | 74 | 18 | 1 | 2 | 18 |
141,458 |
Kane610/axis
|
axis/models/ptz_cgi.py
|
axis.models.ptz_cgi.PtzMove
|
class PtzMove(enum.StrEnum):
"""Supported PTZ moves.
Absolute:Moves the image 25 % of the image field width in the specified direction.
Relative: Moves the device approx. 50-90 degrees in the specified direction.
"""
HOME = "home"
"""Moves the image to the home position."""
UP = "up"
"""Moves the image up."""
DOWN = "down"
"""Moves the image down."""
LEFT = "left"
"""Moves the image to the left."""
RIGHT = "right"
"""Moves the image to the right."""
UPLEFT = "upleft"
"""Moves the image up diagonal to the left."""
UPRIGHT = "upright"
"""Moves the image up diagonal to the right."""
DOWNLEFT = "downleft"
"""Moves the image down diagonal to the left."""
DOWNRIGHT = "downright"
"""Moves the image down diagonal to the right."""
STOP = "stop"
"""Stops the pan/tilt movement."""
|
class PtzMove(enum.StrEnum):
'''Supported PTZ moves.
Absolute:Moves the image 25 % of the image field width in the specified direction.
Relative: Moves the device approx. 50-90 degrees in the specified direction.
'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1.27 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 68 | 36 | 11 | 11 | 11 | 10 | 14 | 11 | 11 | 10 | 0 | 3 | 0 | 0 |
141,459 |
Kane610/axis
|
axis/models/ptz_cgi.py
|
axis.models.ptz_cgi.PtzQuery
|
class PtzQuery(enum.StrEnum):
"""Supported PTZ queries."""
LIMITS = "limits"
"""PTZ limits for the Axis product."""
MODE = "mode"
"""Products with Panopsis technology: The current mode (overview or normal)."""
POSITION = "position"
"""Values for current position."""
PRESETPOSALL = "presetposall"
"""Current preset positions for all video channels."""
PRESETPOSCAM = "presetposcam"
"""Current preset positions for a video channel."""
PRESETPOSCAMDATA = "presetposcamdata"
"""Configured preset positions with position data measured in degrees."""
SPEED = "speed"
"""Values for pan/tilt speed."""
|
class PtzQuery(enum.StrEnum):
'''Supported PTZ queries.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 68 | 23 | 7 | 8 | 8 | 7 | 8 | 8 | 8 | 7 | 0 | 3 | 0 | 0 |
141,460 |
Kane610/axis
|
axis/models/ptz_cgi.py
|
axis.models.ptz_cgi.PtzRotation
|
class PtzRotation(enum.StrEnum):
"""Supported PTZ rotations."""
ROTATION_0 = "0"
ROTATION_90 = "90"
ROTATION_180 = "180"
ROTATION_270 = "270"
|
class PtzRotation(enum.StrEnum):
'''Supported PTZ rotations.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 68 | 7 | 1 | 5 | 5 | 4 | 1 | 5 | 5 | 4 | 0 | 3 | 0 | 0 |
141,461 |
Kane610/axis
|
axis/models/ptz_cgi.py
|
axis.models.ptz_cgi.PtzState
|
class PtzState(enum.StrEnum):
"""Supported PTZ states."""
AUTO = "auto"
ON = "on"
OFF = "off"
|
class PtzState(enum.StrEnum):
'''Supported PTZ states.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.25 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 68 | 6 | 1 | 4 | 4 | 3 | 1 | 4 | 4 | 3 | 0 | 3 | 0 | 0 |
141,462 |
Kane610/axis
|
axis/models/stream_profile.py
|
axis.models.stream_profile.GetSupportedVersionsResponseT
|
class GetSupportedVersionsResponseT(TypedDict):
"""ListApis response."""
apiVersion: str
context: str
method: str
data: ApiVersionsT
error: NotRequired[ErrorDataT]
|
class GetSupportedVersionsResponseT(TypedDict):
'''ListApis response.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.17 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 8 | 1 | 6 | 1 | 5 | 1 | 6 | 1 | 5 | 0 | 1 | 0 | 0 |
141,463 |
Kane610/axis
|
axis/models/ptz_cgi.py
|
axis.models.ptz_cgi.QueryRequest
|
class QueryRequest(ApiRequest):
"""Retrieve current status."""
method = "post"
path = "/axis-cgi/com/ptz.cgi"
content_type = "text/plain"
query: PtzQuery
@property
def data(self) -> dict[str, str]:
"""Request data."""
return {"query": self.query}
|
class QueryRequest(ApiRequest):
'''Retrieve current status.'''
@property
def data(self) -> dict[str, str]:
'''Request data.'''
pass
| 3 | 2 | 3 | 0 | 2 | 1 | 1 | 0.25 | 1 | 2 | 0 | 0 | 1 | 0 | 1 | 5 | 13 | 3 | 8 | 6 | 5 | 2 | 7 | 5 | 5 | 1 | 1 | 0 | 1 |
141,464 |
Kane610/axis
|
axis/models/pwdgrp_cgi.py
|
axis.models.pwdgrp_cgi.DeleteUserRequest
|
class DeleteUserRequest(ApiRequest):
"""Request object for deleting a user."""
method = "post"
path = "/axis-cgi/pwdgrp.cgi"
content_type = "text/plain"
user: str
@property
def data(self) -> dict[str, str]:
"""Request data."""
return {"action": "remove", "user": self.user}
|
class DeleteUserRequest(ApiRequest):
'''Request object for deleting a user.'''
@property
def data(self) -> dict[str, str]:
'''Request data.'''
pass
| 3 | 2 | 3 | 0 | 2 | 1 | 1 | 0.25 | 1 | 2 | 0 | 0 | 1 | 0 | 1 | 5 | 13 | 3 | 8 | 6 | 5 | 2 | 7 | 5 | 5 | 1 | 1 | 0 | 1 |
141,465 |
Kane610/axis
|
axis/models/pwdgrp_cgi.py
|
axis.models.pwdgrp_cgi.GetUsersRequest
|
class GetUsersRequest(ApiRequest):
"""Request object for listing users."""
method = "post"
path = "/axis-cgi/pwdgrp.cgi"
content_type = "text/plain"
@property
def data(self) -> dict[str, str]:
"""Request data."""
return {"action": "get"}
|
class GetUsersRequest(ApiRequest):
'''Request object for listing users.'''
@property
def data(self) -> dict[str, str]:
'''Request data.'''
pass
| 3 | 2 | 3 | 0 | 2 | 1 | 1 | 0.29 | 1 | 2 | 0 | 0 | 1 | 0 | 1 | 5 | 11 | 2 | 7 | 6 | 4 | 2 | 6 | 5 | 4 | 1 | 1 | 0 | 1 |
141,466 |
Kane610/axis
|
axis/models/pwdgrp_cgi.py
|
axis.models.pwdgrp_cgi.GetUsersResponse
|
class GetUsersResponse(ApiResponse[dict[str, User]]):
"""Response object for listing ports."""
@classmethod
def decode(cls, bytes_data: bytes) -> Self:
"""Prepare API description dictionary."""
if "=" not in (string_data := bytes_data.decode()):
return cls(data={})
data: dict[str, str] = dict(
group.split("=", 1) for group in string_data.replace('"', "").splitlines()
)
user_list = {
user
for group in ("admin", "operator", "viewer", "ptz")
for user in data[group].split(",")
}
users: list[UserGroupsT] = [
{
"user": user,
"admin": user in data["admin"].split(","),
"operator": user in data["operator"].split(","),
"viewer": user in data["viewer"].split(","),
"ptz": user in data["ptz"].split(","),
}
for user in user_list
]
return cls(data=User.decode_to_dict(users))
|
class GetUsersResponse(ApiResponse[dict[str, User]]):
'''Response object for listing ports.'''
@classmethod
def decode(cls, bytes_data: bytes) -> Self:
'''Prepare API description dictionary.'''
pass
| 3 | 2 | 27 | 4 | 22 | 1 | 2 | 0.08 | 1 | 6 | 2 | 0 | 0 | 0 | 1 | 24 | 31 | 5 | 24 | 7 | 21 | 2 | 8 | 5 | 6 | 2 | 6 | 1 | 2 |
141,467 |
Kane610/axis
|
axis/models/pwdgrp_cgi.py
|
axis.models.pwdgrp_cgi.ModifyUserRequest
|
class ModifyUserRequest(ApiRequest):
"""Request object for modifying a user."""
method = "post"
path = "/axis-cgi/pwdgrp.cgi"
content_type = "text/plain"
user: str
pwd: str | None = None
sgrp: SecondaryGroup | None = None
comment: str | None = None
@property
def data(self) -> dict[str, str]:
"""Request data."""
data = {"action": "update", "user": self.user}
if self.pwd is not None:
data["pwd"] = self.pwd
if self.sgrp:
data["sgrp"] = self.sgrp
if self.comment:
data["comment"] = self.comment
return data
|
class ModifyUserRequest(ApiRequest):
'''Request object for modifying a user.'''
@property
def data(self) -> dict[str, str]:
'''Request data.'''
pass
| 3 | 2 | 14 | 4 | 9 | 1 | 4 | 0.11 | 1 | 2 | 0 | 0 | 1 | 0 | 1 | 5 | 27 | 7 | 18 | 10 | 15 | 2 | 17 | 9 | 15 | 4 | 1 | 1 | 4 |
141,468 |
Kane610/axis
|
axis/models/pwdgrp_cgi.py
|
axis.models.pwdgrp_cgi.SecondaryGroup
|
class SecondaryGroup(enum.StrEnum):
"""Supported user secondary groups.
Defines the user access rights for the account.
"""
ADMIN = "viewer:operator:admin"
ADMIN_PTZ = "viewer:operator:admin:ptz"
OPERATOR = "viewer:operator"
OPERATOR_PTZ = "viewer:operator:ptz"
VIEWER = "viewer"
VIEWER_PTZ = "viewer:ptz"
UNKNOWN = "unknown"
|
class SecondaryGroup(enum.StrEnum):
'''Supported user secondary groups.
Defines the user access rights for the account.
'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.38 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 68 | 14 | 3 | 8 | 8 | 7 | 3 | 8 | 8 | 7 | 0 | 3 | 0 | 0 |
141,469 |
Kane610/axis
|
axis/models/pwdgrp_cgi.py
|
axis.models.pwdgrp_cgi.User
|
class User(ApiItem):
"""Represents a user and the groups it belongs to."""
admin: bool
operator: bool
viewer: bool
ptz: bool
@property
def name(self) -> str:
"""User name."""
return self.id
@property
def privileges(self) -> SecondaryGroup:
"""Return highest privileged role supported."""
if self.admin:
return SecondaryGroup.ADMIN_PTZ if self.ptz else SecondaryGroup.ADMIN
if self.operator:
return SecondaryGroup.OPERATOR_PTZ if self.ptz else SecondaryGroup.OPERATOR
if self.viewer:
return SecondaryGroup.VIEWER_PTZ if self.ptz else SecondaryGroup.VIEWER
return SecondaryGroup.UNKNOWN
@classmethod
def decode(cls, data: UserGroupsT) -> Self:
"""Create object from dict."""
return cls(
id=data["user"],
admin=data["admin"],
operator=data["operator"],
viewer=data["viewer"],
ptz=data["ptz"],
)
|
class User(ApiItem):
'''Represents a user and the groups it belongs to.'''
@property
def name(self) -> str:
'''User name.'''
pass
@property
def privileges(self) -> SecondaryGroup:
'''Return highest privileged role supported.'''
pass
@classmethod
def decode(cls, data: UserGroupsT) -> Self:
'''Create object from dict.'''
pass
| 7 | 4 | 7 | 0 | 6 | 1 | 3 | 0.15 | 1 | 3 | 2 | 0 | 2 | 0 | 3 | 26 | 34 | 4 | 26 | 7 | 19 | 4 | 17 | 4 | 13 | 7 | 5 | 1 | 9 |
141,470 |
Kane610/axis
|
axis/models/pwdgrp_cgi.py
|
axis.models.pwdgrp_cgi.UserGroupsT
|
class UserGroupsT(TypedDict):
"""Groups user belongs to."""
user: str
admin: bool
operator: bool
viewer: bool
ptz: bool
|
class UserGroupsT(TypedDict):
'''Groups user belongs to.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.17 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 8 | 1 | 6 | 1 | 5 | 1 | 6 | 1 | 5 | 0 | 1 | 0 | 0 |
141,471 |
Kane610/axis
|
axis/models/pwdgrp_cgi.py
|
axis.models.pwdgrp_cgi.CreateUserRequest
|
class CreateUserRequest(ApiRequest):
"""Request object for creating a user."""
method = "post"
path = "/axis-cgi/pwdgrp.cgi"
content_type = "text/plain"
user: str
pwd: str
sgrp: SecondaryGroup
comment: str | None = None
@property
def data(self) -> dict[str, str]:
"""Request data."""
data = {
"action": "add",
"user": self.user,
"pwd": self.pwd,
"grp": "users",
"sgrp": self.sgrp,
}
if self.comment is not None:
data["comment"] = self.comment
return data
|
class CreateUserRequest(ApiRequest):
'''Request object for creating a user.'''
@property
def data(self) -> dict[str, str]:
'''Request data.'''
pass
| 3 | 2 | 14 | 2 | 11 | 1 | 2 | 0.1 | 1 | 2 | 0 | 0 | 1 | 0 | 1 | 5 | 27 | 5 | 20 | 8 | 17 | 2 | 13 | 7 | 11 | 2 | 1 | 1 | 2 |
141,472 |
Kane610/axis
|
axis/models/view_area.py
|
axis.models.view_area.ListViewAreasResponseT
|
class ListViewAreasResponseT(TypedDict):
"""List view areas response."""
apiVersion: str
context: str
method: str
data: ListViewAreasDataT
error: NotRequired[ErrorDataT]
|
class ListViewAreasResponseT(TypedDict):
'''List view areas response.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.17 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 8 | 1 | 6 | 1 | 5 | 1 | 6 | 1 | 5 | 0 | 1 | 0 | 0 |
141,473 |
Kane610/axis
|
axis/models/view_area.py
|
axis.models.view_area.ResetGeometryRequest
|
class ResetGeometryRequest(ApiRequest):
"""Request object for resetting geometry of a view area."""
method = "post"
path = "/axis-cgi/viewarea/configure.cgi"
content_type = "application/json"
error_codes = general_error_codes
id: int
api_version: str = API_VERSION
context: str = CONTEXT
@property
def content(self) -> bytes:
"""Initialize request data."""
return orjson.dumps(
{
"apiVersion": self.api_version,
"context": self.context,
"method": "resetGeometry",
"params": {"viewArea": {"id": self.id}},
}
)
|
class ResetGeometryRequest(ApiRequest):
'''Request object for resetting geometry of a view area.'''
@property
def content(self) -> bytes:
'''Initialize request data.'''
pass
| 3 | 2 | 10 | 0 | 9 | 1 | 1 | 0.11 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 5 | 24 | 4 | 18 | 9 | 15 | 2 | 10 | 8 | 8 | 1 | 1 | 0 | 1 |
141,474 |
Kane610/axis
|
axis/models/view_area.py
|
axis.models.view_area.SetGeometryRequest
|
class SetGeometryRequest(ApiRequest):
"""Request object for setting geometry of a view area."""
method = "post"
path = "/axis-cgi/viewarea/configure.cgi"
content_type = "application/json"
error_codes = general_error_codes
id: int
geometry: Geometry
api_version: str = API_VERSION
context: str = CONTEXT
@property
def content(self) -> bytes:
"""Initialize request data."""
return orjson.dumps(
{
"apiVersion": self.api_version,
"context": self.context,
"method": "setGeometry",
"params": {
"viewArea": {
"id": self.id,
"rectangularGeometry": {
"horizontalOffset": self.geometry.horizontal_offset,
"horizontalSize": self.geometry.horizontal_size,
"verticalOffset": self.geometry.vertical_offset,
"verticalSize": self.geometry.vertical_size,
},
}
},
}
)
|
class SetGeometryRequest(ApiRequest):
'''Request object for setting geometry of a view area.'''
@property
def content(self) -> bytes:
'''Initialize request data.'''
pass
| 3 | 2 | 20 | 0 | 19 | 1 | 1 | 0.07 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 5 | 35 | 4 | 29 | 9 | 26 | 2 | 11 | 8 | 9 | 1 | 1 | 0 | 1 |
141,475 |
Kane610/axis
|
axis/interfaces/applications/fence_guard.py
|
axis.interfaces.applications.fence_guard.FenceGuardHandler
|
class FenceGuardHandler(ApplicationHandler[Configuration]):
"""Fence guard handler for Axis devices."""
app_name = ApplicationName.FENCE_GUARD
async def get_configuration(self) -> Configuration:
"""Get configuration of VMD4 application."""
bytes_data = await self.vapix.api_request(GetConfigurationRequest())
response = GetConfigurationResponse.decode(bytes_data)
return response.data
|
class FenceGuardHandler(ApplicationHandler[Configuration]):
'''Fence guard handler for Axis devices.'''
async def get_configuration(self) -> Configuration:
'''Get configuration of VMD4 application.'''
pass
| 2 | 2 | 5 | 0 | 4 | 1 | 1 | 0.33 | 1 | 3 | 3 | 0 | 1 | 0 | 1 | 26 | 10 | 2 | 6 | 5 | 4 | 2 | 6 | 5 | 4 | 1 | 3 | 0 | 1 |
141,476 |
Kane610/axis
|
axis/interfaces/applications/applications.py
|
axis.interfaces.applications.applications.ApplicationsHandler
|
class ApplicationsHandler(ApiHandler[Application]):
"""API Discovery for Axis devices."""
@property
def listed_in_parameters(self) -> bool:
"""Is application supported and in a usable state."""
if self.vapix.params.property_handler.supported and (
properties := self.vapix.params.property_handler.get("0")
):
return version.parse(properties.embedded_development) >= version.parse(
MINIMUM_VERSION
)
return False
async def _api_request(self) -> dict[str, Application]:
"""Get default data of API discovery."""
return await self.list_applications()
async def list_applications(self) -> dict[str, Application]:
"""List all APIs registered on API Discovery service."""
bytes_data = await self.vapix.api_request(ListApplicationsRequest())
response = ListApplicationsResponse.decode(bytes_data)
return response.data
|
class ApplicationsHandler(ApiHandler[Application]):
'''API Discovery for Axis devices.'''
@property
def listed_in_parameters(self) -> bool:
'''Is application supported and in a usable state.'''
pass
async def _api_request(self) -> dict[str, Application]:
'''Get default data of API discovery.'''
pass
async def list_applications(self) -> dict[str, Application]:
'''List all APIs registered on API Discovery service.'''
pass
| 5 | 4 | 6 | 0 | 5 | 1 | 1 | 0.25 | 1 | 6 | 3 | 0 | 3 | 0 | 3 | 24 | 23 | 3 | 16 | 8 | 11 | 4 | 11 | 6 | 7 | 2 | 2 | 1 | 4 |
141,477 |
Kane610/axis
|
axis/interfaces/api_handler.py
|
axis.interfaces.api_handler.SubscriptionHandler
|
class SubscriptionHandler:
"""Manage subscription and notification to subscribers."""
def __init__(self) -> None:
"""Initialize subscription handler."""
self._subscribers: dict[str, list[SubscriptionType]] = {ID_FILTER_ALL: []}
def signal_subscribers(self, obj_id: str) -> None:
"""Signal subscribers."""
subscribers: list[SubscriptionType] = (
self._subscribers.get(obj_id, []) + self._subscribers[ID_FILTER_ALL]
)
for callback in subscribers:
callback(obj_id)
def subscribe(
self,
callback: CallbackType,
id_filter: tuple[str] | str | None = None,
) -> UnsubscribeType:
"""Subscribe to added events."""
subscription = callback
_id_filter: tuple[str]
if id_filter is None:
_id_filter = (ID_FILTER_ALL,)
elif isinstance(id_filter, str):
_id_filter = (id_filter,)
for obj_id in _id_filter:
if obj_id not in self._subscribers:
self._subscribers[obj_id] = []
self._subscribers[obj_id].append(subscription)
def unsubscribe() -> None:
for obj_id in _id_filter:
if obj_id not in self._subscribers:
continue
if subscription not in self._subscribers[obj_id]:
continue
self._subscribers[obj_id].remove(subscription)
return unsubscribe
|
class SubscriptionHandler:
'''Manage subscription and notification to subscribers.'''
def __init__(self) -> None:
'''Initialize subscription handler.'''
pass
def signal_subscribers(self, obj_id: str) -> None:
'''Signal subscribers.'''
pass
def subscribe(
self,
callback: CallbackType,
id_filter: tuple[str] | str | None = None,
) -> UnsubscribeType:
'''Subscribe to added events.'''
pass
def unsubscribe() -> None:
pass
| 5 | 4 | 11 | 1 | 10 | 1 | 3 | 0.13 | 0 | 4 | 0 | 2 | 3 | 1 | 3 | 3 | 43 | 7 | 32 | 15 | 23 | 4 | 25 | 11 | 20 | 5 | 0 | 2 | 12 |
141,478 |
Kane610/axis
|
axis/interfaces/api_discovery.py
|
axis.interfaces.api_discovery.ApiDiscoveryHandler
|
class ApiDiscoveryHandler(ApiHandler[Api]):
"""API Discovery for Axis devices."""
api_id = ApiId.API_DISCOVERY
default_api_version = API_VERSION
@property
def listed_in_api_discovery(self) -> bool:
"""API Discovery is always listed in API Discovery."""
return True
async def _api_request(self) -> dict[str, Api]:
"""Get default data of API discovery."""
return await self.get_api_list()
async def get_api_list(self) -> dict[str, Api]:
"""List all APIs registered on API Discovery service."""
bytes_data = await self.vapix.api_request(ListApisRequest())
return GetAllApisResponse.decode(bytes_data).data
async def get_supported_versions(self) -> list[str]:
"""List supported API versions."""
bytes_data = await self.vapix.api_request(GetSupportedVersionsRequest())
response = GetSupportedVersionsResponse.decode(bytes_data)
return response.data
|
class ApiDiscoveryHandler(ApiHandler[Api]):
'''API Discovery for Axis devices.'''
@property
def listed_in_api_discovery(self) -> bool:
'''API Discovery is always listed in API Discovery.'''
pass
async def _api_request(self) -> dict[str, Api]:
'''Get default data of API discovery.'''
pass
async def get_api_list(self) -> dict[str, Api]:
'''List all APIs registered on API Discovery service.'''
pass
async def get_supported_versions(self) -> list[str]:
'''List supported API versions.'''
pass
| 6 | 5 | 4 | 0 | 3 | 1 | 1 | 0.33 | 1 | 9 | 5 | 0 | 4 | 0 | 4 | 25 | 25 | 5 | 15 | 11 | 9 | 5 | 14 | 10 | 9 | 1 | 2 | 0 | 4 |
141,479 |
Kane610/axis
|
axis/errors.py
|
axis.errors.Unauthorized
|
class Unauthorized(AxisException):
"""Username is not authorized."""
|
class Unauthorized(AxisException):
'''Username is not authorized.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 4 | 0 | 0 |
141,480 |
Kane610/axis
|
axis/errors.py
|
axis.errors.ResponseError
|
class ResponseError(AxisException):
"""Invalid response."""
|
class ResponseError(AxisException):
'''Invalid response.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 4 | 0 | 0 |
141,481 |
Kane610/axis
|
axis/errors.py
|
axis.errors.RequestError
|
class RequestError(AxisException):
"""Unable to fulfill request.
Raised when device cannot be reached.
"""
|
class RequestError(AxisException):
'''Unable to fulfill request.
Raised when device cannot be reached.
'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 5 | 1 | 1 | 1 | 0 | 3 | 1 | 1 | 0 | 0 | 4 | 0 | 0 |
141,482 |
Kane610/axis
|
axis/interfaces/applications/loitering_guard.py
|
axis.interfaces.applications.loitering_guard.LoiteringGuardHandler
|
class LoiteringGuardHandler(ApplicationHandler[Configuration]):
"""Loitering guard handler for Axis devices."""
app_name = ApplicationName.LOITERING_GUARD
async def get_configuration(self) -> Configuration:
"""Get configuration of VMD4 application."""
bytes_data = await self.vapix.api_request(GetConfigurationRequest())
response = GetConfigurationResponse.decode(bytes_data)
return response.data
|
class LoiteringGuardHandler(ApplicationHandler[Configuration]):
'''Loitering guard handler for Axis devices.'''
async def get_configuration(self) -> Configuration:
'''Get configuration of VMD4 application.'''
pass
| 2 | 2 | 5 | 0 | 4 | 1 | 1 | 0.33 | 1 | 3 | 3 | 0 | 1 | 0 | 1 | 26 | 10 | 2 | 6 | 5 | 4 | 2 | 6 | 5 | 4 | 1 | 3 | 0 | 1 |
141,483 |
Kane610/axis
|
axis/errors.py
|
axis.errors.PathNotFound
|
class PathNotFound(AxisException):
"""Path not found."""
|
class PathNotFound(AxisException):
'''Path not found.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 4 | 0 | 0 |
141,484 |
Kane610/axis
|
axis/errors.py
|
axis.errors.LoginRequired
|
class LoginRequired(AxisException):
"""User is logged out."""
|
class LoginRequired(AxisException):
'''User is logged out.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 4 | 0 | 0 |
141,485 |
Kane610/axis
|
axis/errors.py
|
axis.errors.Forbidden
|
class Forbidden(AxisException):
"""Endpoint is not accessible due to low permissions."""
|
class Forbidden(AxisException):
'''Endpoint is not accessible due to low permissions.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 4 | 0 | 0 |
141,486 |
Kane610/axis
|
axis/errors.py
|
axis.errors.AxisException
|
class AxisException(Exception):
"""Base error for Axis."""
|
class AxisException(Exception):
'''Base error for Axis.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 7 | 0 | 0 | 0 | 10 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 3 | 0 | 0 |
141,487 |
Kane610/axis
|
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/Kane610_axis/tests/test_api_handler.py
|
tests.test_api_handler.test_class.ClassForTest
|
class ClassForTest(SubscriptionHandler):
"""Class to test subscriptions."""
|
class ClassForTest(SubscriptionHandler):
'''Class to test subscriptions.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 1 | 0 | 0 |
141,488 |
Kane610/axis
|
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/Kane610_axis/axis/rtsp.py
|
axis.rtsp.RTPClient.UDPClient
|
class UDPClient:
"""Datagram recepient for device data."""
def __init__(self, callback: Callable[[Signal], None] | None) -> None:
"""Signal events to subscriber using callback."""
self.callback = callback
self.data: deque[bytes] = deque()
self.transport: asyncio.BaseTransport | None = None
self.fragment: bool = False
def connection_made(self, transport: asyncio.BaseTransport) -> None:
"""Execute when port is up and listening.
Save reference to transport for future control.
"""
_LOGGER.debug("Stream listener online")
self.transport = transport
def connection_lost(self, exc: Exception | None) -> None:
"""Signal retry if RTSP session fails to get a response."""
_LOGGER.debug("Stream recepient offline")
def datagram_received(self, data: bytes, addr: Any) -> None:
"""Signals when new data is available."""
if self.callback:
payload = data[RTP_HEADER_SIZE:]
# if the previous packet was a fragment, then merge it
if self.fragment:
previous = self.data.pop()
self.data.append(previous + payload)
else:
self.data.append(payload)
# check whether the RTP marker bit is set, if not it is a fragment
self.fragment = (data[1] & 0b1 << 7) == 0
if not self.fragment:
self.callback(Signal.DATA)
|
class UDPClient:
'''Datagram recepient for device data.'''
def __init__(self, callback: Callable[[Signal], None] | None) -> None:
'''Signal events to subscriber using callback.'''
pass
def connection_made(self, transport: asyncio.BaseTransport) -> None:
'''Execute when port is up and listening.
Save reference to transport for future control.
'''
pass
def connection_lost(self, exc: Exception | None) -> None:
'''Signal retry if RTSP session fails to get a response.'''
pass
def datagram_received(self, data: bytes, addr: Any) -> None:
'''Signals when new data is available.'''
pass
| 5 | 5 | 8 | 1 | 5 | 2 | 2 | 0.41 | 0 | 6 | 1 | 0 | 4 | 4 | 4 | 4 | 38 | 7 | 22 | 11 | 17 | 9 | 21 | 11 | 16 | 4 | 0 | 2 | 7 |
141,489 |
Kane610/axis
|
axis/device.py
|
axis.device.AxisDevice
|
class AxisDevice:
"""Creates a new Axis device.self."""
def __init__(self, configuration: Configuration) -> None:
"""Initialize device functionality."""
self.config = configuration
self.vapix = Vapix(self)
self.stream = StreamManager(self)
self.event = EventManager()
def enable_events(self) -> None:
"""Enable events for stream."""
self.stream.event = True
|
class AxisDevice:
'''Creates a new Axis device.self.'''
def __init__(self, configuration: Configuration) -> None:
'''Initialize device functionality.'''
pass
def enable_events(self) -> None:
'''Enable events for stream.'''
pass
| 3 | 3 | 5 | 0 | 4 | 1 | 1 | 0.38 | 0 | 4 | 4 | 0 | 2 | 4 | 2 | 2 | 13 | 2 | 8 | 7 | 5 | 3 | 8 | 7 | 5 | 1 | 0 | 0 | 2 |
141,490 |
Kane610/axis
|
axis/interfaces/parameters/image.py
|
axis.interfaces.parameters.image.ImageParameterHandler
|
class ImageParameterHandler(ParamHandler[ImageParam]):
"""Handler for image parameters."""
parameter_group = ParameterGroup.IMAGE
parameter_item = ImageParam
|
class ImageParameterHandler(ParamHandler[ImageParam]):
'''Handler for image parameters.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.33 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 25 | 5 | 1 | 3 | 3 | 2 | 1 | 3 | 3 | 2 | 0 | 3 | 0 | 0 |
141,491 |
Kane610/axis
|
axis/errors.py
|
axis.errors.MethodNotAllowed
|
class MethodNotAllowed(AxisException):
"""Invalid request."""
|
class MethodNotAllowed(AxisException):
'''Invalid request.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 4 | 0 | 0 |
141,492 |
Kane610/axis
|
axis/interfaces/applications/motion_guard.py
|
axis.interfaces.applications.motion_guard.MotionGuardHandler
|
class MotionGuardHandler(ApplicationHandler[Configuration]):
"""Motion guard handler for Axis devices."""
app_name = ApplicationName.MOTION_GUARD
async def get_configuration(self) -> Configuration:
"""Get configuration of VMD4 application."""
bytes_data = await self.vapix.api_request(GetConfigurationRequest())
response = GetConfigurationResponse.decode(bytes_data)
return response.data
|
class MotionGuardHandler(ApplicationHandler[Configuration]):
'''Motion guard handler for Axis devices.'''
async def get_configuration(self) -> Configuration:
'''Get configuration of VMD4 application.'''
pass
| 2 | 2 | 5 | 0 | 4 | 1 | 1 | 0.33 | 1 | 3 | 3 | 0 | 1 | 0 | 1 | 26 | 10 | 2 | 6 | 5 | 4 | 2 | 6 | 5 | 4 | 1 | 3 | 0 | 1 |
141,493 |
Kane610/axis
|
axis/interfaces/applications/object_analytics.py
|
axis.interfaces.applications.object_analytics.ObjectAnalyticsHandler
|
class ObjectAnalyticsHandler(ApplicationHandler[Configuration]):
"""Object analytics handler for Axis devices."""
app_name = ApplicationName.OBJECT_ANALYTICS
async def get_configuration(self) -> Configuration:
"""Get configuration of object analytics application."""
bytes_data = await self.vapix.api_request(GetConfigurationRequest())
response = GetConfigurationResponse.decode(bytes_data)
return response.data
|
class ObjectAnalyticsHandler(ApplicationHandler[Configuration]):
'''Object analytics handler for Axis devices.'''
async def get_configuration(self) -> Configuration:
'''Get configuration of object analytics application.'''
pass
| 2 | 2 | 5 | 0 | 4 | 1 | 1 | 0.33 | 1 | 3 | 3 | 0 | 1 | 0 | 1 | 26 | 10 | 2 | 6 | 5 | 4 | 2 | 6 | 5 | 4 | 1 | 3 | 0 | 1 |
141,494 |
Kane610/axis
|
axis/interfaces/applications/vmd4.py
|
axis.interfaces.applications.vmd4.Vmd4Handler
|
class Vmd4Handler(ApplicationHandler[Configuration]):
"""VMD4 handler for Axis devices."""
app_name = ApplicationName.VMD4
async def get_configuration(self) -> Configuration:
"""Get configuration of VMD4 application."""
bytes_data = await self.vapix.api_request(GetConfigurationRequest())
response = GetConfigurationResponse.decode(bytes_data)
return response.data
|
class Vmd4Handler(ApplicationHandler[Configuration]):
'''VMD4 handler for Axis devices.'''
async def get_configuration(self) -> Configuration:
'''Get configuration of VMD4 application.'''
pass
| 2 | 2 | 5 | 0 | 4 | 1 | 1 | 0.33 | 1 | 3 | 3 | 0 | 1 | 0 | 1 | 26 | 10 | 2 | 6 | 5 | 4 | 2 | 6 | 5 | 4 | 1 | 3 | 0 | 1 |
141,495 |
Kane610/axis
|
axis/models/view_area.py
|
axis.models.view_area.Size
|
class Size:
"""Represent a size object."""
horizontal: int
vertical: int
@classmethod
def from_dict(cls, item: SizeT) -> "Size":
"""Create size object from dict."""
return Size(horizontal=item["horizontal"], vertical=item["vertical"])
|
class Size:
'''Represent a size object.'''
@classmethod
def from_dict(cls, item: SizeT) -> "Size":
'''Create size object from dict.'''
pass
| 3 | 2 | 3 | 0 | 2 | 1 | 1 | 0.33 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 1 | 10 | 2 | 6 | 3 | 3 | 2 | 5 | 2 | 3 | 1 | 0 | 0 | 1 |
141,496 |
Kane610/axis
|
axis/models/view_area.py
|
axis.models.view_area.SizeT
|
class SizeT(TypedDict):
"""Represent a size object."""
horizontal: int
vertical: int
|
class SizeT(TypedDict):
'''Represent a size object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.33 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 | 1 | 3 | 1 | 2 | 1 | 3 | 1 | 2 | 0 | 1 | 0 | 0 |
141,497 |
Kane610/axis
|
axis/models/view_area.py
|
axis.models.view_area.ViewArea
|
class ViewArea(ApiItem):
"""View area object."""
camera: int
source: int
configurable: bool
# These are only listed if the geometry of the view area can be configured.
canvas_size: Size | None = None
rectangular_geometry: Geometry | None = None
min_size: Size | None = None
max_size: Size | None = None
grid: Geometry | None = None
@classmethod
def decode(cls, data: ViewAreaT) -> Self:
"""Decode dict to class object."""
def create_geometry(item: GeometryT | None) -> Geometry | None:
"""Create geometry object."""
if item is None:
return None
return Geometry.from_dict(item)
def create_size(item: SizeT | None) -> Size | None:
"""Create size object."""
if item is None:
return None
return Size.from_dict(item)
return cls(
id=str(data["id"]),
camera=data["camera"],
source=data["source"],
configurable=data["configurable"],
canvas_size=create_size(data.get("canvasSize")),
rectangular_geometry=create_geometry(data.get("rectangularGeometry")),
min_size=create_size(data.get("minSize")),
max_size=create_size(data.get("maxSize")),
grid=create_geometry(data.get("grid")),
)
|
class ViewArea(ApiItem):
'''View area object.'''
@classmethod
def decode(cls, data: ViewAreaT) -> Self:
'''Decode dict to class object.'''
pass
def create_geometry(item: GeometryT | None) -> Geometry | None:
'''Create geometry object.'''
pass
def create_size(item: SizeT | None) -> Size | None:
'''Create size object.'''
pass
| 5 | 4 | 12 | 1 | 9 | 2 | 2 | 0.17 | 1 | 6 | 5 | 0 | 0 | 0 | 1 | 24 | 42 | 7 | 30 | 10 | 25 | 5 | 19 | 9 | 15 | 2 | 5 | 1 | 5 |
141,498 |
Kane610/axis
|
axis/models/view_area.py
|
axis.models.view_area.ViewAreaT
|
class ViewAreaT(TypedDict):
"""View area representation."""
id: int
source: int
camera: int
configurable: bool
rectangularGeometry: NotRequired[GeometryT]
canvasSize: NotRequired[SizeT]
minSize: NotRequired[SizeT]
maxSize: NotRequired[SizeT]
grid: NotRequired[GeometryT]
|
class ViewAreaT(TypedDict):
'''View area representation.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 12 | 1 | 10 | 1 | 9 | 1 | 10 | 1 | 9 | 0 | 1 | 0 | 0 |
141,499 |
Kane610/axis
|
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/Kane610_axis/tests/test_rtsp.py
|
tests.test_rtsp.test_successful_connect.UDPClientProtocol
|
class UDPClientProtocol:
def __init__(self):
self.transport = None
def connection_made(self, transport):
self.transport = transport
def connection_lost(self, exc):
LOGGER.info("Connection lost.")
def send_message(self, message: str) -> None:
LOGGER.info("Send: %s", message)
self.transport.sendto(message.encode())
|
class UDPClientProtocol:
def __init__(self):
pass
def connection_made(self, transport):
pass
def connection_lost(self, exc):
pass
def send_message(self, message: str) -> None:
pass
| 5 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 4 | 1 | 4 | 4 | 13 | 3 | 10 | 6 | 5 | 0 | 10 | 6 | 5 | 1 | 0 | 0 | 4 |
141,500 |
Kane610/axis
|
axis/rtsp.py
|
axis.rtsp.RTSPClient
|
class RTSPClient(asyncio.Protocol):
"""RTSP transport, session handling, message generation."""
def __init__(
self,
url: str,
host: str,
username: str,
password: str,
callback: Callable[[Signal], None],
) -> None:
"""RTSP."""
self.loop = asyncio.get_running_loop()
self.callback = callback
self.rtp = RTPClient(self.loop, callback)
self.session = RTSPSession(url, host, username, password)
self.session.rtp_port = self.rtp.port
self.session.rtcp_port = self.rtp.rtcp_port
self.method = RTSPMethods(self.session)
self.transport: asyncio.BaseTransport | None = None
self.keep_alive_handle: asyncio.TimerHandle | None = None
self.time_out_handle: asyncio.TimerHandle | None = None
async def start(self) -> None:
"""Start RTSP session."""
await self.rtp.start()
try:
await self.loop.create_connection(
lambda: self, self.session.host, self.session.port
)
except OSError as err:
_LOGGER.debug("RTSP got exception %s", err)
self.stop()
self.callback(Signal.FAILED)
def stop(self) -> None:
"""Stop session."""
self.session.stop()
if self.transport:
self.transport.write(self.method.message.encode()) # type: ignore [attr-defined]
self.transport.close()
self.rtp.stop()
if self.keep_alive_handle is not None:
self.keep_alive_handle.cancel()
if self.time_out_handle is not None:
self.time_out_handle.cancel()
def connection_made(self, transport: asyncio.BaseTransport) -> None:
"""Connect to device is successful.
Start configuring RTSP session.
Schedule time out handle in case device doesn't respond.
"""
self.transport = transport
self.transport.write(self.method.message.encode()) # type: ignore [attr-defined]
self.time_out_handle = self.loop.call_later(TIME_OUT_LIMIT, self.time_out)
def data_received(self, data: bytes) -> None:
"""Got response on RTSP session.
Manage time out handle since response came in a reasonable time.
Update session parameters with latest response.
If state is playing schedule keep-alive.
"""
self.time_out_handle.cancel() # type: ignore [union-attr]
self.session.update(data.decode())
if self.session.state == State.STARTING:
self.transport.write(self.method.message.encode()) # type: ignore [union-attr]
self.time_out_handle = self.loop.call_later(TIME_OUT_LIMIT, self.time_out)
elif self.session.state == State.PLAYING:
self.callback(Signal.PLAYING)
if self.session.session_timeout != 0:
interval = self.session.session_timeout - 5
self.keep_alive_handle = self.loop.call_later(interval, self.keep_alive)
else:
self.stop()
def keep_alive(self) -> None:
"""Keep RTSP session alive per negotiated time interval."""
self.transport.write(self.method.message.encode()) # type: ignore [union-attr]
self.time_out_handle = self.loop.call_later(TIME_OUT_LIMIT, self.time_out)
def time_out(self) -> None:
"""If we don't get a response within time the RTSP request time out.
This usually happens if device isn't available on specified IP.
"""
_LOGGER.warning("Response timed out %s", self.session.host)
self.stop()
self.callback(Signal.FAILED)
def connection_lost(self, exc: Exception | None) -> None:
"""Happens when device closes connection or stop() has been called."""
_LOGGER.debug("RTSP session lost connection")
|
class RTSPClient(asyncio.Protocol):
'''RTSP transport, session handling, message generation.'''
def __init__(
self,
url: str,
host: str,
username: str,
password: str,
callback: Callable[[Signal], None],
) -> None:
'''RTSP.'''
pass
async def start(self) -> None:
'''Start RTSP session.'''
pass
def stop(self) -> None:
'''Stop session.'''
pass
def connection_made(self, transport: asyncio.BaseTransport) -> None:
'''Connect to device is successful.
Start configuring RTSP session.
Schedule time out handle in case device doesn't respond.
'''
pass
def data_received(self, data: bytes) -> None:
'''Got response on RTSP session.
Manage time out handle since response came in a reasonable time.
Update session parameters with latest response.
If state is playing schedule keep-alive.
'''
pass
def keep_alive(self) -> None:
'''Keep RTSP session alive per negotiated time interval.'''
pass
def time_out(self) -> None:
'''If we don't get a response within time the RTSP request time out.
This usually happens if device isn't available on specified IP.
'''
pass
def connection_lost(self, exc: Exception | None) -> None:
'''Happens when device closes connection or stop() has been called.'''
pass
| 9 | 9 | 12 | 2 | 8 | 3 | 2 | 0.35 | 1 | 10 | 5 | 0 | 8 | 8 | 8 | 8 | 105 | 22 | 65 | 26 | 49 | 23 | 54 | 18 | 45 | 4 | 1 | 2 | 15 |
141,501 |
Kane610/axis
|
axis/rtsp.py
|
axis.rtsp.RTSPMethods
|
class RTSPMethods:
"""Generate RTSP messages based on session data."""
def __init__(self, session: RTSPSession) -> None:
"""Define message methods."""
self.session = session
self.message_methods: dict[str, Callable[[], str]] = {
"OPTIONS": self.options,
"DESCRIBE": self.describe,
"SETUP": self.setup,
"PLAY": self.play,
"KEEP-ALIVE": self.keep_alive,
"TEARDOWN": self.teardown,
}
@property
def message(self) -> str:
"""Return RTSP method based on sequence number from session."""
message = self.message_methods[self.session.method]()
_LOGGER.debug(message)
return message
def keep_alive(self) -> str:
"""Keep-Alive messages doesn't need authentication."""
return self.options(False)
def options(self, authenticate: bool = True) -> str:
"""Request options device supports."""
message = f"OPTIONS {self.session.url} RTSP/1.0\r\n"
message += self.sequence
message += self.authentication if authenticate else ""
message += self.user_agent
message += self.session_id
message += "\r\n"
return message
def describe(self) -> str:
"""Request description of what services RTSP server make available."""
message = f"DESCRIBE {self.session.url} RTSP/1.0\r\n"
message += self.sequence
message += self.authentication
message += self.user_agent
message += "Accept: application/sdp\r\n"
message += "\r\n"
return message
def setup(self) -> str:
"""Set up stream transport."""
message = f"SETUP {self.session.control_url} RTSP/1.0\r\n"
message += self.sequence
message += self.authentication
message += self.user_agent
message += self.transport
message += "\r\n"
return message
def play(self) -> str:
"""RTSP session is ready to send data."""
message = f"PLAY {self.session.url} RTSP/1.0\r\n"
message += self.sequence
message += self.authentication
message += self.user_agent
message += self.session_id
message += "\r\n"
return message
def teardown(self) -> str:
"""Tell device to tear down session."""
message = f"TEARDOWN {self.session.url} RTSP/1.0\r\n"
message += self.sequence
message += self.authentication
message += self.user_agent
message += self.session_id
message += "\r\n"
return message
@property
def sequence(self) -> str:
"""Generate sequence string."""
return f"CSeq: {self.session.sequence}\r\n"
@property
def authentication(self) -> str:
"""Generate authentication string."""
if self.session.digest:
authentication = self.session.generate_digest()
elif self.session.basic:
authentication = self.session.generate_basic()
else:
return ""
return f"Authorization: {authentication}\r\n"
@property
def user_agent(self) -> str:
"""Generate user-agent string."""
return f"User-Agent: {self.session.user_agent}\r\n"
@property
def session_id(self) -> str:
"""Generate session string."""
if self.session.session_id:
return f"Session: {self.session.session_id}\r\n"
return ""
@property
def transport(self) -> str:
"""Generate transport string."""
return f"Transport: RTP/AVP;unicast;client_port={self.session.rtp_port}-{self.session.rtcp_port}\r\n"
|
class RTSPMethods:
'''Generate RTSP messages based on session data.'''
def __init__(self, session: RTSPSession) -> None:
'''Define message methods.'''
pass
@property
def message(self) -> str:
'''Return RTSP method based on sequence number from session.'''
pass
def keep_alive(self) -> str:
'''Keep-Alive messages doesn't need authentication.'''
pass
def options(self, authenticate: bool = True) -> str:
'''Request options device supports.'''
pass
def describe(self) -> str:
'''Request description of what services RTSP server make available.'''
pass
def setup(self) -> str:
'''Set up stream transport.'''
pass
def play(self) -> str:
'''RTSP session is ready to send data.'''
pass
def teardown(self) -> str:
'''Tell device to tear down session.'''
pass
@property
def sequence(self) -> str:
'''Generate sequence string.'''
pass
@property
def authentication(self) -> str:
'''Generate authentication string.'''
pass
@property
def user_agent(self) -> str:
'''Generate user-agent string.'''
pass
@property
def session_id(self) -> str:
'''Generate session string.'''
pass
@property
def transport(self) -> str:
'''Generate transport string.'''
pass
| 20 | 14 | 7 | 0 | 6 | 1 | 1 | 0.17 | 0 | 5 | 1 | 0 | 13 | 2 | 13 | 13 | 108 | 13 | 81 | 29 | 61 | 14 | 66 | 23 | 52 | 3 | 0 | 1 | 17 |
141,502 |
Kane610/axis
|
axis/rtsp.py
|
axis.rtsp.RTSPSession
|
class RTSPSession:
"""All RTSP session data.
Stores device stream configuration and session data.
"""
def __init__(self, url: str, host: str, username: str, password: str) -> None:
"""Session parameters."""
self._basic_auth: str | None = None
self.sequence = 0
self.url = url
self.host = host
self.port = RTSP_PORT
self.username = username
self.password = password
self.user_agent = "HASS Axis"
self.rtp_port = None
self.rtcp_port = None
self.methods = [
"OPTIONS",
"DESCRIBE",
"SETUP",
"PLAY",
"KEEP-ALIVE",
"TEARDOWN",
]
# Information as part of ack from device
self.rtsp_version: int | None = None
self.status_code: int | None = None
self.status_text: str | None = None
self.sequence_ack: int | None = None
self.date: str | None = None
self.methods_ack: list[str] | None = None
self.basic = False
self.digest = False
self.realm: str | None = None
self.nonce: str | None = None
self.stale: bool | None = None
self.content_type: str | None = None
self.content_base: str | None = None
self.content_length: int | None = None
self.session_id: str | None = None
self.session_timeout = 0
self.transport_ack: str | None = None
self.range: str | None = None
self.rtp_info: str | None = None
self.sdp: list[str] | None = None
self.control_url: str | None = None
@property
def method(self) -> str:
"""Which method the sequence number corresponds to.
0 - OPTIONS
1 - DESCRIBE
2 - SETUP
3 - PLAY
4 - KEEP-ALIVE (OPTIONS)
5 - TEARDOWN
"""
return self.methods[self.sequence]
@property
def state(self) -> State:
"""Which state the session is in.
Starting - all messages needed to get stream started.
Playing - keep-alive messages every self.session_timeout.
"""
if self.method in ["OPTIONS", "DESCRIBE", "SETUP", "PLAY"]:
return State.STARTING
if self.method in ["KEEP-ALIVE"]:
return State.PLAYING
return State.STOPPED
def update(self, response: str) -> None:
"""Update session information from device response.
Increment sequence number when starting stream, not when playing.
If device requires authentication resend previous message with auth.
"""
data = response.splitlines()
_LOGGER.debug("Received data %s from %s", data, self.host)
while data:
line = data.pop(0)
if "RTSP/1.0" in line:
self.rtsp_version = int(line.split(" ")[0][5])
self.status_code = int(line.split(" ")[1])
self.status_text = line.split(" ")[2]
elif "CSeq" in line:
self.sequence_ack = int(line.split(": ")[1])
elif "Date" in line:
self.date = line.split(": ")[1]
elif "Public" in line:
self.methods_ack = line.split(": ")[1].split(", ")
elif "WWW-Authenticate: Basic" in line:
self.basic = True
self.realm = line.split('"')[1]
elif "WWW-Authenticate: Digest" in line:
self.digest = True
self.realm = line.split('"')[1]
self.nonce = line.split('"')[3]
self.stale = line.split("stale=")[1] == "TRUE"
elif "Content-Type" in line:
self.content_type = line.split(": ")[1]
elif "Content-Base" in line:
self.content_base = line.split(": ")[1]
elif "Content-Length" in line:
self.content_length = int(line.split(": ")[1])
elif "Session" in line:
self.session_id = line.split(": ")[1].split(";")[0]
if "=" in line:
self.session_timeout = int(line.split(": ")[1].split("=")[1])
elif "Transport" in line:
self.transport_ack = line.split(": ")[1]
elif "Range" in line:
self.range = line.split(": ")[1]
elif "RTP-Info" in line:
self.rtp_info = line.split(": ")[1]
elif not line:
if data:
self.sdp = data
break
if self.sdp:
stream_found = False
for param in self.sdp:
if not stream_found and "m=application" in param:
stream_found = True
elif stream_found and "a=control:rtsp" in param:
self.control_url = param.split(":", 1)[1]
break
if self.status_code == 200:
if self.state == State.STARTING:
self.sequence += 1
elif self.status_code == 401:
# Device requires authorization, do not increment to next method
pass
else:
# If device configuration is correct we should never get here
_LOGGER.debug(
"%s RTSP %s %s", self.host, self.status_code, self.status_text
)
def generate_digest(self) -> str:
"""RFC 2617."""
from hashlib import md5
_ha1 = f"{self.username}:{self.realm}:{self.password}"
ha1 = md5(_ha1.encode("UTF-8")).hexdigest()
_ha2 = f"{self.method}:{self.url}"
ha2 = md5(_ha2.encode("UTF-8")).hexdigest()
encrypt_response = f"{ha1}:{self.nonce}:{ha2}"
response = md5(encrypt_response.encode("UTF-8")).hexdigest()
digest_auth = "Digest "
digest_auth += f'username="{self.username}", '
digest_auth += f'realm="{self.realm}", '
digest_auth += 'algorithm="MD5", '
digest_auth += f'nonce="{self.nonce}", '
digest_auth += f'uri="{self.url}", '
digest_auth += f'response="{response}"'
return digest_auth
def generate_basic(self) -> str:
"""RFC 2617."""
from base64 import b64encode
if not self._basic_auth:
creds = f"{self.username}:{self.password}"
self._basic_auth = "Basic "
self._basic_auth += b64encode(creds.encode("UTF-8")).decode("UTF-8")
return self._basic_auth
def stop(self) -> None:
"""Set session to stopped."""
self.sequence = 5
|
class RTSPSession:
'''All RTSP session data.
Stores device stream configuration and session data.
'''
def __init__(self, url: str, host: str, username: str, password: str) -> None:
'''Session parameters.'''
pass
@property
def method(self) -> str:
'''Which method the sequence number corresponds to.
0 - OPTIONS
1 - DESCRIBE
2 - SETUP
3 - PLAY
4 - KEEP-ALIVE (OPTIONS)
5 - TEARDOWN
'''
pass
@property
def state(self) -> State:
'''Which state the session is in.
Starting - all messages needed to get stream started.
Playing - keep-alive messages every self.session_timeout.
'''
pass
def update(self, response: str) -> None:
'''Update session information from device response.
Increment sequence number when starting stream, not when playing.
If device requires authentication resend previous message with auth.
'''
pass
def generate_digest(self) -> str:
'''RFC 2617.'''
pass
def generate_basic(self) -> str:
'''RFC 2617.'''
pass
def stop(self) -> None:
'''Set session to stopped.'''
pass
| 10 | 8 | 24 | 1 | 19 | 3 | 5 | 0.19 | 0 | 5 | 1 | 0 | 7 | 32 | 7 | 7 | 179 | 17 | 136 | 56 | 124 | 26 | 109 | 54 | 99 | 25 | 0 | 3 | 34 |
141,503 |
Kane610/axis
|
axis/rtsp.py
|
axis.rtsp.Signal
|
class Signal(enum.StrEnum):
"""What is the content of the callback."""
DATA = "data"
FAILED = "failed"
PLAYING = "playing"
|
class Signal(enum.StrEnum):
'''What is the content of the callback.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.25 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 68 | 6 | 1 | 4 | 4 | 3 | 1 | 4 | 4 | 3 | 0 | 3 | 0 | 0 |
141,504 |
Kane610/axis
|
axis/rtsp.py
|
axis.rtsp.State
|
class State(enum.StrEnum):
"""State of the connection."""
PAUSED = "paused"
PLAYING = "playing"
STARTING = "starting"
STOPPED = "stopped"
|
class State(enum.StrEnum):
'''State of the connection.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 68 | 7 | 1 | 5 | 5 | 4 | 1 | 5 | 5 | 4 | 0 | 3 | 0 | 0 |
141,505 |
Kane610/axis
|
axis/stream_manager.py
|
axis.stream_manager.StreamManager
|
class StreamManager:
"""Setup, start, stop and retry stream."""
def __init__(self, device: "AxisDevice") -> None:
"""Initialize stream manager."""
self.device = device
self.video = None # Unsupported
self.audio = None # Unsupported
self.event = False
self.stream: RTSPClient | None = None
self.connection_status_callback: list[Callable[[Signal], None]] = []
self.background_tasks: set[asyncio.Task[None]] = set()
self.retry_timer: asyncio.TimerHandle | None = None
@property
def stream_url(self) -> str:
"""Build url for stream."""
rtsp_url = RTSP_URL.format(
host=self.device.config.host,
video=self.video_query,
audio=self.audio_query,
event=self.event_query,
)
_LOGGER.debug(rtsp_url)
return rtsp_url
@property
def video_query(self) -> int:
"""Generate video query, not supported."""
return 0
@property
def audio_query(self) -> int:
"""Generate audio query, not supported."""
return 0
@property
def event_query(self) -> str:
"""Generate event query."""
return "on" if self.event else "off"
def session_callback(self, signal: Signal) -> None:
"""Signalling from stream session.
Data - new data available for processing.
Playing - Connection is healthy.
Retry - if there is no connection to device.
"""
if signal == Signal.DATA and self.event:
self.device.event.handler(self.data)
elif signal == Signal.FAILED:
self.retry()
if signal in [Signal.PLAYING, Signal.FAILED]:
for callback in self.connection_status_callback:
callback(signal)
@property
def data(self) -> bytes:
"""Get stream data."""
return self.stream.rtp.data # type: ignore[union-attr]
@property
def state(self) -> State:
"""State of stream."""
if not self.stream:
return State.STOPPED
return self.stream.session.state
def start(self) -> None:
"""Start stream."""
if not self.stream or self.stream.session.state == State.STOPPED:
self.stream = RTSPClient(
self.stream_url,
self.device.config.host,
self.device.config.username,
self.device.config.password,
self.session_callback,
)
task = asyncio.create_task(self.stream.start())
self.background_tasks.add(task)
task.add_done_callback(self.background_tasks.discard)
def stop(self) -> None:
"""Stop stream."""
if self.stream and self.stream.session.state != State.STOPPED:
self.stream.stop()
self.cancel_retry()
def retry(self) -> None:
"""No connection to device, retry connection after 15 seconds."""
self.cancel_retry()
loop = asyncio.get_running_loop()
self.stream = None
self.retry_timer = loop.call_later(RETRY_TIMER, self.start)
_LOGGER.debug("Reconnecting to %s", self.device.config.host)
def cancel_retry(self) -> None:
"""Cancel scheduled retry."""
if self.retry_timer is not None:
self.retry_timer.cancel()
|
class StreamManager:
'''Setup, start, stop and retry stream.'''
def __init__(self, device: "AxisDevice") -> None:
'''Initialize stream manager.'''
pass
@property
def stream_url(self) -> str:
'''Build url for stream.'''
pass
@property
def video_query(self) -> int:
'''Generate video query, not supported.'''
pass
@property
def audio_query(self) -> int:
'''Generate audio query, not supported.'''
pass
@property
def event_query(self) -> str:
'''Generate event query.'''
pass
def session_callback(self, signal: Signal) -> None:
'''Signalling from stream session.
Data - new data available for processing.
Playing - Connection is healthy.
Retry - if there is no connection to device.
'''
pass
@property
def data(self) -> bytes:
'''Get stream data.'''
pass
@property
def state(self) -> State:
'''State of stream.'''
pass
def start(self) -> None:
'''Start stream.'''
pass
def stop(self) -> None:
'''Stop stream.'''
pass
def retry(self) -> None:
'''No connection to device, retry connection after 15 seconds.'''
pass
def cancel_retry(self) -> None:
'''Cancel scheduled retry.'''
pass
| 19 | 13 | 7 | 0 | 5 | 2 | 2 | 0.29 | 0 | 9 | 3 | 0 | 12 | 8 | 12 | 12 | 103 | 16 | 70 | 31 | 51 | 20 | 52 | 25 | 39 | 5 | 0 | 2 | 21 |
141,506 |
Kane610/axis
|
tests/conftest.py
|
tests.conftest.TcpServerProtocol
|
class TcpServerProtocol(asyncio.Protocol):
"""Simple socket server that responds with preset responses."""
def __init__(self) -> None:
"""Initialize TCP protocol server."""
self._response_queue: deque[str] = deque()
self.requests: list[str] = []
self.next_request_received = asyncio.Event()
def register_response(self, response: str) -> None:
"""Take a single response as an argument and queue it."""
self._response_queue.append(response)
def register_responses(self, responses: list[str]) -> None:
"""Take a list of responses as an argument and queue them."""
self._response_queue.extend(responses)
def connection_made(self, transport) -> None:
"""Successful connection."""
peername = transport.get_extra_info("peername")
LOGGER.info("Server connection from %s", peername)
self.transport = transport
def data_received(self, data: bytes) -> None:
"""Received a request from a client.
If test is waiting on next request to be received it can now continue.
"""
message = data.decode()
self.requests.append(message)
LOGGER.info("Server received: %s", repr(message))
self.next_request_received.set()
def send_response(self, response: str) -> None:
"""Send response to client.
Clear event so test can wait on next request to be received.
"""
LOGGER.info("Server response: %s", repr(response))
self.transport.write(response.encode())
self.next_request_received.clear()
def step_response(self) -> None:
"""Send next response in queue."""
response = self._response_queue.popleft()
self.send_response(response)
@property
def last_request(self) -> str:
"""Return last request."""
return self.requests[-1]
def stop(self) -> None:
"""Stop server."""
self.transport.close()
|
class TcpServerProtocol(asyncio.Protocol):
'''Simple socket server that responds with preset responses.'''
def __init__(self) -> None:
'''Initialize TCP protocol server.'''
pass
def register_response(self, response: str) -> None:
'''Take a single response as an argument and queue it.'''
pass
def register_responses(self, responses: list[str]) -> None:
'''Take a list of responses as an argument and queue them.'''
pass
def connection_made(self, transport) -> None:
'''Successful connection.'''
pass
def data_received(self, data: bytes) -> None:
'''Received a request from a client.
If test is waiting on next request to be received it can now continue.
'''
pass
def send_response(self, response: str) -> None:
'''Send response to client.
Clear event so test can wait on next request to be received.
'''
pass
def step_response(self) -> None:
'''Send next response in queue.'''
pass
@property
def last_request(self) -> str:
'''Return last request.'''
pass
def stop(self) -> None:
'''Stop server.'''
pass
| 11 | 10 | 5 | 0 | 3 | 1 | 1 | 0.47 | 1 | 3 | 0 | 0 | 9 | 4 | 9 | 9 | 55 | 11 | 30 | 18 | 19 | 14 | 29 | 17 | 19 | 1 | 1 | 0 | 9 |
141,507 |
Kane610/axis
|
axis/interfaces/mqtt.py
|
axis.interfaces.mqtt.MqttClientHandler
|
class MqttClientHandler(ApiHandler[Any]):
"""MQTT Client for Axis devices."""
api_id = ApiId.MQTT_CLIENT
default_api_version = API_VERSION
async def configure_client(self, client_config: ClientConfig) -> None:
"""Configure MQTT Client."""
await self.vapix.api_request(
ConfigureClientRequest(
api_version=self.default_api_version, client_config=client_config
)
)
async def activate(self) -> None:
"""Activate MQTT Client."""
await self.vapix.api_request(
ActivateClientRequest(api_version=self.default_api_version)
)
async def deactivate(self) -> None:
"""Deactivate MQTT Client."""
await self.vapix.api_request(
DeactivateClientRequest(api_version=self.default_api_version)
)
async def get_client_status(self) -> ClientConfigStatus:
"""Get MQTT Client status."""
bytes_data = await self.vapix.api_request(
GetClientStatusRequest(api_version=self.default_api_version)
)
response = GetClientStatusResponse.decode(bytes_data)
return response.data
async def get_event_publication_config(self) -> EventPublicationConfig:
"""Get MQTT Client event publication config."""
bytes_data = await self.vapix.api_request(
GetEventPublicationConfigRequest(api_version=self.default_api_version)
)
response = GetEventPublicationConfigResponse.decode(bytes_data)
return response.data
async def configure_event_publication(
self, topics: list[str] = DEFAULT_TOPICS
) -> None:
"""Configure MQTT Client event publication."""
event_filters = EventFilter.from_list(
[{"topicFilter": topic} for topic in topics]
)
config = EventPublicationConfig(event_filter_list=event_filters)
await self.vapix.api_request(
ConfigureEventPublicationRequest(
api_version=self.default_api_version, config=config
)
)
|
class MqttClientHandler(ApiHandler[Any]):
'''MQTT Client for Axis devices.'''
async def configure_client(self, client_config: ClientConfig) -> None:
'''Configure MQTT Client.'''
pass
async def activate(self) -> None:
'''Activate MQTT Client.'''
pass
async def deactivate(self) -> None:
'''Deactivate MQTT Client.'''
pass
async def get_client_status(self) -> ClientConfigStatus:
'''Get MQTT Client status.'''
pass
async def get_event_publication_config(self) -> EventPublicationConfig:
'''Get MQTT Client event publication config.'''
pass
async def configure_event_publication(
self, topics: list[str] = DEFAULT_TOPICS
) -> None:
'''Configure MQTT Client event publication.'''
pass
| 7 | 7 | 7 | 0 | 6 | 1 | 1 | 0.17 | 1 | 14 | 12 | 0 | 6 | 0 | 6 | 27 | 55 | 7 | 41 | 17 | 32 | 7 | 21 | 15 | 14 | 1 | 2 | 0 | 6 |
141,508 |
Kane610/axis
|
axis/interfaces/light_control.py
|
axis.interfaces.light_control.LightHandler
|
class LightHandler(ApiHandler[LightInformation]):
"""Light control for Axis devices."""
api_id = ApiId.LIGHT_CONTROL
default_api_version = API_VERSION
@property
def listed_in_parameters(self) -> bool:
"""Is API listed in parameters."""
if prop := self.vapix.params.property_handler.get("0"):
return prop.light_control
return False
async def _api_request(self) -> dict[str, LightInformation]:
"""Get default data of stream profiles."""
return await self.get_light_information()
async def get_light_information(self) -> dict[str, LightInformation]:
"""List the light control information."""
bytes_data = await self.vapix.api_request(
GetLightInformationRequest(api_version=self.default_api_version)
)
return GetLightInformationResponse.decode(bytes_data).data
async def get_service_capabilities(self) -> ServiceCapabilities:
"""List the light control information."""
bytes_data = await self.vapix.api_request(
GetServiceCapabilitiesRequest(api_version=self.default_api_version)
)
return GetServiceCapabilitiesResponse.decode(bytes_data).data
async def activate_light(self, light_id: str) -> None:
"""Activate the light."""
await self.vapix.api_request(
ActivateLightRequest(
api_version=self.default_api_version, light_id=light_id
)
)
async def deactivate_light(self, light_id: str) -> None:
"""Deactivate the light."""
await self.vapix.api_request(
DeactivateLightRequest(
api_version=self.default_api_version, light_id=light_id
)
)
async def enable_light(self, light_id: str) -> None:
"""Activate the light."""
await self.vapix.api_request(
EnableLightRequest(api_version=self.default_api_version, light_id=light_id)
)
async def disable_light(self, light_id: str) -> None:
"""Deactivate the light."""
await self.vapix.api_request(
DisableLightRequest(api_version=self.default_api_version, light_id=light_id)
)
async def get_light_status(self, light_id: str) -> bool:
"""Get light status if its on or off."""
bytes_data = await self.vapix.api_request(
GetLightStatusRequest(
api_version=self.default_api_version, light_id=light_id
)
)
return GetLightStatusResponse.decode(bytes_data).data
async def set_automatic_intensity_mode(self, light_id: str, enabled: bool) -> None:
"""Enable the automatic light intensity control."""
await self.vapix.api_request(
SetAutomaticIntensityModeRequest(
api_version=self.default_api_version,
light_id=light_id,
enabled=enabled,
)
)
async def get_valid_intensity(self, light_id: str) -> Range:
"""Get valid intensity range for light."""
bytes_data = await self.vapix.api_request(
GetValidIntensityRequest(
api_version=self.default_api_version, light_id=light_id
)
)
return GetValidIntensityResponse.decode(bytes_data).data
async def set_manual_intensity(self, light_id: str, intensity: int) -> None:
"""Manually sets the intensity."""
await self.vapix.api_request(
SetManualIntensityRequest(
api_version=self.default_api_version,
light_id=light_id,
intensity=intensity,
)
)
async def get_manual_intensity(self, light_id: str) -> int:
"""Enable the automatic light intensity control."""
bytes_data = await self.vapix.api_request(
GetManualIntensityRequest(
api_version=self.default_api_version, light_id=light_id
)
)
return GetManualIntensityResponse.decode(bytes_data).data
async def set_individual_intensity(
self, light_id: str, led_id: int, intensity: int
) -> None:
"""Manually sets the intensity for an individual LED."""
await self.vapix.api_request(
SetIndividualIntensityRequest(
api_version=self.default_api_version,
light_id=light_id,
led_id=led_id,
intensity=intensity,
)
)
async def get_individual_intensity(self, light_id: str, led_id: int) -> int:
"""Receives the intensity from the setIndividualIntensity request."""
bytes_data = await self.vapix.api_request(
GetIndividualIntensityRequest(
api_version=self.default_api_version,
light_id=light_id,
led_id=led_id,
)
)
return GetIndividualIntensityResponse.decode(bytes_data).data
async def get_current_intensity(self, light_id: str) -> int:
"""Receives the intensity from the setIndividualIntensity request."""
bytes_data = await self.vapix.api_request(
GetCurrentIntensityRequest(
api_version=self.default_api_version, light_id=light_id
)
)
return GetCurrentIntensityResponse.decode(bytes_data).data
async def set_automatic_angle_of_illumination_mode(
self, light_id: str, enabled: bool
) -> None:
"""Automatically control the angle of illumination.
Using this mode means that the angle of illumination
is the same as the camera's angle of view.
"""
await self.vapix.api_request(
SetAutomaticAngleOfIlluminationModeRequest(
api_version=self.default_api_version, light_id=light_id, enabled=enabled
)
)
async def get_valid_angle_of_illumination(self, light_id: str) -> list[Range]:
"""List the valid angle of illumination values."""
bytes_data = await self.vapix.api_request(
GetValidAngleOfIlluminationRequest(
api_version=self.default_api_version, light_id=light_id
)
)
return GetValidAngleOfIlluminationResponse.decode(bytes_data).data
async def set_manual_angle_of_illumination(
self, light_id: str, angle_of_illumination: int
) -> None:
"""Set the manual angle of illumination.
This is useful when the angle of illumination needs
to be different from the camera's view angle.
"""
await self.vapix.api_request(
SetManualAngleOfIlluminationModeRequest(
api_version=self.default_api_version,
light_id=light_id,
angle_of_illumination=angle_of_illumination,
)
)
async def get_manual_angle_of_illumination(self, light_id: str) -> int:
"""Get the angle of illumination."""
bytes_data = await self.vapix.api_request(
GetManualAngleOfIlluminationRequest(
api_version=self.default_api_version, light_id=light_id
)
)
return GetManualAngleOfIlluminationResponse.decode(bytes_data).data
async def get_current_angle_of_illumination(self, light_id: str) -> int:
"""Receive the current angle of illumination."""
bytes_data = await self.vapix.api_request(
GetCurrentAngleOfIlluminationRequest(
api_version=self.default_api_version, light_id=light_id
)
)
return GetCurrentAngleOfIlluminationResponse.decode(bytes_data).data
async def set_light_synchronization_day_night_mode(
self, light_id: str, enabled: bool
) -> None:
"""Enable automatic synchronization with the day/night mode."""
await self.vapix.api_request(
SetLightSynchronizeDayNightModeRequest(
api_version=self.default_api_version, light_id=light_id, enabled=enabled
)
)
async def get_light_synchronization_day_night_mode(self, light_id: str) -> bool:
"""Check if the automatic synchronization is enabled with the day/night mode."""
bytes_data = await self.vapix.api_request(
GetLightSynchronizeDayNightModeRequest(
api_version=self.default_api_version, light_id=light_id
)
)
return GetLightSynchronizeDayNightModeResponse.decode(bytes_data).data
async def get_supported_versions(self) -> list[str]:
"""List supported API versions."""
bytes_data = await self.vapix.api_request(GetSupportedVersionsRequest())
return GetSupportedVersionsResponse.decode(bytes_data).data
|
class LightHandler(ApiHandler[LightInformation]):
'''Light control for Axis devices.'''
@property
def listed_in_parameters(self) -> bool:
'''Is API listed in parameters.'''
pass
async def _api_request(self) -> dict[str, LightInformation]:
'''Get default data of stream profiles.'''
pass
async def get_light_information(self) -> dict[str, LightInformation]:
'''List the light control information.'''
pass
async def get_service_capabilities(self) -> ServiceCapabilities:
'''List the light control information.'''
pass
async def activate_light(self, light_id: str) -> None:
'''Activate the light.'''
pass
async def deactivate_light(self, light_id: str) -> None:
'''Deactivate the light.'''
pass
async def enable_light(self, light_id: str) -> None:
'''Activate the light.'''
pass
async def disable_light(self, light_id: str) -> None:
'''Deactivate the light.'''
pass
async def get_light_status(self, light_id: str) -> bool:
'''Get light status if its on or off.'''
pass
async def set_automatic_intensity_mode(self, light_id: str, enabled: bool) -> None:
'''Enable the automatic light intensity control.'''
pass
async def get_valid_intensity(self, light_id: str) -> Range:
'''Get valid intensity range for light.'''
pass
async def set_manual_intensity(self, light_id: str, intensity: int) -> None:
'''Manually sets the intensity.'''
pass
async def get_manual_intensity(self, light_id: str) -> int:
'''Enable the automatic light intensity control.'''
pass
async def set_individual_intensity(
self, light_id: str, led_id: int, intensity: int
) -> None:
'''Manually sets the intensity for an individual LED.'''
pass
async def get_individual_intensity(self, light_id: str, led_id: int) -> int:
'''Receives the intensity from the setIndividualIntensity request.'''
pass
async def get_current_intensity(self, light_id: str) -> int:
'''Receives the intensity from the setIndividualIntensity request.'''
pass
async def set_automatic_angle_of_illumination_mode(
self, light_id: str, enabled: bool
) -> None:
'''Automatically control the angle of illumination.
Using this mode means that the angle of illumination
is the same as the camera's angle of view.
'''
pass
async def get_valid_angle_of_illumination(self, light_id: str) -> list[Range]:
'''List the valid angle of illumination values.'''
pass
async def set_manual_angle_of_illumination(
self, light_id: str, angle_of_illumination: int
) -> None:
'''Set the manual angle of illumination.
This is useful when the angle of illumination needs
to be different from the camera's view angle.
'''
pass
async def get_manual_angle_of_illumination(self, light_id: str) -> int:
'''Get the angle of illumination.'''
pass
async def get_current_angle_of_illumination(self, light_id: str) -> int:
'''Receive the current angle of illumination.'''
pass
async def set_light_synchronization_day_night_mode(
self, light_id: str, enabled: bool
) -> None:
'''Enable automatic synchronization with the day/night mode.'''
pass
async def get_light_synchronization_day_night_mode(self, light_id: str) -> bool:
'''Check if the automatic synchronization is enabled with the day/night mode.'''
pass
async def get_supported_versions(self) -> list[str]:
'''List supported API versions.'''
pass
| 26 | 25 | 8 | 0 | 7 | 1 | 1 | 0.19 | 1 | 42 | 37 | 0 | 24 | 0 | 24 | 45 | 219 | 27 | 161 | 49 | 127 | 31 | 65 | 39 | 40 | 2 | 2 | 1 | 25 |
141,509 |
Kane610/axis
|
axis/interfaces/event_manager.py
|
axis.interfaces.event_manager.EventManager
|
class EventManager:
"""Initialize new events and update states of existing events."""
def __init__(self) -> None:
"""Ready information about events."""
self._known_topics: set[str] = set()
self._subscribers: dict[str, list[SubscriptionType]] = {ID_FILTER_ALL: []}
def handler(self, data: bytes | dict[str, Any]) -> None:
"""Create event and pass it along to subscribers."""
event = Event.decode(data)
if LOGGER.isEnabledFor(logging.DEBUG):
LOGGER.debug(event)
if event.topic_base == EventTopic.UNKNOWN or event.topic in BLACK_LISTED_TOPICS:
return
known = (unique_topic := f"{event.topic}_{event.id}") not in self._known_topics
self._known_topics.add(unique_topic)
if event.operation == EventOperation.UNKNOWN:
# MQTT events does not report operation
event.operation = (
EventOperation.INITIALIZED if known else EventOperation.CHANGED
)
subscribers: list[SubscriptionType] = (
self._subscribers.get(event.id, []) + self._subscribers[ID_FILTER_ALL]
)
for callback, topic_filter, operation_filter in subscribers:
if topic_filter is not None and event.topic_base not in topic_filter:
continue
if operation_filter is not None and event.operation not in operation_filter:
continue
callback(event)
def subscribe(
self,
callback: SubscriptionCallback,
id_filter: tuple[str] | str | None = None,
topic_filter: tuple[EventTopic, ...] | EventTopic | None = None,
operation_filter: tuple[EventOperation, ...] | EventOperation | None = None,
) -> UnsubscribeType:
"""Subscribe to events.
"callback" - callback function to call when on event.
Return function to unsubscribe.
"""
if isinstance(topic_filter, EventTopic):
topic_filter = (topic_filter,)
if isinstance(operation_filter, EventOperation):
operation_filter = (operation_filter,)
subscription = (callback, topic_filter, operation_filter)
_id_filter: tuple[str]
if id_filter is None:
_id_filter = (ID_FILTER_ALL,)
elif isinstance(id_filter, str):
_id_filter = (id_filter,)
else:
_id_filter = id_filter
for obj_id in _id_filter:
if obj_id not in self._subscribers:
self._subscribers[obj_id] = []
self._subscribers[obj_id].append(subscription)
def unsubscribe() -> None:
for obj_id in _id_filter:
if obj_id not in self._subscribers:
continue
if subscription not in self._subscribers[obj_id]:
continue
self._subscribers[obj_id].remove(subscription)
return unsubscribe
def __len__(self) -> int:
"""List number of subscribers."""
return sum(len(s) for s in self._subscribers.values())
|
class EventManager:
'''Initialize new events and update states of existing events.'''
def __init__(self) -> None:
'''Ready information about events.'''
pass
def handler(self, data: bytes | dict[str, Any]) -> None:
'''Create event and pass it along to subscribers.'''
pass
def subscribe(
self,
callback: SubscriptionCallback,
id_filter: tuple[str] | str | None = None,
topic_filter: tuple[EventTopic, ...] | EventTopic | None = None,
operation_filter: tuple[EventOperation, ...] | EventOperation | None = None,
) -> UnsubscribeType:
'''Subscribe to events.
"callback" - callback function to call when on event.
Return function to unsubscribe.
'''
pass
def unsubscribe() -> None:
pass
def __len__(self) -> int:
'''List number of subscribers.'''
pass
| 6 | 5 | 16 | 2 | 13 | 2 | 4 | 0.16 | 0 | 11 | 3 | 0 | 4 | 2 | 4 | 4 | 80 | 13 | 58 | 21 | 46 | 9 | 46 | 15 | 40 | 8 | 0 | 2 | 21 |
141,510 |
Kane610/axis
|
axis/interfaces/event_instances.py
|
axis.interfaces.event_instances.EventInstanceHandler
|
class EventInstanceHandler(ApiHandler[Any]):
"""Event instances for Axis devices."""
async def _api_request(self) -> dict[str, Any]:
"""Get default data of API discovery."""
return await self.get_event_instances()
async def get_event_instances(self) -> dict[str, Any]:
"""List all event instances."""
bytes_data = await self.vapix.api_request(ListEventInstancesRequest())
response = ListEventInstancesResponse.decode(bytes_data)
return response.data
|
class EventInstanceHandler(ApiHandler[Any]):
'''Event instances for Axis devices.'''
async def _api_request(self) -> dict[str, Any]:
'''Get default data of API discovery.'''
pass
async def get_event_instances(self) -> dict[str, Any]:
'''List all event instances.'''
pass
| 3 | 3 | 4 | 0 | 3 | 1 | 1 | 0.43 | 1 | 5 | 2 | 0 | 2 | 0 | 2 | 23 | 12 | 2 | 7 | 5 | 4 | 3 | 7 | 5 | 4 | 1 | 2 | 0 | 2 |
141,511 |
Kane610/axis
|
axis/interfaces/basic_device_info.py
|
axis.interfaces.basic_device_info.BasicDeviceInfoHandler
|
class BasicDeviceInfoHandler(ApiHandler[DeviceInformation]):
"""Basic device information for Axis devices."""
api_id = ApiId.BASIC_DEVICE_INFO
default_api_version = API_VERSION
async def _api_request(self) -> dict[str, DeviceInformation]:
"""Get default data of basic device information."""
return await self.get_all_properties()
async def get_all_properties(self) -> dict[str, DeviceInformation]:
"""List all properties of basic device info."""
discovery_item = self.vapix.api_discovery[self.api_id]
bytes_data = await self.vapix.api_request(
GetAllPropertiesRequest(discovery_item.version)
)
response = GetAllPropertiesResponse.decode(bytes_data)
return {"0": response.data}
async def get_supported_versions(self) -> list[str]:
"""List supported API versions."""
bytes_data = await self.vapix.api_request(GetSupportedVersionsRequest())
response = GetSupportedVersionsResponse.decode(bytes_data)
return response.data
|
class BasicDeviceInfoHandler(ApiHandler[DeviceInformation]):
'''Basic device information for Axis devices.'''
async def _api_request(self) -> dict[str, DeviceInformation]:
'''Get default data of basic device information.'''
pass
async def get_all_properties(self) -> dict[str, DeviceInformation]:
'''List all properties of basic device info.'''
pass
async def get_supported_versions(self) -> list[str]:
'''List supported API versions.'''
pass
| 4 | 4 | 5 | 0 | 4 | 1 | 1 | 0.25 | 1 | 8 | 5 | 0 | 3 | 0 | 3 | 24 | 24 | 4 | 16 | 11 | 12 | 4 | 14 | 11 | 10 | 1 | 2 | 0 | 3 |
141,512 |
Kane610/axis
|
axis/models/port_management.py
|
axis.models.port_management.SetStateSequenceRequest
|
class SetStateSequenceRequest(ApiRequest):
"""Request object for configuring port sequence."""
method = "post"
path = "/axis-cgi/io/portmanagement.cgi"
content_type = "application/json"
error_codes = error_codes
port: str
sequence: list[Sequence]
api_version: str = API_VERSION
context: str = CONTEXT
@property
def content(self) -> bytes:
"""Initialize request data."""
sequence = [item.to_dict() for item in self.sequence]
return orjson.dumps(
{
"apiVersion": self.api_version,
"context": self.context,
"method": "setStateSequence",
"params": {"port": self.port, "sequence": sequence},
}
)
|
class SetStateSequenceRequest(ApiRequest):
'''Request object for configuring port sequence.'''
@property
def content(self) -> bytes:
'''Initialize request data.'''
pass
| 3 | 2 | 11 | 0 | 10 | 1 | 1 | 0.1 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 5 | 26 | 4 | 20 | 10 | 17 | 2 | 12 | 9 | 10 | 1 | 1 | 0 | 1 |
141,513 |
Kane610/axis
|
axis/models/port_management.py
|
axis.models.port_management.SetPortsRequest
|
class SetPortsRequest(ApiRequest):
"""Request object for configuring ports."""
method = "post"
path = "/axis-cgi/io/portmanagement.cgi"
content_type = "application/json"
error_codes = error_codes
port_config: list[PortConfiguration] | PortConfiguration
api_version: str = API_VERSION
context: str = CONTEXT
@property
def content(self) -> bytes:
"""Initialize request data."""
if not isinstance(self.port_config, list):
self.port_config = [self.port_config]
ports: list[dict[str, str]] = [port.to_dict() for port in self.port_config]
return orjson.dumps(
{
"apiVersion": self.api_version,
"context": self.context,
"method": "setPorts",
"params": {"ports": ports},
}
)
|
class SetPortsRequest(ApiRequest):
'''Request object for configuring ports.'''
@property
def content(self) -> bytes:
'''Initialize request data.'''
pass
| 3 | 2 | 13 | 0 | 12 | 1 | 2 | 0.1 | 1 | 4 | 0 | 0 | 1 | 0 | 1 | 5 | 27 | 4 | 21 | 10 | 18 | 2 | 13 | 9 | 11 | 2 | 1 | 1 | 2 |
141,514 |
Kane610/axis
|
axis/models/port_management.py
|
axis.models.port_management.SequenceT
|
class SequenceT(TypedDict):
"""Port sequence representation."""
state: Literal["open", "closed"]
time: int
|
class SequenceT(TypedDict):
'''Port sequence representation.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.33 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 | 1 | 3 | 1 | 2 | 1 | 3 | 1 | 2 | 0 | 1 | 0 | 0 |
141,515 |
Kane610/axis
|
axis/models/port_management.py
|
axis.models.port_management.Sequence
|
class Sequence:
"""Sequence class."""
state: Literal["open", "closed"]
time: int
def to_dict(self) -> SequenceT:
"""Convert to dictionary."""
return {"state": self.state, "time": self.time}
|
class Sequence:
'''Sequence class.'''
def to_dict(self) -> SequenceT:
'''Convert to dictionary.'''
pass
| 2 | 2 | 3 | 0 | 2 | 1 | 1 | 0.4 | 0 | 1 | 1 | 0 | 1 | 0 | 1 | 1 | 9 | 2 | 5 | 2 | 3 | 2 | 5 | 2 | 3 | 1 | 0 | 0 | 1 |
141,516 |
Kane610/axis
|
axis/models/parameters/param_cgi.py
|
axis.models.parameters.param_cgi.ParamRequest
|
class ParamRequest(ApiRequest):
"""Request object for listing parameters."""
method = "post"
path = "/axis-cgi/param.cgi"
content_type = "text/plain"
group: ParameterGroup | None = None
@property
def data(self) -> dict[str, str]:
"""Request query parameters."""
query = {"action": "list"}
if self.group:
query["group"] = f"root.{self.group}"
return query
|
class ParamRequest(ApiRequest):
'''Request object for listing parameters.'''
@property
def data(self) -> dict[str, str]:
'''Request query parameters.'''
pass
| 3 | 2 | 6 | 0 | 5 | 1 | 2 | 0.18 | 1 | 2 | 0 | 0 | 1 | 0 | 1 | 5 | 16 | 3 | 11 | 8 | 8 | 2 | 10 | 7 | 8 | 2 | 1 | 1 | 2 |
141,517 |
Kane610/axis
|
axis/models/parameters/param_cgi.py
|
axis.models.parameters.param_cgi.ParameterGroup
|
class ParameterGroup(enum.StrEnum):
"""Parameter groups."""
AUDIO = "Audio"
AUDIOSOURCE = "AudioSource"
BANDWIDTH = "Bandwidth"
BASICDEVICEINFO = "BasicDeviceInfo"
BRAND = "Brand"
HTTPS = "HTTPS"
IMAGE = "Image"
IMAGESOURCE = "ImageSource"
INPUT = "Input"
IOPORT = "IOPort"
LAYOUT = "Layout"
MEDIACLIP = "MediaClip"
NETWORK = "Network"
OUTPUT = "Output"
PROPERTIES = "Properties"
PTZ = "PTZ"
RECORDING = "Recording"
REMOTESERVICE = "RemoteService"
SNMP = "SNMP"
SOCKS = "SOCKS"
STORAGE = "Storage"
STREAMCACHE = "StreamCache"
STREAMPROFILE = "StreamProfile"
SYSTEM = "System"
TAMPERING = "Tampering"
TEMPERATURECONTROL = "TemperatureControl"
TIME = "Time"
WEBSERVICE = "WebService"
UNKNOWN = "unknown"
@classmethod
def _missing_(cls, value: object) -> "ParameterGroup":
"""Set default enum member if an unknown value is provided."""
LOGGER.warning("Unsupported parameter group %s", value)
return ParameterGroup.UNKNOWN
|
class ParameterGroup(enum.StrEnum):
'''Parameter groups.'''
@classmethod
def _missing_(cls, value: object) -> "ParameterGroup":
'''Set default enum member if an unknown value is provided.'''
pass
| 3 | 2 | 4 | 0 | 3 | 1 | 1 | 0.06 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 69 | 39 | 3 | 34 | 32 | 31 | 2 | 33 | 31 | 31 | 1 | 3 | 0 | 1 |
141,518 |
Kane610/axis
|
axis/models/parameters/properties.py
|
axis.models.parameters.properties.PropertyApiHttpParamT
|
class PropertyApiHttpParamT(TypedDict):
"""Represent an API HTTP object."""
AdminPath: str
Version: int
|
class PropertyApiHttpParamT(TypedDict):
'''Represent an API HTTP object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.33 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 | 1 | 3 | 1 | 2 | 1 | 3 | 1 | 2 | 0 | 1 | 0 | 0 |
141,519 |
Kane610/axis
|
axis/models/parameters/properties.py
|
axis.models.parameters.properties.PropertyApiMetadataParamT
|
class PropertyApiMetadataParamT(TypedDict):
"""Represent an API Metadata object."""
Metadata: str
Version: str
|
class PropertyApiMetadataParamT(TypedDict):
'''Represent an API Metadata object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.33 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 | 1 | 3 | 1 | 2 | 1 | 3 | 1 | 2 | 0 | 1 | 0 | 0 |
141,520 |
Kane610/axis
|
axis/models/parameters/properties.py
|
axis.models.parameters.properties.PropertyApiParamT
|
class PropertyApiParamT(TypedDict):
"""Represent an API object."""
HTTP: PropertyApiHttpParamT
Metadata: PropertyApiMetadataParamT
PTZ: NotRequired[PropertyApiPtzParamT]
|
class PropertyApiParamT(TypedDict):
'''Represent an API object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.25 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 6 | 1 | 4 | 1 | 3 | 1 | 4 | 1 | 3 | 0 | 1 | 0 | 0 |
141,521 |
Kane610/axis
|
axis/models/parameters/properties.py
|
axis.models.parameters.properties.PropertyApiPtzParamT
|
class PropertyApiPtzParamT(TypedDict):
"""Represent an API PTZ object."""
Presets: PropertyApiPtzPresetsParamT
|
class PropertyApiPtzParamT(TypedDict):
'''Represent an API PTZ object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 1 | 2 | 1 | 1 | 1 | 2 | 1 | 1 | 0 | 1 | 0 | 0 |
141,522 |
Kane610/axis
|
axis/models/parameters/properties.py
|
axis.models.parameters.properties.PropertyApiPtzPresetsParamT
|
class PropertyApiPtzPresetsParamT(TypedDict):
"""Represent a PTZ preset object."""
Version: NotRequired[str]
|
class PropertyApiPtzPresetsParamT(TypedDict):
'''Represent a PTZ preset object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 1 | 2 | 1 | 1 | 1 | 2 | 1 | 1 | 0 | 1 | 0 | 0 |
141,523 |
Kane610/axis
|
axis/models/parameters/param_cgi.py
|
axis.models.parameters.param_cgi.ParamItem
|
class ParamItem(ApiItem):
"""Parameter item."""
@classmethod
def decode_to_dict(cls, data: list[Any]) -> dict[str, Self]:
"""Create objects from dict."""
return {"0": cls.decode(data[0])}
|
class ParamItem(ApiItem):
'''Parameter item.'''
@classmethod
def decode_to_dict(cls, data: list[Any]) -> dict[str, Self]:
'''Create objects from dict.'''
pass
| 3 | 2 | 3 | 0 | 2 | 1 | 1 | 0.5 | 1 | 4 | 0 | 6 | 0 | 0 | 1 | 24 | 7 | 1 | 4 | 3 | 1 | 2 | 3 | 2 | 1 | 1 | 5 | 0 | 1 |
141,524 |
Kane610/axis
|
axis/models/parameters/properties.py
|
axis.models.parameters.properties.PropertyEmbeddedDevelopmentParamT
|
class PropertyEmbeddedDevelopmentParamT(TypedDict):
"""Represent an embedded development object."""
CacheSize: int
DefaultCacheSize: int
EmbeddedDevelopment: bool
Version: str
RuleEngine: PropertyEmbeddedDevelopmentRuleEngineParamT
|
class PropertyEmbeddedDevelopmentParamT(TypedDict):
'''Represent an embedded development object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.17 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 8 | 1 | 6 | 1 | 5 | 1 | 6 | 1 | 5 | 0 | 1 | 0 | 0 |
141,525 |
Kane610/axis
|
axis/models/parameters/properties.py
|
axis.models.parameters.properties.PropertyFirmwareParamT
|
class PropertyFirmwareParamT(TypedDict):
"""Represent a firmware object."""
BuildDate: str
BuildNumber: str
Version: str
|
class PropertyFirmwareParamT(TypedDict):
'''Represent a firmware object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.25 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 6 | 1 | 4 | 1 | 3 | 1 | 4 | 1 | 3 | 0 | 1 | 0 | 0 |
141,526 |
Kane610/axis
|
axis/models/parameters/properties.py
|
axis.models.parameters.properties.PropertyImageParamT
|
class PropertyImageParamT(TypedDict):
"""Represent an image object."""
Format: NotRequired[str]
NbrOfViews: int
Resolution: str
Rotation: str
ShowSuboptimalResolutions: bool
|
class PropertyImageParamT(TypedDict):
'''Represent an image object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.17 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 8 | 1 | 6 | 1 | 5 | 1 | 6 | 1 | 5 | 0 | 1 | 0 | 0 |
141,527 |
Kane610/axis
|
axis/models/parameters/properties.py
|
axis.models.parameters.properties.PropertyLightControlParamT
|
class PropertyLightControlParamT(TypedDict):
"""Represent a light control object."""
LightControl2: NotRequired[bool]
LightControlAvailable: bool
|
class PropertyLightControlParamT(TypedDict):
'''Represent a light control object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.33 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 | 1 | 3 | 1 | 2 | 1 | 3 | 1 | 2 | 0 | 1 | 0 | 0 |
141,528 |
Kane610/axis
|
axis/models/parameters/properties.py
|
axis.models.parameters.properties.PropertyParamT
|
class PropertyParamT(TypedDict):
"""Represent a property object."""
API: PropertyApiParamT
EmbeddedDevelopment: NotRequired[PropertyEmbeddedDevelopmentParamT]
Firmware: PropertyFirmwareParamT
Image: NotRequired[PropertyImageParamT]
LightControl: NotRequired[PropertyLightControlParamT]
PTZ: NotRequired[PropertyPtzParamT]
System: PropertySystemParamT
|
class PropertyParamT(TypedDict):
'''Represent a property object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.13 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 1 | 8 | 1 | 7 | 1 | 8 | 1 | 7 | 0 | 1 | 0 | 0 |
141,529 |
Kane610/axis
|
axis/models/parameters/properties.py
|
axis.models.parameters.properties.PropertyPtzParamT
|
class PropertyPtzParamT(TypedDict):
"""Represent a PTZ object."""
DigitalPTZ: bool
DriverManagement: bool
DriverModeList: str
PTZ: bool
PTZOnQuadView: bool
SelectableDriverMode: bool
|
class PropertyPtzParamT(TypedDict):
'''Represent a PTZ object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.14 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 9 | 1 | 7 | 1 | 6 | 1 | 7 | 1 | 6 | 0 | 1 | 0 | 0 |
141,530 |
Kane610/axis
|
axis/models/parameters/properties.py
|
axis.models.parameters.properties.PropertySystemParamT
|
class PropertySystemParamT(TypedDict):
"""Represent a system object."""
Architecture: str
HardwareID: str
Language: str
LanguageType: str
SerialNumber: str
Soc: str
|
class PropertySystemParamT(TypedDict):
'''Represent a system object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.14 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 9 | 1 | 7 | 1 | 6 | 1 | 7 | 1 | 6 | 0 | 1 | 0 | 0 |
141,531 |
Kane610/axis
|
axis/models/parameters/ptz.py
|
axis.models.parameters.ptz.PresetPositionT
|
class PresetPositionT(TypedDict):
"""PTZ preset position data description."""
data: tuple[float, float, float]
name: str | None
|
class PresetPositionT(TypedDict):
'''PTZ preset position data description.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.33 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 | 1 | 3 | 1 | 2 | 1 | 3 | 1 | 2 | 0 | 1 | 0 | 0 |
141,532 |
Kane610/axis
|
axis/models/parameters/properties.py
|
axis.models.parameters.properties.PropertyEmbeddedDevelopmentRuleEngineParamT
|
class PropertyEmbeddedDevelopmentRuleEngineParamT(TypedDict):
"""Represent an embedded development rule engine object."""
MultiConfiguration: bool
|
class PropertyEmbeddedDevelopmentRuleEngineParamT(TypedDict):
'''Represent an embedded development rule engine object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 1 | 2 | 1 | 1 | 1 | 2 | 1 | 1 | 0 | 1 | 0 | 0 |
141,533 |
Kane610/axis
|
axis/models/parameters/io_port.py
|
axis.models.parameters.io_port.PortParamT
|
class PortParamT(TypedDict):
"""Port representation."""
Configurable: NotRequired[bool]
Direction: str
Usage: str
Input: NotRequired[PortInputParamT]
Output: NotRequired[PortOutputParamT]
|
class PortParamT(TypedDict):
'''Port representation.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.17 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 8 | 1 | 6 | 1 | 5 | 1 | 6 | 1 | 5 | 0 | 1 | 0 | 0 |
141,534 |
Kane610/axis
|
axis/models/parameters/io_port.py
|
axis.models.parameters.io_port.PortOutputParamT
|
class PortOutputParamT(TypedDict):
"""Output port representation."""
Active: str
Button: str
DelayTime: str
Mode: str
Name: str
PulseTime: str
|
class PortOutputParamT(TypedDict):
'''Output port representation.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.14 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 9 | 1 | 7 | 1 | 6 | 1 | 7 | 1 | 6 | 0 | 1 | 0 | 0 |
141,535 |
Kane610/axis
|
axis/models/parameters/io_port.py
|
axis.models.parameters.io_port.PortInputParamT
|
class PortInputParamT(TypedDict):
"""Input port representation."""
Name: str
Trig: str
|
class PortInputParamT(TypedDict):
'''Input port representation.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.33 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 | 1 | 3 | 1 | 2 | 1 | 3 | 1 | 2 | 0 | 1 | 0 | 0 |
141,536 |
Kane610/axis
|
axis/models/parameters/brand.py
|
axis.models.parameters.brand.BrandParam
|
class BrandParam(ParamItem):
"""Brand parameters."""
brand: str
"""Device branding."""
product_full_name: str
"""Device product full name."""
product_number: str
"""Device product number."""
product_short_name: str
"""Device product short name."""
product_type: str
"""Device product type."""
product_variant: str
"""Device product variant."""
web_url: str
"""Device home page URL."""
@classmethod
def decode(cls, data: BrandT) -> Self:
"""Decode dictionary to class object."""
return cls(
id="brand",
brand=data["Brand"],
product_full_name=data["ProdFullName"],
product_number=data["ProdNbr"],
product_short_name=data["ProdShortName"],
product_type=data["ProdType"],
product_variant=data.get("ProdVariant", ""),
web_url=data["WebURL"],
)
|
class BrandParam(ParamItem):
'''Brand parameters.'''
@classmethod
def decode(cls, data: BrandT) -> Self:
'''Decode dictionary to class object.'''
pass
| 3 | 2 | 12 | 0 | 11 | 1 | 1 | 0.45 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 25 | 37 | 8 | 20 | 3 | 17 | 9 | 10 | 2 | 8 | 1 | 6 | 0 | 1 |
141,537 |
Kane610/axis
|
axis/models/parameters/brand.py
|
axis.models.parameters.brand.BrandT
|
class BrandT(TypedDict):
"""Represent a brand object."""
Brand: str
ProdFullName: str
ProdNbr: str
ProdShortName: str
ProdType: str
ProdVariant: NotRequired[str]
WebURL: str
|
class BrandT(TypedDict):
'''Represent a brand object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.13 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 1 | 8 | 1 | 7 | 1 | 8 | 1 | 7 | 0 | 1 | 0 | 0 |
141,538 |
Kane610/axis
|
axis/models/parameters/image.py
|
axis.models.parameters.image.ImageAppearanceParamT
|
class ImageAppearanceParamT(TypedDict):
"""Represent an appearance object."""
ColorEnabled: str
Compression: str
MirrorEnabled: str
Resolution: str
Rotation: str
|
class ImageAppearanceParamT(TypedDict):
'''Represent an appearance object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.17 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 8 | 1 | 6 | 1 | 5 | 1 | 6 | 1 | 5 | 0 | 1 | 0 | 0 |
141,539 |
Kane610/axis
|
axis/models/parameters/image.py
|
axis.models.parameters.image.ImageMpegH264ParamT
|
class ImageMpegH264ParamT(TypedDict):
"""Represent an MPEG H264 object."""
Profile: str
PSEnabled: str
|
class ImageMpegH264ParamT(TypedDict):
'''Represent an MPEG H264 object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.33 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 | 1 | 3 | 1 | 2 | 1 | 3 | 1 | 2 | 0 | 1 | 0 | 0 |
141,540 |
Kane610/axis
|
axis/models/parameters/image.py
|
axis.models.parameters.image.ImageMpegParamT
|
class ImageMpegParamT(TypedDict):
"""Represent an MPEG object."""
Complexity: str
ConfigHeaderInterval: str
FrameSkipMode: str
ICount: str
PCount: str
UserDataEnabled: str
UserDataInterval: str
ZChromaQPMode: str
ZFpsMode: str
ZGopMode: str
ZMaxGopLength: str
ZMinFps: str
ZStrength: str
H264: ImageMpegH264ParamT
|
class ImageMpegParamT(TypedDict):
'''Represent an MPEG object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.07 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 17 | 1 | 15 | 1 | 14 | 1 | 15 | 1 | 14 | 0 | 1 | 0 | 0 |
141,541 |
Kane610/axis
|
axis/models/parameters/image.py
|
axis.models.parameters.image.ImageOverlayMaskWindowsParamT
|
class ImageOverlayMaskWindowsParamT(TypedDict):
"""Represent an mask windows object."""
Color: str
|
class ImageOverlayMaskWindowsParamT(TypedDict):
'''Represent an mask windows object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 1 | 2 | 1 | 1 | 1 | 2 | 1 | 1 | 0 | 1 | 0 | 0 |
141,542 |
Kane610/axis
|
axis/models/parameters/image.py
|
axis.models.parameters.image.ImageOverlayParamT
|
class ImageOverlayParamT(TypedDict):
"""Represent an overlay object."""
Enabled: str
XPos: str
YPos: str
MaskWindows: ImageOverlayMaskWindowsParamT
|
class ImageOverlayParamT(TypedDict):
'''Represent an overlay object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 7 | 1 | 5 | 1 | 4 | 1 | 5 | 1 | 4 | 0 | 1 | 0 | 0 |
141,543 |
Kane610/axis
|
axis/models/parameters/image.py
|
axis.models.parameters.image.ImageParam
|
class ImageParam(ParamItem):
"""Image parameters."""
enabled: str
name: str
source: str | None
appearance: ImageAppearanceParamT
mpeg: ImageMpegParamT | None
overlay: ImageOverlayParamT | None
rate_control: ImageRateControlParamT | None
size_control: ImageSizeControlParamT | None
stream: ImageStreamParamT
text: ImageTextParamT | None
trigger_data: ImageTriggerDataParamT | None
@classmethod
def decode(cls, data: tuple[str, ImageParamT]) -> Self:
"""Decode dictionary to class object."""
id, raw = data
return cls(
id=id,
enabled=raw.get("Enabled", "yes"),
name=raw["Name"],
source=raw.get("Source"),
appearance=raw["Appearance"],
mpeg=raw.get("MPEG"),
overlay=raw.get("Overlay"),
rate_control=raw.get("RateControl"),
size_control=raw.get("SizeControl"),
stream=raw["Stream"],
text=raw.get("Text"),
trigger_data=raw.get("TriggerData"),
)
@classmethod
def decode_to_dict(cls, data: list[Any]) -> dict[str, Self]:
"""Create objects from dict."""
image_data = [ # Rename channels I0-I19 to 0-19
(str(id), data[0][channel_id])
for id in range(20)
if (channel_id := f"I{id}") in data[0]
]
return {v.id: v for v in cls.decode_to_list(image_data)}
|
class ImageParam(ParamItem):
'''Image parameters.'''
@classmethod
def decode(cls, data: tuple[str, ImageParamT]) -> Self:
'''Decode dictionary to class object.'''
pass
@classmethod
def decode_to_dict(cls, data: list[Any]) -> dict[str, Self]:
'''Create objects from dict.'''
pass
| 5 | 3 | 13 | 0 | 12 | 2 | 1 | 0.11 | 1 | 7 | 1 | 0 | 0 | 0 | 2 | 26 | 43 | 3 | 37 | 8 | 32 | 4 | 18 | 5 | 15 | 1 | 6 | 0 | 2 |
141,544 |
Kane610/axis
|
axis/models/parameters/image.py
|
axis.models.parameters.image.ImageParamT
|
class ImageParamT(TypedDict):
"""Represent an image object."""
Enabled: str
Name: str
Source: str
Appearance: ImageAppearanceParamT
MPEG: NotRequired[ImageMpegParamT]
Overlay: NotRequired[ImageOverlayParamT]
RateControl: NotRequired[ImageRateControlParamT]
SizeControl: NotRequired[ImageSizeControlParamT]
Stream: ImageStreamParamT
Text: NotRequired[ImageTextParamT]
TriggerData: NotRequired[ImageTriggerDataParamT]
|
class ImageParamT(TypedDict):
'''Represent an image object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.08 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 14 | 1 | 12 | 1 | 11 | 1 | 12 | 1 | 11 | 0 | 1 | 0 | 0 |
141,545 |
Kane610/axis
|
axis/models/parameters/image.py
|
axis.models.parameters.image.ImageRateControlParamT
|
class ImageRateControlParamT(TypedDict):
"""Represent an rate control object."""
MaxBitrate: str
Mode: str
Priority: str
TargetBitrate: str
|
class ImageRateControlParamT(TypedDict):
'''Represent an rate control object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 7 | 1 | 5 | 1 | 4 | 1 | 5 | 1 | 4 | 0 | 1 | 0 | 0 |
141,546 |
Kane610/axis
|
axis/models/parameters/image.py
|
axis.models.parameters.image.ImageSizeControlParamT
|
class ImageSizeControlParamT(TypedDict):
"""Represent an size control object."""
MaxFrameSize: str
|
class ImageSizeControlParamT(TypedDict):
'''Represent an size control object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 1 | 2 | 1 | 1 | 1 | 2 | 1 | 1 | 0 | 1 | 0 | 0 |
141,547 |
Kane610/axis
|
axis/models/parameters/image.py
|
axis.models.parameters.image.ImageStreamParamT
|
class ImageStreamParamT(TypedDict):
"""Represent a stream object."""
Duration: str
FPS: str
NbrOfFrames: str
|
class ImageStreamParamT(TypedDict):
'''Represent a stream object.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.25 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 6 | 1 | 4 | 1 | 3 | 1 | 4 | 1 | 3 | 0 | 1 | 0 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.