Module: check_mk
Branch: master
Commit: 3d68cb79e5b7bd41ce4ae4e4663b5e39b2f0cb48
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3d68cb79e5b7bd…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Nov 11 17:35:04 2016 +0100
Cleaned up unused code and removed another subprocess with shell execution
---
web/htdocs/multitar.py | 19 +++----------------
1 file changed, 3 insertions(+), 16 deletions(-)
diff --git a/web/htdocs/multitar.py b/web/htdocs/multitar.py
index 37b6dcb..f9c874f 100644
--- a/web/htdocs/multitar.py
+++ b/web/htdocs/multitar.py
@@ -71,12 +71,6 @@ def extract_from_buffer(buffer, elements):
elif type(elements) == dict:
extract_domains(tarfile.open(None, "r", stream), elements)
-def extract_from_file(filename, elements):
- if type(elements) == list:
- extract(tarfile.open(filename, "r"), elements)
- elif type(elements) == dict:
- extract_domains(tarfile.open(filename, "r"), elements)
-
def list_tar_content(the_tarfile):
files = {}
try:
@@ -100,7 +94,6 @@ def get_file_content(the_tarfile, filename):
def extract_domains(tar, domains):
- import subprocess
tar_domains = {}
for member in tar.getmembers():
try:
@@ -193,15 +186,9 @@ def extract_domains(tar, domains):
# The complete tar.gz file never fits in stringIO buffer..
tar.extract(tar_member, restore_dir)
- if domain.get("restore_command"):
- path_subtar = "%s/%s" % (restore_dir, tar_member.name)
- command = domain.get("restore_command") % { "prefix"
: target_dir,
- "restore_dir" :
restore_dir,
- "path_subtar" :
path_subtar }
- else:
- command = "tar xzf %s/%s -C %s" % (restore_dir,
tar_member.name, target_dir)
-
- p = subprocess.Popen(command, shell = True, stdout = subprocess.PIPE, stderr
= subprocess.PIPE)
+ command = [ "tar", "xzf", "%s/%s" %
(restore_dir, tar_member.name),
+ "-C", target_dir ]
+ p = subprocess.Popen(command, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
exit_code = p.wait()
if exit_code: