From: Rishabh Dave Date: Thu, 11 Apr 2019 17:16:47 +0000 (+0530) Subject: qa: move checks on command arguments to a different method X-Git-Tag: v15.1.0~2911^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=512f4721a57b4d986fa104bfdaf99f3258b7c8f5;p=ceph.git qa: move checks on command arguments to a different method Signed-off-by: Rishabh Dave --- diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index ece01701baf7..5555eae9c521 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -234,22 +234,30 @@ class LocalRemote(object): def put_file(self, src, dst, sudo=False): shutil.copy(src, dst) - def run(self, args, check_status=True, wait=True, - stdout=None, stderr=None, cwd=None, stdin=None, - logger=None, label=None, env=None, timeout=None, omit_sudo=True): - if str(type(args)).find('str') != -1: + def _perform_checks_and_return_list_of_args(self, args, omit_sudo): + # Since Python's shell simulation can only work when commands are + # provided as a list of argumensts... + if isinstance(args, str): args = args.split() + # We'll let sudo be a part of command even omit flag says otherwise in + # cases of commands which can normally be ran only by root. try: if args[args.index('sudo') + 1] in ['-u', 'passwd', 'chown']: omit_sudo = False except ValueError: pass - # We don't need no stinkin' sudo if omit_sudo: args = [a for a in args if a != "sudo"] + return args + + def run(self, args, check_status=True, wait=True, + stdout=None, stderr=None, cwd=None, stdin=None, + logger=None, label=None, env=None, timeout=None, omit_sudo=True): + args = self._perform_checks_and_return_list_of_args(args, omit_sudo) + # We have to use shell=True if any run.Raw was present, e.g. && shell = any([a for a in args if isinstance(a, Raw)])