Skip to content
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.

Commit

Permalink
framework: get rid of commands.getstatusoutput()
Browse files Browse the repository at this point in the history
  • Loading branch information
bachradsusi committed Apr 9, 2015
1 parent e83aa2e commit 2d12677
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 7 additions & 7 deletions framework/src/sealert
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions framework/src/setroubleshoot/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2d12677

Please sign in to comment.