Skip to content

Commit

Permalink
Fix subprocess call (#34)
Browse files Browse the repository at this point in the history
* clearing folder via subprocess

* os.remove

* sort

* one line

* without generators

* os walk for cleaning
  • Loading branch information
anton-sidelnikov authored Dec 28, 2020
1 parent 979c372 commit a674802
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions csm_test_utils/files_rotation.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import hashlib
import logging
import os
import shutil
import sys
import time

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 @@ -44,9 +43,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:
files = [i for i in os.listdir()]
if files:
subprocess.call(['rm', '-r'] + files)
for root, _, files in os.walk(os.path.dirname(base_file)):
for file in files:
os.remove(os.path.join(root, file))
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "csm-test-utils"
version = "0.2.13"
version = "0.2.14"
description = "Utils for testing infrastructure created by customer service monitoring"
authors = ["OTC customer service monitoring team"]
license = "Apache-2.0"
Expand Down

0 comments on commit a674802

Please sign in to comment.