bosdyn-scout 3.3.2__py3-none-any.whl → 4.0.1__py3-none-any.whl

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.
@@ -5,14 +5,6 @@
5
5
  # Development Kit License (20191101-BDSDK-SL).
6
6
 
7
7
  """Relevant exceptions for bosdyn-scout"""
8
-
9
-
10
- class Error(Exception):
11
- """Base exception"""
12
-
13
-
14
- class UnauthenticatedScoutClientError(Error):
15
- """The Scout client is not authenticated properly."""
16
-
17
- def __str__(self):
18
- return 'The Scout client is not authenticated properly. Run the proper authentication before calling other client functions!'
8
+ from bosdyn.orbit.exceptions import Error
9
+ from bosdyn.orbit.exceptions import UnauthenticatedClientError as UnauthenticatedScoutClientError
10
+ from bosdyn.orbit.exceptions import WebhookSignatureVerificationError
bosdyn/scout/utils.py CHANGED
@@ -4,23 +4,32 @@
4
4
  # is subject to the terms and conditions of the Boston Dynamics Software
5
5
  # Development Kit License (20191101-BDSDK-SL).
6
6
 
7
- '''Utility functions for Scout web API'''
7
+ """Utility functions for Scout web API"""
8
8
  import datetime
9
9
  import getpass
10
10
  import os
11
- import shutil
12
11
  import sys
12
+ from typing import Dict, List
13
+
14
+ from deprecated.sphinx import deprecated
15
+
16
+ from bosdyn.orbit.exceptions import WebhookSignatureVerificationError
17
+ from bosdyn.orbit.utils import (datetime_from_isostring, get_action_names_from_run_events,
18
+ get_api_token, validate_webhook_payload, write_image)
13
19
 
14
20
  SCOUT_USER_ENV_VAR = "BOSDYN_SCOUT_CLIENT_USERNAME"
15
21
  SCOUT_PASS_ENV_VAR = "BOSDYN_SCOUT_CLIENT_PASSWORD"
22
+ DEFAULT_MAX_MESSAGE_AGE_MS = 5 * 60 * 1000
23
+
16
24
 
25
+ @deprecated(reason='Please, use get_api_token instead.', version='4.0.0', action="always")
26
+ def get_credentials() -> [str, str]:
27
+ """ Obtains credentials from either environment variables or terminal inputs
17
28
 
18
- def get_credentials():
19
- ''' Obtains credentials from either environment variables or terminal inputs
20
- - Returns
21
- - username(str): the username for the Scout instance
22
- - password(str): the password for the Scout instance
23
- '''
29
+ Returns
30
+ username(str): the username for the Scout instance
31
+ password(str): the password for the Scout instance
32
+ """
24
33
  username = os.environ.get(SCOUT_USER_ENV_VAR)
25
34
  password = os.environ.get(SCOUT_PASS_ENV_VAR)
26
35
  if not username or not password:
@@ -32,17 +41,23 @@ def get_credentials():
32
41
  return username, password
33
42
 
34
43
 
35
- def get_latest_created_at_for_run_events(scout_client, params={}):
36
- ''' Given a dictionary of query params, returns the max created at time for run events
37
- - Args:
38
- - scout_client(ScoutClient object): the client for Scout web API
39
- - params(dict): the query params associated with the get request
40
- - Raises:
41
- - RequestExceptions: exceptions thrown by the Requests library
42
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
43
- - Returns:
44
- - datetime.datetime(datetime representation): the max created at time for run events in datetime
45
- '''
44
+ @deprecated(
45
+ reason=
46
+ 'Scout has been renamed to Orbit. Please, use bosdyn-orbit package instead of bosdyn-scout.',
47
+ version='4.0.0', action="always")
48
+ def get_latest_created_at_for_run_events(scout_client: 'bosdyn.scout.client.ScoutClient',
49
+ params: Dict = {}) -> datetime.datetime:
50
+ """ Given a dictionary of query params, returns the max created at time for run events
51
+
52
+ Args:
53
+ scout_client: the client for Scout web API
54
+ params: the query params associated with the get request
55
+ Raises:
56
+ RequestExceptions: exceptions thrown by the Requests library
57
+ UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
58
+ Returns:
59
+ The max created at time for run events in datetime
60
+ """
46
61
  base_params = {'limit': 1, 'orderBy': '-created_at'}
47
62
  base_params.update(params)
48
63
  latest_resource = scout_client.get_run_events(params=base_params).json()
