Skip to content

Commit 4c52d76

Browse files
committed
Updates to analytics-host to support multiple AnalysisGroups
- This update modifies `analytics-host` to accept multiple device/device archive slugs to create AnalysisGroups from them
1 parent 3a4ea29 commit 4c52d76

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

iotile_analytics_interactive/iotile_analytics/interactive/scripts/analytics_host.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def build_args():
121121
parser.add_argument('--web-push-slug', type=str, default=None, help="Override the source slug given in the analysisgroup and force it to be this")
122122
parser.add_argument('--token', type=str, default=None, help="Token for authentication to iotile cloud (instead of a password)")
123123
parser.add_argument('-d', '--domain', default=DOMAIN_NAME, help="Domain to use for remote queries, defaults to https://iotile.cloud")
124-
parser.add_argument('analysis_group', default=None, nargs='?', help="The slug or path of the object you want to perform analysis on")
124+
parser.add_argument('analysis_group', default=None, nargs='+', help="The slug or path of the object you want to perform analysis on")
125125

126126
return parser
127127

@@ -214,6 +214,21 @@ def print_report_details(report):
214214
except ValidationError:
215215
print("Error parsing docstring for report.")
216216

217+
def find_analysis_groups(args):
218+
"""Parse through the list of options for analysis_group and build a list"""
219+
all_groups = []
220+
all_logins = True
221+
222+
groups = args.analysis_group
223+
for _group in groups:
224+
logged_in, group = find_analysis_group(_group)
225+
all_groups.append(group)
226+
all_logins = all_logins and logged_in
227+
228+
if len(all_groups) == 1:
229+
return all_logins, all_groups[0]
230+
231+
return all_logins, all_groups
217232

218233
def find_analysis_group(args):
219234
"""Find an analysis group by name."""
@@ -337,6 +352,11 @@ def build_file_handler(output_path, standalone, bundle, web_push, label, group,
337352
if label is None:
338353
label = input("Enter a label for the report: ")
339354

355+
356+
# if there are multiple AnalysisGroup, push to the first one by default
357+
if isinstance(group, list):
358+
group = group[0]
359+
340360
if slug is None and group is not None:
341361
slug = group.source_info.get('slug')
342362

@@ -422,7 +442,7 @@ def main(argv=None):
422442
return 0
423443

424444
report_args = split_args(args.arg)
425-
logged_in, group = find_analysis_group(args)
445+
logged_in, group = find_analysis_groups(args)
426446

427447

428448
check_arguments(report_obj, report_args, confirm=not args.no_confirm)

0 commit comments

Comments
 (0)