Commit 0420fe31 authored by Jérome Perrin's avatar Jérome Perrin

apachedex: fix argument parsing

Use shlex from standard library which splits arguments properly instead of
implementing our own buggy version.
parent 840e40bb
......@@ -32,7 +32,7 @@ from __future__ import print_function
import os, errno
import subprocess
import argparse
import time
import shlex
from datetime import date
# <apachedex_executable> /srv/etc/output_folder script_name
......@@ -61,8 +61,7 @@ def build_command(apachedex_executable, output_file,
raise ValueError("log_list: no log files to analyse were provided")
if config:
config = filter(None, [x.strip() for x in config.split(' ')])
argument_list += config
argument_list += log_list
......@@ -64,6 +64,19 @@ class TestApachedexCommand(unittest.TestCase):
'--base', 'bar', 'foo',
'--default', 'foo',
'--error-detail', self.acesslog1, self.acesslog2 ])
def test_complexCommandEscape(self):
command = build_command(self.apachedex,
[self.acesslog1, self.acesslog2],
'--base "foo bar"')
self.assertEqual(command, ['/bin/apachedex',
'--out', 'bar.html',
'--base', 'foo bar',
'--error-detail', self.acesslog1, self.acesslog2 ])
def test_raiseErro(self):
self.assertRaises(ValueError, build_command, self.apachedex, 'foo.html', [])
if __name__ == '__main__':
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment