1#!/usr/bin/env python3 2# coding=utf-8 3 4# 5# Copyright (c) 2021 Huawei Device Co., Ltd. 6# Licensed under the Apache License, Version 2.0 (the "License"); 7# you may not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17# 18 19from xdevice import DeviceError 20 21 22class HdcError(DeviceError): 23 """ 24 Raised when there is an error in hdc operations. 25 """ 26 27 def __init__(self, error_msg, error_no=""): 28 super(HdcError, self).__init__(error_msg, error_no) 29 self.error_msg = error_msg 30 self.error_no = error_no 31 32 def __str__(self): 33 return str(self.error_msg) 34 35 36class HdcCommandRejectedException(HdcError): 37 """ 38 Exception thrown when hdc refuses a command. 39 """ 40 41 def __init__(self, error_msg, error_no=""): 42 super(HdcCommandRejectedException, self).__init__(error_msg, error_no) 43 self.error_msg = error_msg 44 self.error_no = error_no 45 46 def __str__(self): 47 return str(self.error_msg) 48 49 50class ShellCommandUnresponsiveException(HdcError): 51 """ 52 Exception thrown when a shell command executed on a device takes too long 53 to send its output. 54 """ 55 def __init__(self, error_msg="ShellCommandUnresponsiveException", 56 error_no=""): 57 super(ShellCommandUnresponsiveException, self).\ 58 __init__(error_msg, error_no) 59 self.error_msg = error_msg 60 self.error_no = error_no 61 62 def __str__(self): 63 return str(self.error_msg) 64 65 66class DeviceUnresponsiveException(HdcError): 67 """ 68 Exception thrown when a shell command executed on a device takes too long 69 to send its output. 70 """ 71 def __init__(self, error_msg="DeviceUnresponsiveException", error_no=""): 72 super(DeviceUnresponsiveException, self).__init__(error_msg, error_no) 73 self.error_msg = error_msg 74 self.error_no = error_no 75 76 def __str__(self): 77 return str(self.error_msg) 78 79 80class AppInstallError(DeviceError): 81 def __init__(self, error_msg, error_no=""): 82 super(AppInstallError, self).__init__(error_msg, error_no) 83 self.error_msg = error_msg 84 self.error_no = error_no 85 86 def __str__(self): 87 return str(self.error_msg) 88 89 90class HapNotSupportTest(DeviceError): 91 def __init__(self, error_msg, error_no=""): 92 super(HapNotSupportTest, self).__init__(error_msg, error_no) 93 self.error_msg = error_msg 94 self.error_no = error_no 95 96 def __str__(self): 97 return str(self.error_msg) 98