From e1d98597b93f6e2befa8d23ac479b11b78e479c1 Mon Sep 17 00:00:00 2001 From: z30043230 Date: Sat, 19 Jul 2025 18:29:47 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=AE=89=E5=85=A8=E3=80=91input?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E6=B2=A1=E6=9C=89=E6=A0=A1=E9=AA=8C=E5=A4=96?= =?UTF-8?q?=E9=83=A8=E8=BE=93=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msprof_analyze/prof_common/file_manager.py | 18 ++++++++---------- .../msprof_analyze/prof_common/path_manager.py | 13 +++++-------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/profiler/msprof_analyze/prof_common/file_manager.py b/profiler/msprof_analyze/prof_common/file_manager.py index 064eb3f039..737d178841 100644 --- a/profiler/msprof_analyze/prof_common/file_manager.py +++ b/profiler/msprof_analyze/prof_common/file_manager.py @@ -36,11 +36,10 @@ class FileManager: if file_size <= 0: return result_data if not AdditionalArgsManager().force and file_size > Constant.MAX_FILE_SIZE: - check_msg = input( - f"The file({file_path}) size exceeds the preset max value. Continue reading the file? [y/n]") - if check_msg.lower() != "y": - logger.warning("The user choose not to read the file: %s", file_path) - return result_data + logger.warning(f"The file({file_path}) size is {file_size} Byte, exceeds the preset max value. You can add " + f"the '--force' parameter and retry. This parameter will ignore the file owner and " + f"file size!") + return result_data try: with open(file_path, "r") as json_file: result_data = json.loads(json_file.read()) @@ -57,11 +56,10 @@ class FileManager: if file_size <= 0: return [] if not AdditionalArgsManager().force and file_size > Constant.MAX_FILE_SIZE: - check_msg = input( - f"The file({file_path}) size exceeds the preset max value. Continue reading the file? [y/n]") - if check_msg.lower() != "y": - logger.warning(f"The user choose not to read the file: {file_path}") - return [] + logger.warning(f"The file({file_path}) size is {file_size} Byte, exceeds the preset max value. You can add " + f"the '--force' parameter and retry. This parameter will ignore the file owner and " + f"file size!") + return [] result_data = [] try: with open(file_path, newline="") as csv_file: diff --git a/profiler/msprof_analyze/prof_common/path_manager.py b/profiler/msprof_analyze/prof_common/path_manager.py index 05970362ba..0b92ebc2de 100644 --- a/profiler/msprof_analyze/prof_common/path_manager.py +++ b/profiler/msprof_analyze/prof_common/path_manager.py @@ -111,10 +111,8 @@ class PathManager: if not os.path.exists(path): continue if os.stat(path).st_uid != os.getuid(): - check_msg = input("The path does not belong to you, do you want to continue? [y/n]") - if check_msg.lower() != "y": - raise RuntimeError("The user choose not to continue.") - return + raise RuntimeError("The path does not belong to you. You can add the '--force' parameter and " + "retry. This parameter will ignore the file owner and file size!") @classmethod def check_path_writeable(cls, path): @@ -211,10 +209,9 @@ class PathManager: return file_size = os.path.getsize(file_path) if file_size > Constant.MAX_FILE_SIZE_5_GB: - check_msg = input( - f"The file({file_path}) size exceeds the preset max value. Continue reading the file? [y/n]") - if check_msg.lower() != "y": - raise RuntimeError(f"[WARNING] The user choose not to read the file: {file_path}") + raise RuntimeError(f"The file({file_path}) size is {file_size} Byte, exceeds the preset max value. " + f"You can add the '--force' parameter and retry. This parameter will ignore " + f"the file owner and file size!") @classmethod def expanduser_for_cli(cls, ctx, parm, str_name: str): -- Gitee