bosdyn-scout 3.3.1__py3-none-any.whl → 4.0.0__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,31 @@
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
13
12
 
13
+ from deprecated.sphinx import deprecated
14
+
15
+ from bosdyn.orbit.exceptions import WebhookSignatureVerificationError
16
+ from bosdyn.orbit.utils import (datetime_from_isostring, get_action_names_from_run_events,
17
+ get_api_token, validate_webhook_payload, write_image)
18
+
14
19
  SCOUT_USER_ENV_VAR = "BOSDYN_SCOUT_CLIENT_USERNAME"
15
20
  SCOUT_PASS_ENV_VAR = "BOSDYN_SCOUT_CLIENT_PASSWORD"
21
+ DEFAULT_MAX_MESSAGE_AGE_MS = 5 * 60 * 1000
22
+
16
23
 
24
+ @deprecated(reason='Please, use get_api_token instead.', version='4.0.0', action="always")
25
+ def get_credentials() -> [str, str]:
26
+ """ Obtains credentials from either environment variables or terminal inputs
17
27
 
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
- '''
28
+ Returns
29
+ username(str): the username for the Scout instance
30
+ password(str): the password for the Scout instance
31
+ """
24
32
  username = os.environ.get(SCOUT_USER_ENV_VAR)
25
33
  password = os.environ.get(SCOUT_PASS_ENV_VAR)
26
34
  if not username or not password:
@@ -32,17 +40,23 @@ def get_credentials():
32
40
  return username, password
33
41
 
34
42
 
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
- '''
43
+ @deprecated(
44
+ reason=
45
+ 'Scout has been renamed to Orbit. Please, use bosdyn-orbit package instead of bosdyn-scout.',
46
+ version='4.0.0', action="always")
47
+ def get_latest_created_at_for_run_events(scout_client: 'bosdyn.scout.client.ScoutClient',
48
+ params: dict = {}) -> datetime.datetime:
49
+ """ Given a dictionary of query params, returns the max created at time for run events
50
+
51
+ Args:
52
+ scout_client: the client for Scout web API
53
+ params: the query params associated with the get request
54
+ Raises:
55
+ RequestExceptions: exceptions thrown by the Requests library
56
+ UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
57
+ Returns:
58
+ The max created at time for run events in datetime
59
+ """
46
60
  base_params = {'limit': 1, 'orderBy': '-created_at'}
47
61
  base_params.update(params)
48
62
  latest_resource = scout_client.get_run_events(params=base_params).json()
@@ -53,34 +67,46 @@ def get_latest_created_at_for_run_events(scout_client, params={}):
53
67
  return datetime_from_isostring(latest_resource["resources"][0]["createdAt"])
54
68
 
55
69
 
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
- '''
70
+ @deprecated(
71
+ reason=
72
+ 'Scout has been renamed to Orbit. Please, use bosdyn-orbit package instead of bosdyn-scout.',
73
+ version='4.0.0', action="always")
74
+ def get_latest_run_capture_resources(scout_client: 'bosdyn.scout.client.ScoutClient',
75
+ params: dict = {}) -> list:
76
+ """ Given a dictionary of query params, returns the latest run capture resources in json format
77
+
78
+ Args:
79
+ scout_client: the client for Scout web API
80
+ params: the query params associated with the get request
81
+ Raises:
82
+ RequestExceptions: exceptions thrown by the Requests library
83
+ UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
84
+ Returns:
85
+ A list of resources obtained from Scout's RESTful endpoint
86
+ """
67
87
  base_params = {'orderBy': '-created_at'}
68
88
  base_params.update(params)
69
89
  run_captures = scout_client.get_run_captures(params=base_params).json()
70
90
  return run_captures["resources"]
71
91
 
