Sha256: 1d01767ccb7f0d002d6ee300320716616646eceb3f75bc381f186528a7309018
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
# Copyright (c) 2013-2015 SUSE LLC # # This program is free software; you can redistribute it and/or # modify it under the terms of version 3 of the GNU General Public License as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, contact SUSE LLC. # # To contact SUSE about this file by physical or electronic mail, # you may find current contact information at www.suse.com class PatternsInspector < Inspector def inspect(system, description, _filter, _options = {}) if system.has_command?("zypper") inspect_with_zypper(system, description) else description.patterns = PatternsScope.new "Patterns are not supported on this system." end end private def inspect_with_zypper(system, description) begin xml = system.run_command("zypper", "-xq", "--no-refresh", "patterns", "-i", stdout: :capture) rescue Cheetah::ExecutionFailed => e if e.stdout.include?("locked") Machinery.logger.error(e.stdout) raise Machinery::Errors::ZypperFailed.new( "Zypper is locked." ) else raise end end pattern_list = Nokogiri::XML(xml).xpath("/stream/pattern-list/pattern") if pattern_list.count == 0 description.patterns = PatternsScope.new return "Found 0 patterns." end patterns = pattern_list.map do |pattern| Pattern.new( name: pattern["name"], version: pattern["version"], release: pattern["release"] ) end.uniq.sort_by(&:name) description.patterns = PatternsScope.new(patterns) "Found #{patterns.count} patterns." end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
machinery-tool-1.5.0 | plugins/inspect/patterns_inspector.rb |