diff options
Diffstat (limited to 'vymgmt/error_distinguish.py')
-rw-r--r-- | vymgmt/error_distinguish.py | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/vymgmt/error_distinguish.py b/vymgmt/error_distinguish.py deleted file mode 100644 index 1f889f8..0000000 --- a/vymgmt/error_distinguish.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright (c) 2016 Hochikong - - -def distinguish_for_set(message): - """Distinguish the error type,PathError or ValueError - - :param message: A error message string from VyOS - :return: The type of error - """ - path_error_string = ['Configuration path:', 'is not valid', 'already exists'] - value_error_string = ['Value validation failed'] - all_strings = [path_error_string, value_error_string] - condition = 0 - for i in all_strings: - for x in i: - if x in message: - condition += 1 - - if condition == 2: - return "ConfigPathError" - elif condition == 1: - return "ConfigValueError" - else: - return "NonsupportButError" - - -def distinguish_for_delete(message): - """Distinguish the error type,PathError or ValueError - - :param message: A error message string from VyOS - :return: The type of error - """ - path_error_string = ['Configuration path:', 'is not valid', 'Delete failed'] - value_error_string = ['Nothing to delete', 'the specified value does not exist', - "the specified node does not exist"] - all_strings = [path_error_string, value_error_string] - condition = 0 - - for i in all_strings: - for x in i: - if x in message: - condition += 1 - - if condition == 3: - return "ConfigPathError" - elif condition == 2: - return "ConfigValueError" - else: - return "NonsupportButError" - - -def distinguish_for_commit(message): - """Distinguish the error type - - :param message: A error message string from VyOS - :return: The type of error - """ - all_strings = ['Commit failed', 'due to another commit in progress'] - - for i in all_strings: - if i in message: - if i == all_strings[0]: - return "CommitFailed" - if i == all_strings[1]: - return "CommitConflict" |