Skip to content
Permalink
Browse files

framework: get rid of commands.getstatusoutput()

  • Loading branch information...
bachradsusi committed Apr 9, 2015
1 parent e83aa2e commit 2d12677629ca319310f6263688bb1b7f676c01b7
Showing with 10 additions and 7 deletions.
  1. +7 −7 framework/src/sealert
  2. +3 −0 framework/src/setroubleshoot/signature.py
@@ -141,7 +141,7 @@ def fix_lookup_id(local_id, analysis_id):
async_rpc.add_errback(query_alerts_error)

def query_alerts_callback(sigs):
import commands
import subprocess
for siginfo in sigs.signature_list:
for plugin in siginfo.plugin_list:
if analysis_id == plugin.analysis_id:
@@ -151,12 +151,12 @@ def fix_lookup_id(local_id, analysis_id):
cl.main_loop.quit()
return
siginfo.update_derived_template_substitutions()
command = siginfo.substitute(p.get_fix_cmd(siginfo.audit_event, plugin.args))
rc, output = commands.getstatusoutput(command)
if rc == 0:
print _("Successfully ran %s" % command)
else:
print output
command = siginfo.substitute_array(p.get_fix_cmd(siginfo.audit_event, plugin.args).split())
try:
output = subprocess.check_output(command)
print _("Successfully ran %s" % ' '.join(command))
except subprocess.CalledProcessError as e:
print(e.output)
cl.main_loop.quit()
return
print _("Plugin %s not valid for %s id") % (analysis_id, local_id)
@@ -460,6 +460,9 @@ def get_plugins(self, all = False):
def substitute(self, txt):
return Template(txt).safe_substitute(self.template_substitutions)

def substitute_array(self, args):
return [self.substitute(txt) for txt in args]

def format_details(self, replace=False):
env = self.environment

0 comments on commit 2d12677

Please sign in to comment.
You can’t perform that action at this time.