ActionStreamer 1.2.7__tar.gz → 1.2.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/PKG-INFO +1 -1
  2. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/Config/Config.py +63 -1
  3. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/Config/__init__.py +2 -2
  4. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/Model/Model.py +37 -1
  5. actionstreamer-1.2.8/actionstreamer/Model/__init__.py +4 -0
  6. actionstreamer-1.2.8/actionstreamer/WebService/EventPreset/EventPreset.py +83 -0
  7. actionstreamer-1.2.8/actionstreamer/WebService/EventPreset/__init__.py +4 -0
  8. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/WebService/File/File.py +1 -1
  9. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/pyproject.toml +1 -1
  10. actionstreamer-1.2.7/actionstreamer/Model/__init__.py +0 -4
  11. actionstreamer-1.2.7/actionstreamer/WebService/EventPreset/EventPreset.py +0 -35
  12. actionstreamer-1.2.7/actionstreamer/WebService/EventPreset/__init__.py +0 -4
  13. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/README.md +0 -0
  14. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/CommonFunctions/CommonFunctions.py +0 -0
  15. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/CommonFunctions/Wifi/Wifi.py +0 -0
  16. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/CommonFunctions/Wifi/__init__.py +0 -0
  17. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/CommonFunctions/__init__.py +0 -0
  18. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/Device/Device.py +0 -0
  19. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/Device/__init__.py +0 -0
  20. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/WebService/API/API.py +0 -0
  21. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/WebService/API/__init__.py +0 -0
  22. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/WebService/Event/Event.py +0 -0
  23. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/WebService/Event/__init__.py +0 -0
  24. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/WebService/File/__init__.py +0 -0
  25. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/WebService/Health/Health.py +0 -0
  26. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/WebService/Health/__init__.py +0 -0
  27. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/WebService/LogMessage/LogMessage.py +0 -0
  28. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/WebService/LogMessage/__init__.py +0 -0
  29. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/WebService/Patch/Patch.py +0 -0
  30. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/WebService/Patch/__init__.py +0 -0
  31. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/WebService/Tag/Tag.py +0 -0
  32. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/WebService/Tag/__init__.py +0 -0
  33. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/WebService/VideoClip/VideoClip.py +0 -0
  34. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/WebService/VideoClip/__init__.py +0 -0
  35. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/WebService/__init__.py +0 -0
  36. {actionstreamer-1.2.7 → actionstreamer-1.2.8}/actionstreamer/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: actionstreamer
3
- Version: 1.2.7
3
+ Version: 1.2.8
4
4
  Summary: A library for the ActionStreamer API.
5
5
  Author: ActionStreamer
6
6
  Author-email: joe@actionstreamer.com
@@ -1,3 +1,4 @@
1
+ import json
1
2
  import os
2
3
  import platform
3
4
 
@@ -128,4 +129,65 @@ def set_config_value(config_folder_path: str, name: str, value: str) -> bool:
128
129
 
129
130
  except Exception as ex:
130
131
  print(f"Error occurred while setting value in '{name}': {ex}")
131
- return False
132
+ return False
133
+
134
+
135
+ def load_json(file_path):
136
+ """Load JSON from file, creating an empty dict if the file doesn't exist."""
137
+ if not os.path.exists(file_path):
138
+ return {}
139
+ with open(file_path, "r", encoding="utf-8") as f:
140
+ try:
141
+ return json.load(f)
142
+ except json.JSONDecodeError:
143
+ return {}
144
+
145
+
146
+ def save_json(file_path, data):
147
+ """Save JSON to file, ensuring directories exist."""
148
+ os.makedirs(os.path.dirname(file_path), exist_ok=True)
149
+ with open(file_path, "w", encoding="utf-8") as f:
150
+ json.dump(data, f, indent=4)
151
+
152
+
153
+ def get_json_value(data, path):
154
+ """Retrieve a value from a nested dictionary using a dot-separated path."""
155
+ keys = path.split(".")
156
+ for key in keys:
157
+ if not isinstance(data, dict) or key not in data:
158
+ return None # Key path doesn't exist
159
+ data = data[key]
160
+ return data
161
+
162
+
163
+ def set_json_value(data, path, value):
164
+ """Set a value in a nested dictionary using a dot-separated path."""
165
+ keys = path.split(".")
166
+ d = data
167
+ for key in keys[:-1]:
168
+ if key not in d or not isinstance(d[key], dict):
169
+ d[key] = {} # Create nested dict if needed
170
+ d = d[key]
171
+ d[keys[-1]] = value # Set final value
172
+
173
+
174
+ def read_json_value(file_path, json_path):
175
+ """Read a value from a JSON file using a path."""
176
+ data = load_json(file_path)
177
+ return get_json_value(data, json_path)
178
+
179
+
180
+ def write_json_value(file_path, json_path, value):
181
+ """Write a value to a JSON file using a path."""
182
+ data = load_json(file_path)
183
+ set_json_value(data, json_path, value)
184
+ save_json(file_path, data)
185
+
186
+ # # Example usage
187
+ # config_path = "config.json"
188
+
189
+ # # Set a value
190
+ # write_value(config_path, "myroot.mychild.isenabled", True)
191
+
192
+ # # Get a value
193
+ # print(read_value(config_path, "myroot.mychild.isenabled")) # Output: True
@@ -1,4 +1,4 @@
1
- from .Config import WebServiceConfig, LogConfig, is_windows, get_config_folder_path, get_appdata_folder_path, get_config_value, set_config_value
1
+ from .Config import WebServiceConfig, LogConfig, is_windows, get_config_folder_path, get_appdata_folder_path, get_config_value, set_config_value, read_json_value, write_json_value
2
2
 
3
3
 
4
- __all__ = ['WebServiceConfig', 'LogConfig', 'is_windows', 'get_config_folder_path', 'get_appdata_folder_path', 'get_config_value', 'set_config_value']
4
+ __all__ = ['WebServiceConfig', 'LogConfig', 'is_windows', 'get_config_folder_path', 'get_appdata_folder_path', 'get_config_value', 'set_config_value', 'read_json_value', 'write_json_value']
@@ -436,7 +436,7 @@ class StandardResult:
436
436
 
437
437
  class DeviceObject:
438
438
 
439
- def __init__(self, key: int = 0, deviceTypeID: int = 0, userID: int = 0, deviceName: str = '', serialNumber: str = '', deviceDescription: str = '', recentOutput: str = '', cameraStatus: str = '', lastIPAddress: str = '', tunnelIPAddress: str = '', lastHeardFromDate: datetime = datetime.now(), softwareDate: datetime = datetime.now(), location: str = '', setupStatus: int = 0, autoSendFiles: int = 0, runStartupEvent: int = 0, deviceReadyEventPresetID: int = 0, standaloneEventPresetID: int = 0, logHealth: int = 0, audioChannelName: str = '', volume: int = 0, commentListID = 0, isArchived: bool = False, gUID: str = '', creationDate: datetime = datetime.now(), createdBy: int = 0, lastModifiedDate: datetime = datetime.now(), lastModifiedBy: int = 0, **kwargs):
439
+ def __init__(self, key: int = 0, deviceTypeID: int = 0, userID: int = 0, deviceName: str = '', serialNumber: str = '', deviceDescription: str = '', recentOutput: str = '', cameraStatus: str = '', lastIPAddress: str = '', tunnelIPAddress: str = '', lastHeardFromDate: datetime = datetime.now(), softwareDate: datetime = datetime.now(), location: str = '', setupStatus: int = 0, autoSendFiles: int = 0, runStartupEvent: int = 0, deviceReadyEventPresetID: int = 0, standaloneEventPresetID: int = 0, logHealth: int = 0, runAnalytics: int = 0, audioChannelName: str = '', volume: int = 0, commentListID = 0, isArchived: bool = False, gUID: str = '', creationDate: datetime = datetime.now(), createdBy: int = 0, lastModifiedDate: datetime = datetime.now(), lastModifiedBy: int = 0, **kwargs):
440
440
  self.key = key
441
441
  self.deviceTypeID = deviceTypeID
442
442
  self.userID = userID
@@ -456,6 +456,7 @@ class DeviceObject:
456
456
  self.deviceReadyEventPresetID = deviceReadyEventPresetID
457
457
  self.standaloneEventPresetID = standaloneEventPresetID
458
458
  self.logHealth = logHealth
459
+ self.runAnalytics = runAnalytics
459
460
  self.audioChannelName = audioChannelName
460
461
  self.volume = volume
461
462
  self.commentListID = commentListID
@@ -527,6 +528,41 @@ class CreateVideoClip:
527
528
  # Optionally store any extra fields
528
529
  self.extra_fields = kwargs
529
530
 
