Permalink
Browse files

fix regarding issue #27

Added pycharm to gitignore
Added 2 more tests regarding quoted characters one with # in quote and
other with | in quote
Fix for issue #27
 first split by space then recreate list splited by | sinece shlex
without posix=Trou would split if | was in quote and added commenters =
'' include # in string
  • Loading branch information...
1 parent 32a5360 commit cd53254c2c0c92eccb9c2fe91d7631e7dc25112f @ibeex committed Oct 11, 2012
Showing with 18 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +6 −1 envoy/core.py
  3. +11 −0 test_envoy.py
View
@@ -1 +1,2 @@
*.pyc
+.idea
View
@@ -13,6 +13,7 @@
import signal
import subprocess
import threading
+import itertools
__version__ = '0.0.2'
@@ -174,8 +175,8 @@ def expand_args(command):
# Prepare arguments.
if isinstance(command, str):
splitter = shlex.shlex(command)
- splitter.whitespace = '|'
splitter.whitespace_split = True
+ splitter.commenters = ''
command = []
while True:
@@ -185,7 +186,11 @@ def expand_args(command):
else:
break
+ # http://stackoverflow.com/questions/6164313/make-python-sublists-from-a-list-using-a-seperator
+ command = [list(x[1]) for x in itertools.groupby(command, lambda x: x == '|') if not x[0]]
+ command = [' '.join(x) for x in command]
command = list(map(shlex.split, command))
+ print command
return command
View
@@ -24,6 +24,17 @@ def test_quoted_args(self):
self.assertEqual(r.std_out.rstrip(), sentinel)
self.assertEqual(r.status_code, 0)
+ def test_quoted_args1(self):
+ sentinel = '#quoted_args' * 3
+ r = envoy.run("python -c 'print \"%s\"'" % sentinel)
+ self.assertEqual(r.std_out.rstrip(), sentinel)
+ self.assertEqual(r.status_code, 0)
+
+ def test_quoted_args2(self):
+ sentinel = 'quoted | args' * 3
+ r = envoy.run("python -c 'print \"%s\"'" % sentinel)
+ self.assertEqual(r.std_out.rstrip(), sentinel)
+ self.assertEqual(r.status_code, 0)
class ConnectedCommandTests(unittest.TestCase):
def test_status_code(self):

0 comments on commit cd53254

Please sign in to comment.