• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# encoding=utf-8
2
3'''
4======================================================================================
5版权 (C) 2020-2025, Huawei Technologies Co., Env
6========================================================================================
7@FileName:    constant.py
8@Function:    def constant var
9@Author:      w00278233
10@Date:        20200424
11======================================================================================
12'''
13
14import platform
15import os
16
17
18
19class CONSTANT(object):
20    ENVERRMESSAGE = ""
21
22    class Box():
23        '''
24        Box相关的常量
25        '''
26        SHORT_TIMEOUT=15
27        GT3000_DEFAULT_PORT=7788
28        OK="0,Success"
29
30    class OSType():
31        '''
32        与操作系统的相关的常量
33        '''
34        PASSWORD = "gongjubu123456!."
35        ACCOUNT = "pwhpdevice"
36        def getworkspace():
37            WORKSPACE= ""
38            if platform.system() == "Linux":
39                WORKSPACE = "/data/MobileUpgrade"
40            if platform.system() == "Windows":
41                WORKSPACE = "D:\MobileUpgrade"
42            return WORKSPACE
43        default_log_dir = os.path.join(getworkspace(), "log")
44
45        def getscripttype():
46            script_file = ""
47            if platform.system() == "Linux":
48                script_file = ".sh"
49            if platform.system() == "Windows":
50                script_file = ".bat"
51            return  script_file
52
53
54    class Board():
55        pass
56
57    class ErrCode():
58        SUCCESS_CODE = 0
59        ERROR_NO_USERCUST_SCRIPT_IN_RESOUCEPOOL = 11
60        ERROR_EXCUTE_USERCUST_SCRIPT_FAIL_IN_RESOUCEPOOL=12
61        ERROR_INVALID_APK_FILE = 33
62        ERROR_CUSTPARAM_IS_NONE=62
63        ERROR_PARAMS_NO_SN=63
64        ERROR_VERSION_USE_CHINAESE=65
65        ERROR_VERSION_IS_NONE=66
66        ERROR_VERSION_PATH_TOO_LONG=67
67        ERROR_CUSTPARAM_NOT_IN_ALLPARAMS=68
68        ERROR_DOWNLOAD_IMG_FAIL=101
69        ERROR_DOWNLOAD_ROOT_FAIL=102
70        RROR_MAKE_DIR_FAIL=103
71        ERROR_DOWNLOAD_APK_FAIL=104
72        ERROR_LOCALPATH_NOT_EXIST=105
73        ERROR_INSTALL_APK_FAIL=106
74        ERROR_NO_UPGRADE_FILE_OR_PACKAGE=107
75        ERROR_DOWNLOAD_VERSION_FAIL=108
76        ERROR_PARSE_RESOURCEPOOL_PARMS_FAIL=109
77        ERROR_DEVICE_IS_FASTBOOT_CAN_NOT_DO_APK_UPGRDE=110
78        ERROR_FLASH_IMAGE_FAIL=111
79        ERROR_FLASH_BASE_FAIL=112
80        ERROR_FLASH_CUST_FAIL=113
81        ERROR_FLASH_PRELOAD_FAIL=114
82        ERROR_BOOT_UP_TIME_OUT=119
83        ERROR_MODEM_CHECK_FAIL=121
84        ERROR_LAUNCHER_CHECK_FAIL=122
85        ERROR_CANNOT_INTO_FASTBOOT_MODE=123
86        ERROR_RESETFACTORY_TIME_OUT=125
87        ERROR_DOWNLOAD_COTA_FAIL=128
88        ERROR_NO_IMG_FILE=131
89        ERROR_NO_SCRIPT_FILE=132
90        ERROR_DEVICE_NOT_FOUND=133
91        ERROR_MODIFY_SCRIPT_FAIL=134
92        ERROR_DEVICE_UNAUTHORIZE=135
93        ERROR_PUSH_FILE_FAIL=136
94        ERROR_VALIDATEPARAMS_FAIL=137
95        ERROR_OTHER_ERROR = 200
96
97    class SysTool():
98        ARIA2CBIN=r"/usr/bin/aria2c"
99
100    class File():
101        LOCK_SUFFIX="file_lock.txt"
102        SUC_FILE="suc.txt"
103        FAILED_FILE="failed.txt"
104
105    class Path():
106        def getDirPath():
107            if platform.system() == "Windows":
108                return "D:\MobileUpgrade\local_img"
109            if platform.system() == "Linux":
110                return "/data/MobileUpgrade/local_img"
111            return "unknow OS"
112
113        def getTftpServerPath():
114            if platform.system() == "Linux":
115                return "/data/nfsuser/data"
116            if platform.system() == "Windows":
117                return "D:\MobileUpgrade\local_img"
118            return "unknow OS"
119
120        def getSavePath():
121            return r'D:\DevicetestTools\upgrade_version.txt'
122
123    class Key():
124        DEV_KEY = "6ba7b8119dad11d180b400c04fd430c8"
125        DEV_DNAME = "b480ff9447a7e874e7065d290b5294c1662e0195a20f0dc60180f8c036bb901e"
126        DEV_PASSWD = "3c5db801e47e4cba7bd0d9bd95bd1540"
127
128