@@ -53,34 +68,46 @@ def get_latest_created_at_for_run_events(scout_client, params={}):
53
68
  return datetime_from_isostring(latest_resource["resources"][0]["createdAt"])
54
69
 
55
70
 
56
- def get_latest_run_capture_resources(scout_client, params={}):
57
- ''' Given a dictionary of query params, returns the latest run capture resources in json format
58
- - Args:
59
- - scout_client(ScoutClient object): the client for Scout web API
60
- - params(dict): the query params associated with the get request
61
- - Raises:
62
- - RequestExceptions: exceptions thrown by the Requests library
63
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
64
- - Returns:
65
- - Run Capture Resources(list): a list of resources obtained from Scout's RESTful endpoint
66
- '''
71
+ @deprecated(
72
+ reason=
73
+ 'Scout has been renamed to Orbit. Please, use bosdyn-orbit package instead of bosdyn-scout.',
74
+ version='4.0.0', action="always")
75
+ def get_latest_run_capture_resources(scout_client: 'bosdyn.scout.client.ScoutClient',
76
+ params: Dict = {}) -> List:
77
+ """ Given a dictionary of query params, returns the latest run capture resources in json format
78
+
79
+ Args:
80
+ scout_client: the client for Scout web API
81
+ params: the query params associated with the get request
82
+ Raises:
83
+ RequestExceptions: exceptions thrown by the Requests library
84
+ UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
85
+ Returns:
86
+ A list of resources obtained from Scout's RESTful endpoint
87
+ """
67
88
  base_params = {'orderBy': '-created_at'}
68
89
  base_params.update(params)
69
90
  run_captures = scout_client.get_run_captures(params=base_params).json()
70
91
  return run_captures["resources"]
71
92
 
72
93
 
73
- def get_latest_created_at_for_run_captures(scout_client, params={}):
74
- ''' Given a dictionary of query params, returns the max created at time for run captures
75
- - Args:
76
- - scout_client(ScoutClient object): the client for Scout web API
77
- - params(dict): the query params associated with the get request
78
- - Raises:
79
- - RequestExceptions: exceptions thrown by the Requests library
80
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
81
- - Returns:
82
- - datetime.datetime(datetime representation): the max created at time for run captures in datetime
83
- '''
94
+ @deprecated(
95
+ reason=
96
+ 'Scout has been renamed to Orbit. Please, use bosdyn-orbit package instead of bosdyn-scout.',
97
+ version='4.0.0', action="always")
98
+ def get_latest_created_at_for_run_captures(scout_client: 'bosdyn.scout.client.ScoutClient',
99
+ params: Dict = {}) -> datetime.datetime:
100
+ """ Given a dictionary of query params, returns the max created at time for run captures
101
+
102
+ Args:
103
+ scout_client: the client for Scout web API
104
+ params: the query params associated with the get request
105
+ Raises:
106
+ RequestExceptions: exceptions thrown by the Requests library
107
+ UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
108
+ Returns:
109
+ The max created at time for run captures in datetime
110
+ """
84
111
  base_params = {'limit': 1, 'orderBy': '-created_at'}
85
112
  base_params.update(params)
86
113
  latest_resource = scout_client.get_run_captures(params=base_params).json()
@@ -91,17 +118,23 @@ def get_latest_created_at_for_run_captures(scout_client, params={}):
91
118
  return datetime_from_isostring(latest_resource["resources"][0]["createdAt"])
92
119
 
93
120
 
94
- def get_latest_run_resource(scout_client, params={}):
95
- ''' Given a dictionary of query params, returns the latest run resource in json format
96
- - Args:
97
- - scout_client(ScoutClient object): the client for Scout web API
98
- - params(dict): the query params associated with the get request
99
- - Raises:
100
- - RequestExceptions: exceptions thrown by the Requests library
101
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
102
- - Returns:
103
- - Run Resource(json): a resource obtained from Scout's RESTful endpoint in json
104
- '''
121
+ @deprecated(
122
+ reason=
123
+ 'Scout has been renamed to Orbit. Please, use bosdyn-orbit package instead of bosdyn-scout.',
124
+ version='4.0.0', action="always")
125
+ def get_latest_run_resource(scout_client: 'bosdyn.scout.client.ScoutClient',
126
+ params: Dict = {}) -> List:
127
+ """ Given a dictionary of query params, returns the latest run resource in json format
128
+
129
+ Args:
130
+ scout_client: the client for Scout web API
131
+ params: the query params associated with the get request
132
+ Raises:
133
+ RequestExceptions: exceptions thrown by the Requests library
134
+ UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
135
+ Returns:
136
+ A list corresponding to a run resource obtained from Scout's RESTful endpoint in json
137
+ """
105
138
  base_params = {'limit': 1, 'orderBy': 'newest'}
106
139
  base_params.update(params)
107
140
  latest_run_json = scout_client.get_runs(params=base_params).json()
@@ -110,17 +143,23 @@ def get_latest_run_resource(scout_client, params={}):
110
143
  return latest_run_json['resources'][0]
111
144
 
112
145
 
113
- def get_latest_run_in_progress(scout_client, params={}):
114
- ''' Given a dictionary of query params, returns the latest running resource in json format
115
- - Args:
116
- - scout_client(ScoutClient object): the client for Scout web API
117
- - params(dict): the query params associated with the get request
118
- - Raises:
119
- - RequestExceptions: exceptions thrown by the Requests library
120
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
121
- - Returns:
122
- - Run(json): a run obtained from Scout's RESTful endpoint in json
123
- '''
146
+ @deprecated(
147
+ reason=
148
+ 'Scout has been renamed to Orbit. Please, use bosdyn-orbit package instead of bosdyn-scout.',
149
+ version='4.0.0', action="always")
150
+ def get_latest_run_in_progress(scout_client: 'bosdyn.scout.client.ScoutClient',
151
+ params: Dict = {}) -> List:
152
+ """ Given a dictionary of query params, returns the latest running resource in json format
153
+
154
+ Args:
155
+ scout_client: the client for Scout web API
156
+ params: the query params associated with the get request
157
+ Raises:
158
+ RequestExceptions: exceptions thrown by the Requests library
159
+ UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
160
+ Returns:
161
+ A list corresponding to a run obtained from Scout's RESTful endpoint in json
162
+ """
124
163
  base_params = {'orderBy': 'newest'}
125
164
  base_params.update(params)
126
165
  latest_resources = scout_client.get_runs(params=base_params).json()["resources"]
@@ -132,47 +171,51 @@ def get_latest_run_in_progress(scout_client, params={}):
132
171
  return None
133
172
 
134
173
 
135
- def get_latest_end_time_for_runs(scout_client, params={}):
136
- ''' Given a dictionary of query params, returns the max end time for runs
137
- - Args:
138
- - scout_client(ScoutClient object): the client for Scout web API
139
- - params(dict): the query params associated with the get request
140
- - Raises:
141
- - RequestExceptions: exceptions thrown by the Requests library
142
- - UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
143
- - Returns:
144
- - datetime.datetime(datetime representation): the max end for runs in datetime
145
- '''
174
+ @deprecated(
175
+ reason=
176
+ 'Scout has been renamed to Orbit. Please, use bosdyn-orbit package instead of bosdyn-scout.',
177
+ version='4.0.0', action="always")
178
+ def get_latest_end_time_for_runs(scout_client: 'bosdyn.scout.client.ScoutClient',
179
+ params: Dict = {}) -> datetime.datetime:
180
+ """ Given a dictionary of query params, returns the max end time for runs
181
+
182
+ Args:
183
+ scout_client: the client for Scout web API
184
+ params: the query params associated with the get request
185
+ Raises:
186
+ RequestExceptions: exceptions thrown by the Requests library
187
+ UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
188
+ Returns:
189
+ The max end time for runs in datetime
190
+ """
146
191
  base_params = {'limit': 1, 'orderBy': 'newest'}
147
192
  base_params.update(params)
148
193
  latest_resource = scout_client.get_runs(params=base_params).json()
149
- if not latest_resource["resources"]:
150
- scout_client_timestamp_response = scout_client.get_scout_system_time()
151
- ms_since_epoch = int(scout_client_timestamp_response.json()["msSinceEpoch"])
152
- return datetime.datetime.utcfromtimestamp(ms_since_epoch / 1000)
153
- return datetime_from_isostring(latest_resource["resources"][0]["endTime"])
154
-
155
-
156
- def write_image(img_raw, image_fp):
157
- ''' Given a raw image and a desired output directory, writes the image to a file
158
- - Args:
159
- - img_raw(Raw image object): the input raw image
160
- - image_fp(str): the output filepath for the image
161
- '''
162
- os.makedirs(os.path.dirname(image_fp), exist_ok=True)
163
- with open(image_fp, 'wb') as out_file:
164
- shutil.copyfileobj(img_raw, out_file)
165
-
166
-
167
- def data_capture_urls_from_run_events(scout_client, run_events, list_of_channel_names=None):
168
- ''' Given run events and list of desired channel names, returns the a list data capture urls
169
- - Args:
170
- - run_events(json): a json representation of run events obtained from Scout's RESTful endpoint
171
- - list_of_channel_names(list): a list of channel names associated with the desired data captures.
172
- Defaults to None which returns all the available channels.
173
- - Returns:
174
- - data_urls(list): a list of urls
175
- '''
194
+ if latest_resource.get("resources"):
195
+ latest_end_time = latest_resource.get("resources")[0]["endTime"]
196
+ if latest_end_time:
197
+ return datetime_from_isostring(latest_end_time)
198
+ scout_client_timestamp_response = scout_client.get_scout_system_time()
199
+ ms_since_epoch = int(scout_client_timestamp_response.json()["msSinceEpoch"])
200
+ return datetime.datetime.utcfromtimestamp(ms_since_epoch / 1000)
201
+
202
+
203
+ @deprecated(
204
+ reason=
205
+ 'Scout has been renamed to Orbit. Please, use bosdyn-orbit package instead of bosdyn-scout.',
206
+ version='4.0.0', action="always")
207
+ def data_capture_urls_from_run_events(scout_client: 'bosdyn.scout.client.ScoutClient',
208
+ run_events: List, list_of_channel_names: List = None) -> List:
209
+ """ Given run events and list of desired channel names, returns the list of data capture urls
210
+
211
+ Args:
212
+ scout_client: the client for Scout web API
213
+ run_events: a json representation of run events obtained from Scout's RESTful endpoint
214
+ list_of_channel_names: a list of channel names associated with the desired data captures.
215
+ Defaults to None which returns all the available channels.
216
+ Returns:
217
+ data_urls: a list of urls
218
+ """
176
219
  all_run_events_resources = run_events["resources"]
177
220
  data_urls = []
178
221
  for resource in all_run_events_resources:
@@ -189,16 +232,23 @@ def data_capture_urls_from_run_events(scout_client, run_events, list_of_channel_
189
232
  return data_urls
190
233
 
191
234
 
192
- def data_capture_url_from_run_capture_resources(scout_client, run_capture_resources,
193
- list_of_channel_names=None):
194
- ''' Given run capture resources and list of desired channel names, returns the a list data capture urls
195
- - Args:
196
- - run_capture_resources(list): a list of resources obtained from Scout's RESTful endpoint
197
- - list_of_channel_names(list): a list of channel names associated with the desired data captures.
198
- Defaults to None which returns all the available channels.
199
- - Returns:
200
- - data_urls(list): a list of urls
201
- '''
235
+ @deprecated(
236
+ reason=
237
+ 'Scout has been renamed to Orbit. Please, use bosdyn-orbit package instead of bosdyn-scout.',
238
+ version='4.0.0', action="always")
239
+ def data_capture_url_from_run_capture_resources(scout_client: 'bosdyn.scout.client.ScoutClient',
240
+ run_capture_resources: List,
241
+ list_of_channel_names: List = None) -> List:
242
+ """ Given run capture resources and list of desired channel names, returns the list of data capture urls
243
+
244
+ Args:
245
+ scout_client: the client for Scout web API
246
+ run_capture_resources: a list of resources obtained from Scout's RESTful endpoint
247
+ list_of_channel_names: a list of channel names associated with the desired data captures.
248
+ Defaults to None which returns all the available channels.
249
+ Returns:
250
+ data_urls: a list of urls
251
+ """
202
252
  data_urls = []
203
253
  for data_capture in run_capture_resources:
204
254
  if list_of_channel_names is None:
@@ -210,31 +260,3 @@ def data_capture_url_from_run_capture_resources(scout_client, run_capture_resour
210
260
  if list_of_channel_names not in data_urls:
211
261
  data_urls.append(f'https://{scout_client._hostname}' + data_capture["dataUrl"])
212
262
  return data_urls
213
-
214
-
215
- def get_action_names_from_run_events(run_events):
216
- ''' Given run events, returns a list of action names
217
- - Args:
218
- - run_events(json): a json representation of run events obtained from Scout's RESTful endpoint
219
- - Returns:
220
- - action_names(list): a list of action names
221
- '''
222
- all_run_events_resources = run_events["resources"]
223
- action_names = []
224
- for resource in all_run_events_resources:
225
- action_names.append(resource["actionName"])
226
- return action_names
227
-
228
-
229
- def datetime_from_isostring(datetime_isostring):
230
- ''' Returns the datetime representation of the iso string representation of time
231
- - Args:
232
- - datetime_isostring(str): the iso string representation of time
233
- - Returns:
234
- - datetime.datetime(datetime representation): the datetime representation of the iso string representation of time
235
- '''
236
- if "Z" in datetime_isostring:
237
- return datetime.datetime.strptime(datetime_isostring, "%Y-%m-%dT%H:%M:%S.%fZ")
238
- if "+" in datetime_isostring:
239
- return datetime.datetime.strptime(datetime_isostring[0:datetime_isostring.index("+")],
240
- "%Y-%m-%dT%H:%M:%S.%f")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bosdyn-scout
3
- Version: 3.3.2
3
+ Version: 4.0.1
4
4
  Summary: Boston Dynamics API Scout Client
5
5
  Home-page: https://dev.bostondynamics.com/docs/scout/
6
6
  Author: Boston Dynamics
@@ -18,6 +18,7 @@ Requires-Python: >=3.6
18
18
  Description-Content-Type: text/markdown
19
19
  Requires-Dist: requests
20
20
  Requires-Dist: Deprecated (~=1.2.10)
21
+ Requires-Dist: bosdyn-orbit (==4.0.1)
21
22
 
22
23
  <!--
23
24
  Copyright (c) 2023 Boston Dynamics, Inc. All rights reserved.
@@ -0,0 +1,9 @@
1
+ bosdyn/__init__.py,sha256=CMQioQKK1NlMk3kZuY49b_Aw-JyvDeOtuqOCAul1I0s,330
2
+ bosdyn/scout/__init__.py,sha256=1qUAbnMKYlERYZvxtGz4ThjYef7Tx-ZBclLoVE_ecjU,265
3
+ bosdyn/scout/client.py,sha256=qjjtItY1gP7w9k2mZl3LFq5q0fBLjM_F8Btj7cjSaiw,42751
4
+ bosdyn/scout/exceptions.py,sha256=1qCD8Nz6xDZAnVf0rSBNLBvQwzxY-ruF-wJA9WqCVkE,518
5
+ bosdyn/scout/utils.py,sha256=ZwP9Z9qcEMnilCqG-2wHO743lpP4qUt89u3d7PU0FUE,12283
6
+ bosdyn_scout-4.0.1.dist-info/METADATA,sha256=TaVHz7pl4zCnipPo-serwONqehiPvrT7E0Wiv3fz40E,1932
7
+ bosdyn_scout-4.0.1.dist-info/WHEEL,sha256=AtBG6SXL3KF_v0NxLf0ehyVOh0cold-JbJYXNGorC6Q,92
8
+ bosdyn_scout-4.0.1.dist-info/top_level.txt,sha256=an2OWgx1ej2jFjmBjPWNQ68ZglvUfKhmXWW-WhTtDmA,7
9
+ bosdyn_scout-4.0.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.40.0)
2
+ Generator: bdist_wheel (0.41.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,9 +0,0 @@
1
- bosdyn/__init__.py,sha256=CMQioQKK1NlMk3kZuY49b_Aw-JyvDeOtuqOCAul1I0s,330
2
- bosdyn/scout/__init__.py,sha256=1qUAbnMKYlERYZvxtGz4ThjYef7Tx-ZBclLoVE_ecjU,265
3
- bosdyn/scout/client.py,sha256=WE2kyZjoQOOyLiUlaqLKDV12xgVxkeFEM6-Gi2Vmx84,25697
4
- bosdyn/scout/exceptions.py,sha256=Rw-4PGV92TSyBqkPopHXQe3ppLKbrH5_mrdmmWb8s-c,623
5
- bosdyn/scout/utils.py,sha256=CcDDfaJpvAhHMYSUaaE4Vswx4CaZMstpvOt38r4mcrM,11687
6
- bosdyn_scout-3.3.2.dist-info/METADATA,sha256=v2tszkzQoeQdcokfUPNZQhtJcre1v2couy83QX2fz20,1894
7
- bosdyn_scout-3.3.2.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
8
- bosdyn_scout-3.3.2.dist-info/top_level.txt,sha256=an2OWgx1ej2jFjmBjPWNQ68ZglvUfKhmXWW-WhTtDmA,7
9
- bosdyn_scout-3.3.2.dist-info/RECORD,,