531
+ # Warn or log if there are unexpected keyword arguments
532
+ if kwargs:
533
+ print(f"Warning: Ignoring unexpected arguments: {kwargs}")
534
+
535
+
536
+ class EventPreset:
537
+
538
+ def __init__(self, deviceID: int = 0, agentTypeID: int = 0, eventTypeID: int = 0, eventParameters: str = '', eventPresetName: str = '', priority: int = 1, maxAttempts: int = 5, expirationEpoch: int = 0, **kwargs):
539
+ self.deviceID = deviceID
540
+ self.agentTypeID = agentTypeID
541
+ self.eventTypeID = eventTypeID
542
+ self.eventParameters = eventParameters
543
+ self.eventPresetName = eventPresetName
544
+ self.priority = priority
545
+ self.maxAttempts = maxAttempts
546
+ self.expirationEpoch = expirationEpoch
547
+
548
+ # Warn or log if there are unexpected keyword arguments
549
+ if kwargs:
550
+ print(f"Warning: Ignoring unexpected arguments: {kwargs}")
551
+
552
+
553
+ class StartRecordingParameters:
554
+
555
+ def __init__(self, width: int = 0, height: int = 0, fps: int = 0, bitrate: int = 0, segmentLengthSeconds: int = 0, hflip: int = 0, vflip: int = 0, rotationDegrees: int = 0, audio: int = 0, **kwargs):
556
+ self.width = width
557
+ self.height = height
558
+ self.fps = fps
559
+ self.bitrate = bitrate
560
+ self.segmentLengthSeconds = segmentLengthSeconds
561
+ self.hflip = hflip
562
+ self.vflip = vflip
563
+ self.rotationDegrees = rotationDegrees
564
+ self.audio = audio
565
+
530
566
  # Warn or log if there are unexpected keyword arguments
531
567
  if kwargs:
532
568
  print(f"Warning: Ignoring unexpected arguments: {kwargs}")
