-
Notifications
You must be signed in to change notification settings - Fork 6k
add information collection for safari bots #20123
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
| import 'dart:convert'; | ||
|
|
||
| import 'utils.dart'; | ||
|
|
||
| class MacOSInfo { | ||
|
|
||
| /// Print information collected from the operating system. | ||
| /// | ||
| /// Built in tools such as `system_profiler` and `defaults` are utilized. | ||
| Future<void> printInformation() async { | ||
| await _printSafaridApplications(); | ||
| await _printSafariDefaults(); | ||
| } | ||
|
Comment on lines
+13
to
+30
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any chance of exceptions being thrown here? Let's guard against them so we don't fail our tests unnecessarily. Maybe something like: Future<void> printInformation() async {
try {
await _printSafariApplications();
} catch (error) {
print('Error thrown while getting Safari Applications: $error');
}
try {
await _printSafariDefaults();
} catch (error) {
print('Error thrown while getting Safari defaults: $error');
}
}
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, makes sense, since these might be different OS'es the tools might also be different.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also added the user limits, since we added try-catch it shouldn't be a problem even if we get a permission error. |
||
|
|
||
| /// Print information on applications in the system that contains string | ||
| /// `Safari`. | ||
| Future<void> _printSafaridApplications() async { | ||
|
nturgut marked this conversation as resolved.
Outdated
|
||
| final String systemProfileJson = await evalProcess( | ||
| 'system_profiler', ['SPApplicationsDataType', '-json']); | ||
|
|
||
| final Map<String, dynamic> json = | ||
| jsonDecode(systemProfileJson) as Map<String, dynamic>; | ||
| final List<dynamic> systemProfile = json.values.first as List<dynamic>; | ||
| for (int i = 0; i < systemProfile.length; i++) { | ||
| final Map<String, dynamic> application = | ||
| systemProfile[i] as Map<String, dynamic>; | ||
| final String applicationName = application['_name'] as String; | ||
| if (applicationName.contains('Safari')) { | ||
| print('application: $applicationName ' | ||
| 'fullInfo: ${application.toString()}'); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Print all the defaults in the system related to Safari. | ||
| Future<void> _printSafariDefaults() async { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mdebbar I added this part too. I thought some defaults such as |
||
| final String defaults = | ||
| await evalProcess('/usr/bin/defaults', ['find', 'Safari']); | ||
|
|
||
| print('Safari related defaults:\n $defaults'); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.