aboutsummaryrefslogtreecommitdiffstats
path: root/sdv/docker/sdvconfig/cli_validation.py
diff options
context:
space:
mode:
Diffstat (limited to 'sdv/docker/sdvconfig/cli_validation.py')
-rw-r--r--sdv/docker/sdvconfig/cli_validation.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/sdv/docker/sdvconfig/cli_validation.py b/sdv/docker/sdvconfig/cli_validation.py
index 70e498e..30477fd 100644
--- a/sdv/docker/sdvconfig/cli_validation.py
+++ b/sdv/docker/sdvconfig/cli_validation.py
@@ -70,7 +70,7 @@ class Validate():
# create a directory called /tmp
try:
- os.mkdir('/tmp')
+ os.makedirs('/tmp', exist_ok=True)
except OSError:
self.logger.exception("creation of directory failed")
raise
@@ -87,7 +87,10 @@ class Validate():
# clone the installer repo
try:
- Repo.clone_from(inst_dir, os.path.join('/tmp', 'inst'))
+ clone_dir = os.path.join('/tmp', 'inst')
+ if os.path.exists(clone_dir) and os.path.isdir(clone_dir):
+ shutil.rmtree(clone_dir)
+ Repo.clone_from(inst_dir, clone_dir)
self.inst_dir = os.path.join('/tmp', 'inst')
self.downloaded = True
except ConnectionError:
@@ -98,7 +101,10 @@ class Validate():
# download the global file
try:
- Repo.clone_from(GLOBAL_DIR, os.path.join('/tmp', 'global'))
+ clone_dir = os.path.join('/tmp', 'global')
+ if os.path.exists(clone_dir) and os.path.isdir(clone_dir):
+ shutil.rmtree(clone_dir)
+ Repo.clone_from(GLOBAL_DIR, clone_dir)
self.gsw = os.path.join('/tmp', 'global', 'global', 'software')
except ConnectionError:
self.logger.exception("failed to download the global git repo")
@@ -153,6 +159,7 @@ class Validate():
self.total))
self.result += result + string
+
# iterate through the roles: have a class for each for each of the roles
for _, value in enumerate(self.json["roles"]):
role = value["name"]
@@ -208,7 +215,7 @@ class Validate():
correct, wrong, total))
self.result += result + string
- self.testapi_result["timestamp"] = datetime.datetime.now()
+ self.testapi_result["timestamp"] = datetime.datetime.now().isoformat()
self.testapi_result["correct"] = self.correct
self.testapi_result["wrong"] = self.wrong
self.testapi_result["total"] = self.total
@@ -246,4 +253,4 @@ if __name__ == "__main__":
# Read arguments from the command line
ARGS = PARSER.parse_args()
- print(ARGS.inst_dir, ARGS.inst_type, ARGS.pdf, ARGS.sitename).validate()
+ Validate(ARGS.inst_dir, ARGS.inst_type, ARGS.pdf, ARGS.sitename).validate()