@@ -58,13 +58,13 @@ def prefs
58
58
# @param value [String] the preference value
59
59
# @return [bool] whether the command succeeded
60
60
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 ]
62
63
@prefs_cache [ key ] = value if success
63
64
success
64
65
end
65
66
66
67
# run the arduino command
67
- # @return [Hash] {:out => StringIO, :err => StringIO }
68
68
def run ( *args , **kwargs )
69
69
full_args = [ @installation . cmd_path ] + args
70
70
@display_mgr . run ( *full_args , **kwargs )
@@ -75,7 +75,8 @@ def run_with_gui_guess(message, *args, **kwargs)
75
75
# so, assume that if we don't get a rapid reply that things are not installed
76
76
x3 = @prefs_response_time * 3
77
77
Timeout . timeout ( x3 ) do
78
- run ( *args , **kwargs )
78
+ result = run_and_capture ( *args , **kwargs )
79
+ result [ :success ]
79
80
end
80
81
rescue Timeout ::Error
81
82
puts "No response in #{ x3 } seconds. Assuming graphical modal error message#{ message } ."
@@ -97,6 +98,8 @@ def run_and_capture(*args)
97
98
{ out : str_out , err : str_err , success : success }
98
99
end
99
100
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
100
103
def board_installed? ( boardname )
101
104
run_with_gui_guess ( " about board not installed" , "--board" , boardname )
102
105
end
@@ -105,16 +108,16 @@ def board_installed?(boardname)
105
108
# @param name [String] the board name
106
109
# @return [bool] whether the command succeeded
107
110
def install_board ( boardname )
108
- run ( "--install-boards" , boardname )
111
+ run_and_capture ( "--install-boards" , boardname ) [ :success ]
109
112
end
110
113
111
114
# install a library by name
112
115
# @param name [String] the library name
113
116
# @return [bool] whether the command succeeded
114
117
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 ]
118
121
end
119
122
120
123
# update the library index
0 commit comments