Skip to content

Commit e381565

Browse files
committed
suppress arduino output
1 parent a4f3ce3 commit e381565

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/arduino_ci/arduino_cmd.rb

+10-7
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ def prefs
5858
# @param value [String] the preference value
5959
# @return [bool] whether the command succeeded
6060
def set_pref(key, value)
61-
success = run_with_gui_guess(" about preferences", "--pref", "#{key}=#{value}", "--save-prefs")
61+
resp = run_and_capture(" about preferences", "--pref", "#{key}=#{value}", "--save-prefs")
62+
success = resp[:success]
6263
@prefs_cache[key] = value if success
6364
success
6465
end
6566

6667
# run the arduino command
67-
# @return [Hash] {:out => StringIO, :err => StringIO }
6868
def run(*args, **kwargs)
6969
full_args = [@installation.cmd_path] + args
7070
@display_mgr.run(*full_args, **kwargs)
@@ -75,7 +75,8 @@ def run_with_gui_guess(message, *args, **kwargs)
7575
# so, assume that if we don't get a rapid reply that things are not installed
7676
x3 = @prefs_response_time * 3
7777
Timeout.timeout(x3) do
78-
run(*args, **kwargs)
78+
result = run_and_capture(*args, **kwargs)
79+
result[:success]
7980
end
8081
rescue Timeout::Error
8182
puts "No response in #{x3} seconds. Assuming graphical modal error message#{message}."
@@ -97,6 +98,8 @@ def run_and_capture(*args)
9798
{ out: str_out, err: str_err, success: success }
9899
end
99100

101+
# check whether a board is installed
102+
# we do this by just selecting a board. the arduino binary will error if unrecognized and do a successful no-op if it's installed
100103
def board_installed?(boardname)
101104
run_with_gui_guess(" about board not installed", "--board", boardname)
102105
end
@@ -105,16 +108,16 @@ def board_installed?(boardname)
105108
# @param name [String] the board name
106109
# @return [bool] whether the command succeeded
107110
def install_board(boardname)
108-
run("--install-boards", boardname)
111+
run_and_capture("--install-boards", boardname)[:success]
109112
end
110113

111114
# install a library by name
112115
# @param name [String] the library name
113116
# @return [bool] whether the command succeeded
114117
def install_library(library_name)
115-
result = run("--install-library", library_name)
116-
@library_is_indexed = true if result
117-
result
118+
result = run_and_capture("--install-library", library_name)
119+
@library_is_indexed = true if result[:success]
120+
result[:success]
118121
end
119122

120123
# update the library index

0 commit comments

Comments
 (0)