]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa: looks for quotes in Python shell and get rid of them
authorRishabh Dave <ridave@redhat.com>
Thu, 11 Apr 2019 18:11:53 +0000 (23:41 +0530)
committerRishabh Dave <ridave@redhat.com>
Fri, 12 Apr 2019 09:30:58 +0000 (15:00 +0530)
Since quotes are not a token for Python's shell simulation (unlike
Bash), raise a RuntimeError for them and add an exception for Python
command since it quotes to define a program on commandline.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/tasks/vstart_runner.py

index 5555eae9c52163f227faa8bca30b30d4c315bca5..4991ef24729fc9e92ee50230dbd5e1fc251da525 100644 (file)
@@ -248,6 +248,21 @@ class LocalRemote(object):
         except ValueError:
             pass
 
+        # Quotes don't work in Python's shell simulation as a bash user would
+        # expect. However, it works fine it has special meaning for the given
+        # command (writing a small python program on the command line).
+        if 'sudo' in args and 'python' not in args and \
+           'python2' not in args and 'python3' not in args:
+            if '-c' in args:
+                args_to_check = args[args.index('-c') + 1 : ]
+            else:
+                args_to_check = args
+
+            for arg in args_to_check:
+                if arg.find("'") != -1 or arg.find('"') != -1:
+                    raise RuntimeError("Don't surround commands by "
+                                       "single/double quotes")
+
         if omit_sudo:
             args = [a for a in args if a != "sudo"]