72
92
 
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
- '''
93
+ @deprecated(
94
+ reason=
95
+ 'Scout has been renamed to Orbit. Please, use bosdyn-orbit package instead of bosdyn-scout.',
96
+ version='4.0.0', action="always")
97
+ def get_latest_created_at_for_run_captures(scout_client: 'bosdyn.scout.client.ScoutClient',
98
+ params: dict = {}) -> datetime.datetime:
99
+ """ Given a dictionary of query params, returns the max created at time for run captures
100
+
101
+ Args:
102
+ scout_client: the client for Scout web API
103
+ params: the query params associated with the get request
104
+ Raises:
105
+ RequestExceptions: exceptions thrown by the Requests library
106
+ UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
107
+ Returns:
108
+ The max created at time for run captures in datetime
109
+ """
84
110
  base_params = {'limit': 1, 'orderBy': '-created_at'}
85
111
  base_params.update(params)
86
112
  latest_resource = scout_client.get_run_captures(params=base_params).json()
@@ -91,17 +117,23 @@ def get_latest_created_at_for_run_captures(scout_client, params={}):
91
117
  return datetime_from_isostring(latest_resource["resources"][0]["createdAt"])
92
118
 
93
119
 
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
- '''
120
+ @deprecated(
121
+ reason=
122
+ 'Scout has been renamed to Orbit. Please, use bosdyn-orbit package instead of bosdyn-scout.',
123
+ version='4.0.0', action="always")
124
+ def get_latest_run_resource(scout_client: 'bosdyn.scout.client.ScoutClient',
125
+ params: dict = {}) -> list:
126
+ """ Given a dictionary of query params, returns the latest run resource in json format
127
+
128
+ Args:
129
+ scout_client: the client for Scout web API
130
+ params: the query params associated with the get request
131
+ Raises:
132
+ RequestExceptions: exceptions thrown by the Requests library
133
+ UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
134
+ Returns:
135
+ A list corresponding to a run resource obtained from Scout's RESTful endpoint in json
136
+ """
105
137
  base_params = {'limit': 1, 'orderBy': 'newest'}
106
138
  base_params.update(params)
107
139
  latest_run_json = scout_client.get_runs(params=base_params).json()
@@ -110,17 +142,23 @@ def get_latest_run_resource(scout_client, params={}):
110
142
  return latest_run_json['resources'][0]
111
143
 
112
144
 
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
- '''
145
+ @deprecated(
146
+ reason=
147
+ 'Scout has been renamed to Orbit. Please, use bosdyn-orbit package instead of bosdyn-scout.',
148
+ version='4.0.0', action="always")
149
+ def get_latest_run_in_progress(scout_client: 'bosdyn.scout.client.ScoutClient',
150
+ params: dict = {}) -> list:
151
+ """ Given a dictionary of query params, returns the latest running resource in json format
152
+
153
+ Args:
154
+ scout_client: the client for Scout web API
155
+ params: the query params associated with the get request
156
+ Raises:
157
+ RequestExceptions: exceptions thrown by the Requests library
158
+ UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
159
+ Returns:
160
+ A list corresponding to a run obtained from Scout's RESTful endpoint in json
161
+ """
124
162
  base_params = {'orderBy': 'newest'}
125
163
  base_params.update(params)
126
164
  latest_resources = scout_client.get_runs(params=base_params).json()["resources"]
@@ -132,47 +170,51 @@ def get_latest_run_in_progress(scout_client, params={}):
132
170
  return None
133
171
 
134
172
 
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
- '''
173
+ @deprecated(
174
+ reason=
175
+ 'Scout has been renamed to Orbit. Please, use bosdyn-orbit package instead of bosdyn-scout.',
176
+ version='4.0.0', action="always")
177
+ def get_latest_end_time_for_runs(scout_client: 'bosdyn.scout.client.ScoutClient',
178
+ params: dict = {}) -> datetime.datetime:
179
+ """ Given a dictionary of query params, returns the max end time for runs
180
+
181
+ Args:
182
+ scout_client: the client for Scout web API
183
+ params: the query params associated with the get request
184
+ Raises:
185
+ RequestExceptions: exceptions thrown by the Requests library
186
+ UnauthenticatedScoutClientError: indicates that the scout client is not authenticated properly
187
+ Returns:
188
+ The max end time for runs in datetime
189
+ """
146
190
  base_params = {'limit': 1, 'orderBy': 'newest'}
147
191
  base_params.update(params)
148
192
  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
