Sha256: ffd4243fa3c1b145caeb9ca36f65ce4107f67d6e91f3735de273f96280a1e0db
Contents?: true
Size: 953 Bytes
Versions: 1
Compression:
Stored size: 953 Bytes
Contents
require_relative 'logger' module Remon module Helper include Logger def cmd(command, error_msg: nil, return_output: true, env: {}, shell: false) if command.is_a? Array command_arr = command command_str = command.join(" ") else command_arr = command.split command_str = command end logger.debug command_str run_command = shell ? command_str : command_arr output = if return_output IO.popen(env, run_command) { |f| f.read } else system(env, run_command, 2 => 1) end exitstatus = $?.exitstatus if exitstatus != 0 error_msg ||= "non zero exit for \"#{command_str}\"" raise Error, error_msg end return output end def safe_cmd(*args, **kwargs) output = cmd(*args, **kwargs) return $?.exitstatus, output rescue => e logger.debug e.message return -1, nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
remon-0.1.0 | lib/remon/helper.rb |