Skip to content

Commit

Permalink
clearing folder via subprocess (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-sidelnikov authored Dec 28, 2020
1 parent 0e08e93 commit 979c372
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions csm_test_utils/files_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import hashlib
import os
import requests
import subprocess
from influx_line_protocol import Metric, MetricCollection
from ocomone.logging import setup_logger

Expand Down Expand Up @@ -43,10 +44,9 @@ def md5(file_name):
def create_file(dd_input="/dev/urandom", base_file="/tmp/base_file.data", bs=1200000, count=100):
base_copy = f"{base_file}_copy"
if not os.path.exists(base_file) or (round(time.time() - os.path.getmtime(base_file)) / 60) > 60:
try:
os.system(f"rm {base_file.split('.')[0]}*")
except Exception as Ex:
LOGGER.error(Ex)
files = [i for i in os.listdir()]
if files:
subprocess.call(['rm', '-r'] + files)
os.system(f"/bin/dd if={dd_input} of={base_file} bs={bs} count={count}")
LOGGER.info(f"Base file created at {base_file}")
base_hash = md5(base_file)
Expand Down

0 comments on commit 979c372

Please sign in to comment.