aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-05-25 00:47:35 -0700
committerMorgan Richomme <morgan.richomme@orange.com>2020-05-25 14:06:11 +0000
commitf2b1483c7d56666c4186183463fff516f5f99900 (patch)
treed41596c8c4bfb4c9f24fbe6cb5b77572bd57f7f3
parent61a35bca9ce57331289e097b32a7db722f6e4da3 (diff)
Drop shell 'rm' command and use 'rmtree' native Python routine
Change-Id: Id5487723b8eb6fdc065ffe712907f9a715f610c5 Issue-ID: INT-1577 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
-rwxr-xr-xtest/mocks/mass-pnf-sim/MassPnfSim.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/test/mocks/mass-pnf-sim/MassPnfSim.py b/test/mocks/mass-pnf-sim/MassPnfSim.py
index dde622ac9..d15b69551 100755
--- a/test/mocks/mass-pnf-sim/MassPnfSim.py
+++ b/test/mocks/mass-pnf-sim/MassPnfSim.py
@@ -1,11 +1,11 @@
#!/usr/bin/env python3
import logging
-import subprocess
+from subprocess import run, CalledProcessError
import argparse
import ipaddress
from sys import exit
from os import chdir, getcwd, path
-from shutil import copytree
+from shutil import copytree, rmtree
from json import dumps
from glob import glob
from requests import get
@@ -139,11 +139,11 @@ class MassPnfSim:
old_pwd = getcwd()
try:
chdir(dir_context)
- subprocess.run(cmd, check=True, shell=True)
+ run(cmd, check=True, shell=True)
chdir(old_pwd)
except FileNotFoundError:
self.logger.error(f"Directory {dir_context} not found")
- except subprocess.CalledProcessError as e:
+ except CalledProcessError as e:
exit(e.returncode)
def _enum_sim_instances(self):
@@ -223,7 +223,8 @@ class MassPnfSim:
def clean(self):
self.logger.info('Cleaning simulators workdirs')
- self._run_cmd(f"rm -rf {self.sim_dirname_pattern}*")
+ for sim_id in range(self.existing_sim_instances):
+ rmtree(f"{self.sim_dirname_pattern}{sim_id}")
@_MassPnfSim_Decorators.do_action('Starting', './simulator.sh start')
def start(self):