@@ -0,0 +1,4 @@
1
+ from .Model import Event, EventWithNames, EventType, EventStatus, EventPreset, VideoClip, RecordingParameters, RecordingArgs, TranscodingParameters, TranscodingArgs, TransferArgs, ConcatenateClipsArgs, File, RTMPParameters, RTMPArgs, WifiConnection, NameValuePair, EventDetails, StandardResult, EpochRange, DeviceObject, CreateVideoClip, VideoClipType, ConferenceArgs
2
+
3
+
4
+ __all__ = ['Event', 'EventWithNames', 'EventType', 'EventStatus', 'EventPreset', 'VideoClip', 'RecordingParameters', 'RecordingArgs', 'TranscodingParameters', 'TranscodingArgs', 'TransferArgs', 'ConcatenateClipsArgs', 'File', 'RTMPParameters', 'RTMPArgs', 'WifiConnection', 'NameValuePair', 'EventDetails', 'StandardResult', 'EpochRange', 'DeviceObject', 'CreateVideoClip', 'VideoClipType', 'ConferenceArgs']
@@ -0,0 +1,83 @@
1
+ import json
2
+
3
+ from actionstreamer import CommonFunctions, Model
4
+ from actionstreamer.WebService.API import WebServiceResult
5
+ from actionstreamer.Config import WebServiceConfig
6
+
7
+ def run_event_preset(ws_config: WebServiceConfig, event_preset_id: int) -> WebServiceResult:
8
+
9
+ ws_result = WebServiceResult(0, '', '', '', None)
10
+
11
+ try:
12
+ method = "POST"
13
+ path = 'v1/eventpreset/run/' + str(event_preset_id)
14
+ url = ws_config.base_url + path
15
+ headers = {"Content-Type": "application/json"}
16
+ parameters = ''
17
+
18
+ json_post_data = {}
19
+ body = json.dumps(json_post_data)
20
+
21
+ response_code, response_string = CommonFunctions.send_signed_request(ws_config, method, url, path, headers, parameters, body)
22
+
23
+ ws_result.http_response_code = response_code
24
+ ws_result.http_response_string = response_string
25
+ ws_result.json_data = json.loads(response_string)
26
+
27
+ except Exception as ex:
28
+ ws_result.code = -1
29
+ filename, line_number = CommonFunctions.get_exception_info()
30
+ if filename is not None and line_number is not None:
31
+ print(f"Exception occurred at line {line_number} in {filename}")
32
+ print(ex)
33
+ ws_result.description = str(ex)
34
+
35
+ return ws_result
36
+
37
+
38
+ def create_event_preset(ws_config: WebServiceConfig, event_preset: Model.EventPreset, event_type: Model.EventType, event_parameters: Model.StartRecordingParameters | Model.StopRecordingParameters) -> tuple[int, str]:
39
+
40
+ try:
41
+ method = "POST"
42
+ path = 'v1/eventpreset/'
43
+ url = ws_config.base_url + path
44
+ headers = {"Content-Type": "application/json"}
45
+ parameters = ''
46
+
47
+ # Set the event parameters based on the event type.
48
+ if event_type == Model.EventType.Video.Start_recording:
49
+ event_parameters_json = Model.RecordingArgs (**event_parameters)
50
+
51
+ elif event_type == Model.EventType.Video.Stop_recording:
52
+ event_parameters_json = None
53
+
54
+ elif event_type == Model.EventType.Video.Start_RTMP:
55
+ event_parameters_json = Model.RTMPArgs(**event_parameters)
56
+
57
+ elif event_type == Model.EventType.Video.Stop_RTMP:
58
+ event_parameters_json = None
59
+
60
+ elif event_type == Model.EventType.Video.Join_conference:
61
+ event_parameters_json = Model.ConferenceArgs(**event_parameters)
62
+
63
+ elif event_type == Model.EventType.Video.Leave_conference:
64
+ event_parameters_json = None
65
+
66
+ else:
67
+ raise ValueError('Invalid event type]')
68
+
69
+ body = json.dumps(event_preset.__dict__)
70
+
71
+ response_code, response_string = CommonFunctions.send_signed_request(ws_config, method, url, path, headers, parameters, body)
72
+
73
+ except Exception as ex:
74
+
75
+ filename, line_number = CommonFunctions.get_exception_info()
76
+ if filename is not None and line_number is not None:
77
+ print(f"Exception occurred at line {line_number} in {filename}")
78
+ print(ex)
79
+
80
+ response_code = -1
81
+ response_string = "Exception in create_event_preset. Line number " + str(line_number)
82
+
83
+ return response_code, response_string
@@ -0,0 +1,4 @@
1
+ from .EventPreset import run_event_preset, create_event_preset
2
+
3
+
4
+ __all__ = ['run_event_preset', 'create_event_preset']
@@ -70,7 +70,7 @@ def create_temp_file(ws_config: actionstreamer.Config.WebServiceConfig, device_n
70
70
 
71
71
  Parameters:
72
72
  ws_config (Config.WebServiceConfig): The web service configuration.
73
- device_name (string): The device name.
73
+ device_name (string): The device serial number.
74
74
  filename (string): The filename (no path information, just the name).
75
75
  file_size (int): The file size in bytes.
76
76
  sha256_hash (string): The SHA256 hash for the file.
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "actionstreamer"
3
- version = "1.2.7"
3
+ version = "1.2.8"
4
4
  description = "A library for the ActionStreamer API."
5
5
  authors = ["ActionStreamer <joe@actionstreamer.com>"]
6
6
  readme = "README.md"
@@ -1,4 +0,0 @@
1
- from .Model import Event, EventWithNames, EventType, EventStatus, VideoClip, RecordingParameters, RecordingArgs, TranscodingParameters, TranscodingArgs, TransferArgs, ConcatenateClipsArgs, File, RTMPParameters, RTMPArgs, WifiConnection, NameValuePair, EventDetails, StandardResult, EpochRange, DeviceObject, CreateVideoClip, VideoClipType, ConferenceArgs
2
-
3
-
4
- __all__ = ['Event', 'EventWithNames', 'EventType', 'EventStatus', 'VideoClip', 'RecordingParameters', 'RecordingArgs', 'TranscodingParameters', 'TranscodingArgs', 'TransferArgs', 'ConcatenateClipsArgs', 'File', 'RTMPParameters', 'RTMPArgs', 'WifiConnection', 'NameValuePair', 'EventDetails', 'StandardResult', 'EpochRange', 'DeviceObject', 'CreateVideoClip', 'VideoClipType', 'ConferenceArgs']
@@ -1,35 +0,0 @@
1
- import json
2
-
3
- from actionstreamer import CommonFunctions
4
- from actionstreamer.WebService.API import WebServiceResult
5
- from actionstreamer.Config import WebServiceConfig
6
-
7
- def run_event_preset(ws_config: WebServiceConfig, event_preset_id: int) -> WebServiceResult:
8
-
9
- ws_result = WebServiceResult(0, '', '', '', None)
10
-
11
- try:
12
- method = "POST"
13
- path = 'v1/eventpreset/run/' + str(event_preset_id)
14
- url = ws_config.base_url + path
15
- headers = {"Content-Type": "application/json"}
16
- parameters = ''
17
-
18
- json_post_data = {}
19
- body = json.dumps(json_post_data)
20
-
21
- response_code, response_string = CommonFunctions.send_signed_request(ws_config, method, url, path, headers, parameters, body)
22
-
23
- ws_result.http_response_code = response_code
24
- ws_result.http_response_string = response_string
25
- ws_result.json_data = json.loads(response_string)
26
-
27
- except Exception as ex:
28
- ws_result.code = -1
29
- filename, line_number = CommonFunctions.get_exception_info()
30
- if filename is not None and line_number is not None:
31
- print(f"Exception occurred at line {line_number} in {filename}")
32
- print(ex)
33
- ws_result.description = str(ex)
34
-
35
- return ws_result
@@ -1,4 +0,0 @@
1
- from .EventPreset import run_event_preset
2
-
3
-
4
- __all__ = ['run_event_preset']
File without changes