diff --git a/src/configService.py b/src/configService.py index c7481b332770880c75b4448ae5dfb9b618ec8198..ad73f3a5361b6de0a6dce810cc45cac549a3d468 100644 --- a/src/configService.py +++ b/src/configService.py @@ -18,6 +18,13 @@ class ConfigService: if not os.path.isfile(config_path): print("config_path not found, switch failed.") return + contents = self.tool.read_file(config_file) + # keys should contains in config + keys = ["DOWNLOAD","DEPENDENCY","ENV","APP","BUILD","RUN"] + for key in keys: + if f"[{key}]" not in contents: + print(f"key [{key}] not found in {config_file}, switch failed.") + return self.tool.write_file(self.meta_path, config_file.strip()) print("Successfully switched. config file saved in file .meta") diff --git a/src/toolService.py b/src/toolService.py index 0942dfcec8df7807509f190b34a835d498e40bfc..0cb256700c82218b59f7b6c30772456dccc31ae5 100644 --- a/src/toolService.py +++ b/src/toolService.py @@ -42,6 +42,12 @@ class ToolService: with open(filename, 'w') as f: f.write(content) + def del_file(self, filepath): + """ + 删除文件。 + """ + if os.path.exists(filepath): + os.remove(filepath) def mkdirs(self, path): """ @@ -66,4 +72,4 @@ class ToolService: response = requests.get(url, stream=True) return response.status_code == 200 except requests.exceptions.RequestException as e: - return False \ No newline at end of file + return False