- '''
193
+ if latest_resource.get("resources"):
194
+ latest_end_time = latest_resource.get("resources")[0]["endTime"]
195
+ if latest_end_time:
196
+ return datetime_from_isostring(latest_end_time)
197
+ scout_client_timestamp_response = scout_client.get_scout_system_time()
198
+ ms_since_epoch = int(scout_client_timestamp_response.json()["msSinceEpoch"])
199
+ return datetime.datetime.utcfromtimestamp(ms_since_epoch / 1000)
200
+
201
+
202
+ @deprecated(
203
+ reason=
204
+ 'Scout has been renamed to Orbit. Please, use bosdyn-orbit package instead of bosdyn-scout.',
205
+ version='4.0.0', action="always")
206
+ def data_capture_urls_from_run_events(scout_client: 'bosdyn.scout.client.ScoutClient',
207
+ run_events: list, list_of_channel_names: list = None) -> list:
208
+ """ Given run events and list of desired channel names, returns the list of data capture urls
209
+
210
+ Args:
211
+ scout_client: the client for Scout web API
212
+ run_events: a json representation of run events obtained from Scout's RESTful endpoint
213
+ list_of_channel_names: a list of channel names associated with the desired data captures.
214
+ Defaults to None which returns all the available channels.
215
+ Returns:
216
+ data_urls: a list of urls
217
+ """
176
218
  all_run_events_resources = run_events["resources"]
177
219
  data_urls = []
178
220
  for resource in all_run_events_resources:
@@ -189,16 +231,23 @@ def data_capture_urls_from_run_events(scout_client, run_events, list_of_channel_
189
231
  return data_urls
190
232
 
191
233
 
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
- '''
234
+ @deprecated(
235
+ reason=
236
+ 'Scout has been renamed to Orbit. Please, use bosdyn-orbit package instead of bosdyn-scout.',
237
+ version='4.0.0', action="always")
238
+ def data_capture_url_from_run_capture_resources(scout_client: 'bosdyn.scout.client.ScoutClient',
239
+ run_capture_resources: list,
240
+ list_of_channel_names: list = None) -> list:
241
+ """ Given run capture resources and list of desired channel names, returns the list of data capture urls
242
+
243
+ Args:
244
+ scout_client: the client for Scout web API
245
+ run_capture_resources: a list of resources obtained from Scout's RESTful endpoint
246
+ list_of_channel_names: a list of channel names associated with the desired data captures.
247
+ Defaults to None which returns all the available channels.
248
+ Returns:
249
+ data_urls: a list of urls
250
+ """
202
251
  data_urls = []
203
252
  for data_capture in run_capture_resources:
204
253
  if list_of_channel_names is None:
@@ -210,31 +259,3 @@ def data_capture_url_from_run_capture_resources(scout_client, run_capture_resour
210
259
  if list_of_channel_names not in data_urls:
211
260
  data_urls.append(f'https://{scout_client._hostname}' + data_capture["dataUrl"])
212
261
  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.1
3
+ Version: 4.0.0
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.0)
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=PmI3HzMDJKduQXq-ie0Hb2T7uP0Zf6LIOFu0e8qX9-A,42696
4
+ bosdyn/scout/exceptions.py,sha256=1qCD8Nz6xDZAnVf0rSBNLBvQwzxY-ruF-wJA9WqCVkE,518
5
+ bosdyn/scout/utils.py,sha256=oXdqHgyVcjGD2LAB-dW_bgXfgGQWpDQLF25MUi9fjTU,12253
6
+ bosdyn_scout-4.0.0.dist-info/METADATA,sha256=jaJk_xiVDF9QX3oGdcwo-a0zuIP4gbnNip_6HAAA2_Q,1932
7
+ bosdyn_scout-4.0.0.dist-info/WHEEL,sha256=AtBG6SXL3KF_v0NxLf0ehyVOh0cold-JbJYXNGorC6Q,92
8
+ bosdyn_scout-4.0.0.dist-info/top_level.txt,sha256=an2OWgx1ej2jFjmBjPWNQ68ZglvUfKhmXWW-WhTtDmA,7
9
+ bosdyn_scout-4.0.0.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.1.dist-info/METADATA,sha256=jwgDwl1k6s4hHYqO5gnuJKoKzE9LCMF4Bz_2v6Y7eO8,1894
7
- bosdyn_scout-3.3.1.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
8
- bosdyn_scout-3.3.1.dist-info/top_level.txt,sha256=an2OWgx1ej2jFjmBjPWNQ68ZglvUfKhmXWW-WhTtDmA,7
9
- bosdyn_scout-3.3.1.dist-info/RECORD,,