Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clearing folder via subprocess #32

Merged
merged 1 commit into from
Dec 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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