diff options
author | Parth Yadav <parthyadav3105@gmail.com> | 2021-06-14 18:43:20 +0530 |
---|---|---|
committer | Parth Yadav <parthyadav3105@gmail.com> | 2021-06-14 18:48:55 +0530 |
commit | a20b86ed4928ccdc77886b931d0e5014ad9f01c4 (patch) | |
tree | f3b00e66686aca065605ecb0bb246b1738f03451 /sdv/docker/sdvconfig/cli_validation.py | |
parent | 59b843cdd9ea6f704412d760ece42f2a49dfb9cd (diff) |
Fix Dockerfile bugs
Fixes some Dockerfile bugs.
Also, fixes some other syntax bugs, does not covers logical bug fixes.
Signed-off-by: Parth Yadav<parthyadav3105@gmail.com>
Change-Id: I72cfbf058a2c35148337359d78e1fb8f1b3234d3
Diffstat (limited to 'sdv/docker/sdvconfig/cli_validation.py')
-rw-r--r-- | sdv/docker/sdvconfig/cli_validation.py | 17 |
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() |