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

Commit 2d12677

Browse files
committed
framework: get rid of commands.getstatusoutput()
1 parent e83aa2e commit 2d12677

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Diff for: framework/src/sealert

+7-7
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def fix_lookup_id(local_id, analysis_id):
141141
async_rpc.add_errback(query_alerts_error)
142142

143143
def query_alerts_callback(sigs):
144-
import commands
144+
import subprocess
145145
for siginfo in sigs.signature_list:
146146
for plugin in siginfo.plugin_list:
147147
if analysis_id == plugin.analysis_id:
@@ -151,12 +151,12 @@ def fix_lookup_id(local_id, analysis_id):
151151
cl.main_loop.quit()
152152
return
153153
siginfo.update_derived_template_substitutions()
154-
command = siginfo.substitute(p.get_fix_cmd(siginfo.audit_event, plugin.args))
155-
rc, output = commands.getstatusoutput(command)
156-
if rc == 0:
157-
print _("Successfully ran %s" % command)
158-
else:
159-
print output
154+
command = siginfo.substitute_array(p.get_fix_cmd(siginfo.audit_event, plugin.args).split())
155+
try:
156+
output = subprocess.check_output(command)
157+
print _("Successfully ran %s" % ' '.join(command))
158+
except subprocess.CalledProcessError as e:
159+
print(e.output)
160160
cl.main_loop.quit()
161161
return
162162
print _("Plugin %s not valid for %s id") % (analysis_id, local_id)

Diff for: framework/src/setroubleshoot/signature.py

+3
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,9 @@ def get_plugins(self, all = False):
460460
def substitute(self, txt):
461461
return Template(txt).safe_substitute(self.template_substitutions)
462462

463+
def substitute_array(self, args):
464+
return [self.substitute(txt) for txt in args]
465+
463466
def format_details(self, replace=False):
464467
env = self.environment
465468

0 commit comments

Comments
 (0)