How to use get_command method in avocado

Best Python code snippet using avocado_python

CommandHanlder.py

Source:CommandHanlder.py Github

copy

Full Screen

1# -*- coding:UTF-8 -*-2import sys3from PLog import logger4from RestHandler import RestApiPost5from DeviceCommands import DeviceCommandTypes,DeviceCommandGenerator6from DataTypes import PLCComand,PLCComandList,PLCResults7from RestHandler import RestApiPost8class CommandHandler:9 def __init__(self,url):10 self.webApiUrl = url11 12 def ExecuteRestApi(self,command):13 res = RestApiPost(self.webApiUrl,command)14 return res15 def FormantAndRunCommand(self,command,args):16 rtval = command17 alength = len(args)18 if alength > 0:19 for index in range(0,alength):20 tempstr = "{" + str(index) + "}"21 rtval = rtval.replace(tempstr,args[index])22 logger.info(rtval)23 rtval = self.ExecuteRestApi(rtval)24 return rtval25 def RunPLCCommand2(self,command):26 rtval = self.ExecuteRestApi(command)27 return rtval28 def RunPLCCommand(self,commandtype,args):29 rtval = ""30 generator = DeviceCommandGenerator()31 length = len(args)32 33 if commandtype == DeviceCommandTypes.ML_5K_HS_TB_WD_SET_ALL and length == 2:34 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)35 elif commandtype == DeviceCommandTypes.ML_5K_HS_TB_WD_RESET_ALL and length == 2:36 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)37 elif commandtype == DeviceCommandTypes.ML_5K_HS_TB_WD_READ_HMI:38 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)39 elif commandtype == DeviceCommandTypes.ML_5K_HS_TB_WD_READ_TEMPS:40 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)41 elif commandtype == DeviceCommandTypes.ML_5K_HS_TB_WD_SET_TEMPS and length == 2:42 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)43 elif commandtype == DeviceCommandTypes.ML_5K_HS_TB_WD_SET_TIC_COS and length == 2:44 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)45 elif commandtype == DeviceCommandTypes.ML_5K_HS_TB_WD_SWITCH_MAN:46 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)47 elif commandtype == DeviceCommandTypes.ML_5K_HS_TB_WD_SWITCH_AUTO:48 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)49 elif commandtype == DeviceCommandTypes.SIM_TEST_D1_T1 and length == 1:50 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)51 elif commandtype == DeviceCommandTypes.SIM_TEST_D1_T2 and length == 1:52 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)53 elif commandtype == DeviceCommandTypes.SIM_TEST_D1_T4 and length == 1:54 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)55 elif commandtype == DeviceCommandTypes.ML_5H_5H_LD5_TEST_SET_ALL and length == 2:56 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)57 elif commandtype == DeviceCommandTypes.ML_5H_5H_LD5_TEST_RESET_ALL and length == 2:58 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)59 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_YYHC_SET_YYHCLL and length == 1:60 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)61 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_YYHC_SET_SFYTDH and length == 2:62 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)63 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_YYHC_SET_RFWD and length == 1:64 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)65 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_YYHC_SET_RKSF and length == 1:66 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)67 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_YYHC_SET_CKSF and length == 1:68 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)69 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_YYHC_SET_JSXS and length == 1:70 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)71 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_YYHC_SET_ZKDZCLL and length == 1:72 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)73 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_BPHCLL and length == 1:74 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)75 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_SFYTDH and length == 2:76 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)77 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_RFWD and length == 1:78 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)79 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_RKSF and length == 1:80 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)81 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_CKSF and length == 1:82 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)83 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_JSBL and length == 1:84 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)85 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_CKSFSX and length == 1:86 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)87 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_CKSFXX and length == 1:88 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)89 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_CKSFBL and length == 1:90 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)91 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_TLJSL and length == 1:92 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)93 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_WLJSL and length == 1:94 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)95 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_YYLL and length == 1:96 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)97 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_SFYTDH and length == 2:98 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)99 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_JLBL and length == 1:100 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)101 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_RFWD and length == 1:102 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)103 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_LT1WD and length == 1:104 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)105 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_LT2WD and length == 1:106 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)107 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_TLXZXS and length == 1:108 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)109 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_WLXZXS and length == 1:110 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)111 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_WLLL and length == 1:112 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)113 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_JSXS and length == 1:114 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)115 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_JSBL and length == 1:116 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)117 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_CKHSL and length == 1:118 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)119 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_DSFW and length == 1:120 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)121 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_READ_YLAN:122 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)123 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_LTXZ1 and length == 1:124 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)125 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_LTXZ2 and length == 1:126 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)127 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_READ_LYAN:128 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)129 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_LYDM1 and length == 1:130 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)131 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_LYDM2 and length == 1:132 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)133 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HS_SET_LLLL and length == 1:134 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)135 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HS_SET_SIROX and length == 1:136 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)137 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HS_SET_RFFS and length == 1:138 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)139 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HS_SET_RFWD and length == 1:140 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)141 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HS_SET_CKSF and length == 1:142 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)143 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HS_SET_SFYTD and length == 2:144 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)145 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HS_SET_TSSD and length == 1:146 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)147 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_HCZHQD:148 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)149 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_READ_JLZHQD_LT1XZ:150 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)151 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_READ_JLZHQD_LT1ZL:152 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)153 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_READ_JLZHQD_LT2XZ:154 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)155 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_READ_JLZHQD_LT2ZL:156 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)157 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_JLZHQD:158 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)159 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_QSZHQD:160 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)161 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_HSZHQD:162 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)163 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_HCZHTZ:164 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)165 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_JLZHTZ:166 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)167 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_QSZHTZ:168 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)169 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_HSZHTZ:170 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)171 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZYR_HCYRQD:172 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)173 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZYR_HCYRTZ:174 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)175 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZYR_JLYRQD:176 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)177 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZYR_JLYRTZ:178 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)179 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_READ_KZMS:180 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)181 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZYR_SIROX_YRQD:182 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)183 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZYR_SIROX_YRTZ:184 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)185 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZYR_HSYRQD:186 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)187 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZYR_HSYRTZ:188 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)189 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZLQ_HSLQKS:190 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)191 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZLQ_HSLQTZ:192 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)193 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZLQ_SIROXLQKS:194 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)195 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZLQ_SIROXLQTZ:196 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)197 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTZ_HSSCKS:198 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)199 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTZ_HSSCTZ:200 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)201 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTZ_HSSCZT:202 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)203 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZFW:204 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)205 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZQX_SIROXQJKS:206 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)207 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZQX_SIROXQJTZ:208 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)209 elif commandtype == DeviceCommandTypes.ML_5K_HS_HC_SET_JSXS and length == 1:210 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)211 elif commandtype == DeviceCommandTypes.ML_5K_HS_JL_SET_JSXS and length == 1:212 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)213 elif commandtype == DeviceCommandTypes.ML_5K_HS_JL_SET_JSBL and length == 1:214 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)215 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_YYHC_SET_YPGXGDZD:216 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)217 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_YYHC_SET_YPGLJXZ:218 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)219 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_YPGXGDZD:220 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)221 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_YGRGZTZD:222 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)223 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_YGXZLJ:224 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)225 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTS_JLSCTS:226 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)227 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTS_JLQZTZ:228 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)229 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTS_JLQZTS:230 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)231 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTS_BPHCSCTS:232 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)233 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTS_BPHCQZTZ:234 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)235 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTS_BPHCQZTS:236 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)237 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTS_HCSCTS:238 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)239 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTS_HCQZTZ:240 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)241 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTS_HCQZTS:242 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)243 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_PCHGDHPH_HC and length == 3:244 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)245 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_PCHGDHPH_JL and length == 3:246 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)247 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_PCHGDHPH_BPHC and length == 3:248 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)249 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_BPHCYL_Q:250 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)251 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_BPHCYL_T:252 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)253 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_Get_YPGXGRGQRDW_7:254 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)255 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_Get_YPGXGRGQRDW_6:256 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)257 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_Get_YPGXGRGQRDW_5:258 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)259 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_Get_YPGXGRGQRDW_4:260 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)261 elif commandtype == DeviceCommandTypes.ML_5K_KTMX_FM_Set_KD and length == 6:262 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)263 elif commandtype == DeviceCommandTypes.ML_5K_KTMX_SFJ_Set_PLKJ and length == 1:264 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)265 elif commandtype == DeviceCommandTypes.ML_5K_KTMX_SFJ_Set_PLGJ and length == 1:266 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype),args)267 else:268 logger.error("Error: Wrong Command, type:" + str(commandtype) + ",args: " + str(args))269 return rtval270if __name__ == '__main__': 271 url = "http://localhost:64035/api/PLCAPI"272 handler = CommandHandler(url)273 # res = handler.RunPLCCommand(DeviceCommandTypes.SIM_TEST_D1_T1,["11"])274 # print(res)275 # res = handler.RunPLCCommand(DeviceCommandTypes.SIM_TEST_D1_T2,["12"])276 # print(res)277 # res = handler.RunPLCCommand(DeviceCommandTypes.SIM_TEST_D1_T4,["14"])278 # print(res)279 # res = handler.RunPLCCommand(DeviceCommandTypes.ML_5K_HS_TB_WD_SET_ALL,["100","110"])280 # print(res)281 # res = handler.RunPLCCommand(DeviceCommandTypes.ML_5K_HS_TB_WD_RESET_ALL,["105","105"])282 # print(res)283 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5H_5H_LD5_TEST_SET_ALL,["105","125"])284 print(res)285 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5H_5H_LD5_TEST_RESET_ALL,["110","120"])286 print(res)287 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5K_HS_TB_WD_READ_HMI,[])288 print(res)289 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5K_HS_TB_WD_READ_TEMPS,[])290 print(res)291 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5K_HS_TB_WD_SET_TEMPS,["110","120"])292 print(res)293 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5K_HS_TB_WD_SET_TIC_COS,["0","0"])294 print(res)295 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5K_HS_TB_WD_SWITCH_MAN,[])296 print(res)297 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5K_HS_TB_WD_SWITCH_AUTO,[])298 print(res)299 res = handler.RunPLCCommand(DeviceCommandTypes.SIM_TEST_D1_T1, ["12"])300 print(res)301 res = handler.RunPLCCommand(DeviceCommandTypes.SIM_TEST_D1_T2, ["13"])302 print(res)303 304 res = handler.RunPLCCommand(DeviceCommandTypes.SIM_TEST_D1_T4, ["14"])305 print(res)306 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5H_5H_LD5_TEST_SET_ALL, ["120","111"])307 print(res)308 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5H_5H_LD5_TEST_RESET_ALL, ["120","111"])...

Full Screen

Full Screen

CommandHandler.py

Source:CommandHandler.py Github

copy

Full Screen

1# -*- coding:UTF-8 -*-2import sys3from src.PythonDeviceControlLib.DeviceCommands import DeviceCommandGenerator, DeviceCommandTypes4from src.PythonDeviceControlLib.PLog import logger5from src.PythonDeviceControlLib.RestHandler import RestApiPost6class CommandHandler:7 def __init__(self, url):8 self.webApiUrl = url9 def ExecuteRestApi(self, command):10 res = RestApiPost(self.webApiUrl, command)11 return res12 def FormantAndRunCommand(self, command, args):13 rtval = command14 alength = len(args)15 if alength > 0:16 for index in range(0, alength):17 tempstr = "{" + str(index) + "}"18 rtval = rtval.replace(tempstr, args[index])19 logger.info(rtval)20 rtval = self.ExecuteRestApi(rtval)21 return rtval22 def RunPLCCommand2(self, command):23 rtval = self.ExecuteRestApi(command)24 return rtval25 def RunPLCCommand(self, commandtype, args):26 rtval = ""27 generator = DeviceCommandGenerator()28 length = len(args)29 if commandtype == DeviceCommandTypes.ML_5K_HS_TB_WD_SET_ALL and length == 2:30 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)31 elif commandtype == DeviceCommandTypes.ML_5K_HS_TB_WD_RESET_ALL and length == 2:32 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)33 elif commandtype == DeviceCommandTypes.ML_5K_HS_TB_WD_READ_HMI:34 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)35 elif commandtype == DeviceCommandTypes.ML_5K_HS_TB_WD_READ_TEMPS:36 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)37 elif commandtype == DeviceCommandTypes.ML_5K_HS_TB_WD_SET_TEMPS and length == 2:38 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)39 elif commandtype == DeviceCommandTypes.ML_5K_HS_TB_WD_SET_TIC_COS and length == 2:40 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)41 elif commandtype == DeviceCommandTypes.ML_5K_HS_TB_WD_SWITCH_MAN:42 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)43 elif commandtype == DeviceCommandTypes.ML_5K_HS_TB_WD_SWITCH_AUTO:44 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)45 elif commandtype == DeviceCommandTypes.SIM_TEST_D1_T1 and length == 1:46 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)47 elif commandtype == DeviceCommandTypes.SIM_TEST_D1_T2 and length == 1:48 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)49 elif commandtype == DeviceCommandTypes.SIM_TEST_D1_T4 and length == 1:50 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)51 elif commandtype == DeviceCommandTypes.ML_5H_5H_LD5_TEST_SET_ALL and length == 2:52 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)53 elif commandtype == DeviceCommandTypes.ML_5H_5H_LD5_TEST_RESET_ALL and length == 2:54 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)55 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_YYHC_SET_YYHCLL and length == 1:56 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)57 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_YYHC_SET_SFYTDH and length == 2:58 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)59 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_YYHC_SET_RFWD and length == 1:60 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)61 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_YYHC_SET_RKSF and length == 1:62 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)63 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_YYHC_SET_CKSF and length == 1:64 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)65 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_YYHC_SET_JSXS and length == 1:66 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)67 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_YYHC_SET_ZKDZCLL and length == 1:68 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)69 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_BPHCLL and length == 1:70 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)71 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_SFYTDH and length == 2:72 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)73 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_RFWD and length == 1:74 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)75 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_RKSF and length == 1:76 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)77 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_CKSF and length == 1:78 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)79 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_JSBL and length == 1:80 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)81 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_CKSFSX and length == 1:82 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)83 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_CKSFXX and length == 1:84 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)85 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_CKSFBL and length == 1:86 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)87 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_TLJSL and length == 1:88 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)89 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_BPHC_SET_WLJSL and length == 1:90 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)91 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_YYLL and length == 1:92 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)93 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_SFYTDH and length == 2:94 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)95 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_JLBL and length == 1:96 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)97 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_RFWD and length == 1:98 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)99 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_LT1WD and length == 1:100 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)101 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_LT2WD and length == 1:102 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)103 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_TLXZXS and length == 1:104 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)105 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_WLXZXS and length == 1:106 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)107 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_WLLL and length == 1:108 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)109 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_JSXS and length == 1:110 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)111 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_JSBL and length == 1:112 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)113 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_CKHSL and length == 1:114 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)115 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_DSFW and length == 1:116 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)117 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_READ_YLAN:118 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)119 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_LTXZ1 and length == 1:120 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)121 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_LTXZ2 and length == 1:122 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)123 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_READ_LYAN:124 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)125 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_LYDM1 and length == 1:126 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)127 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_LYDM2 and length == 1:128 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)129 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HS_SET_LLLL and length == 1:130 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)131 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HS_SET_SIROX and length == 1:132 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)133 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HS_SET_RFFS and length == 1:134 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)135 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HS_SET_RFWD and length == 1:136 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)137 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HS_SET_CKSF and length == 1:138 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)139 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HS_SET_SFYTD and length == 2:140 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)141 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HS_SET_TSSD and length == 1:142 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)143 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_HCZHQD:144 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)145 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_READ_JLZHQD_LT1XZ:146 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)147 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_READ_JLZHQD_LT1ZL:148 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)149 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_READ_JLZHQD_LT2XZ:150 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)151 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_READ_JLZHQD_LT2ZL:152 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)153 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_JLZHQD:154 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)155 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_QSZHQD:156 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)157 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_HSZHQD:158 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)159 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_HCZHTZ:160 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)161 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_JLZHTZ:162 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)163 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_QSZHTZ:164 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)165 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_HSZHTZ:166 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)167 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZYR_HCYRQD:168 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)169 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZYR_HCYRTZ:170 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)171 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZYR_JLYRQD:172 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)173 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZYR_JLYRTZ:174 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)175 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_READ_KZMS:176 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)177 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZYR_SIROX_YRQD:178 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)179 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZYR_SIROX_YRTZ:180 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)181 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZYR_HSYRQD:182 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)183 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZYR_HSYRTZ:184 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)185 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZLQ_HSLQKS:186 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)187 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZLQ_HSLQTZ:188 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)189 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZLQ_SIROXLQKS:190 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)191 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZLQ_SIROXLQTZ:192 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)193 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTZ_HSSCKS:194 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)195 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTZ_HSSCTZ:196 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)197 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTZ_HSSCZT:198 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)199 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZFW:200 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)201 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZQX_SIROXQJKS:202 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)203 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SZQX_SIROXQJTZ:204 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)205 elif commandtype == DeviceCommandTypes.ML_5K_HS_HC_SET_JSXS and length == 1:206 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)207 elif commandtype == DeviceCommandTypes.ML_5K_HS_JL_SET_JSXS and length == 1:208 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)209 elif commandtype == DeviceCommandTypes.ML_5K_HS_JL_SET_JSBL and length == 1:210 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)211 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_YYHC_SET_YPGXGDZD:212 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)213 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_YYHC_SET_YPGLJXZ:214 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)215 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_YPGXGDZD:216 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)217 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_YGRGZTZD:218 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)219 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_JL_SET_YGXZLJ:220 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)221 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTS_JLSCTS:222 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)223 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTS_JLQZTZ:224 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)225 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTS_JLQZTS:226 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)227 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTS_BPHCSCTS:228 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)229 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTS_BPHCQZTZ:230 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)231 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTS_BPHCQZTS:232 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)233 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTS_HCSCTS:234 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)235 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTS_HCQZTZ:236 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)237 elif commandtype == DeviceCommandTypes.ZZ_5K_HS_HCJLHS_SET_SCTS_HCQZTS:238 rtval = self.FormantAndRunCommand(generator.Get_Command(commandtype), args)239 else:240 logger.error("Error: Wrong Command, type:" + str(commandtype) + ",args: " + str(args))241 return rtval242if __name__ == '__main__':243 url = "http://localhost:64035/api/PLCAPI"244 handler = CommandHandler(url)245 # res = handler.RunPLCCommand(DeviceCommandTypes.SIM_TEST_D1_T1,["11"])246 # print(res)247 # res = handler.RunPLCCommand(DeviceCommandTypes.SIM_TEST_D1_T2,["12"])248 # print(res)249 # res = handler.RunPLCCommand(DeviceCommandTypes.SIM_TEST_D1_T4,["14"])250 # print(res)251 # res = handler.RunPLCCommand(DeviceCommandTypes.ML_5K_HS_TB_WD_SET_ALL,["100","110"])252 # print(res)253 # res = handler.RunPLCCommand(DeviceCommandTypes.ML_5K_HS_TB_WD_RESET_ALL,["105","105"])254 # print(res)255 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5H_5H_LD5_TEST_SET_ALL, ["105", "125"])256 print(res)257 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5H_5H_LD5_TEST_RESET_ALL, ["110", "120"])258 print(res)259 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5K_HS_TB_WD_READ_HMI, [])260 print(res)261 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5K_HS_TB_WD_READ_TEMPS, [])262 print(res)263 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5K_HS_TB_WD_SET_TEMPS, ["110", "120"])264 print(res)265 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5K_HS_TB_WD_SET_TIC_COS, ["0", "0"])266 print(res)267 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5K_HS_TB_WD_SWITCH_MAN, [])268 print(res)269 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5K_HS_TB_WD_SWITCH_AUTO, [])270 print(res)271 res = handler.RunPLCCommand(DeviceCommandTypes.SIM_TEST_D1_T1, ["12"])272 print(res)273 res = handler.RunPLCCommand(DeviceCommandTypes.SIM_TEST_D1_T2, ["13"])274 print(res)275 res = handler.RunPLCCommand(DeviceCommandTypes.SIM_TEST_D1_T4, ["14"])276 print(res)277 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5H_5H_LD5_TEST_SET_ALL, ["120", "111"])278 print(res)279 res = handler.RunPLCCommand(DeviceCommandTypes.ML_5H_5H_LD5_TEST_RESET_ALL, ["120", "111"])...

Full Screen

Full Screen

px_commandline_test.py

Source:px_commandline_test.py Github

copy

Full Screen

1import os2from px import px_commandline3def test_get_command_python():4 assert px_commandline.get_command("python") == "python"5 assert px_commandline.get_command("/apa/Python") == "Python"6 assert px_commandline.get_command("python --help") == "python"7 # These are inspired by Python 2.7.11 --help output8 assert px_commandline.get_command("python apa.py") == "apa.py"9 assert px_commandline.get_command("python /usr/bin/apa.py") == "apa.py"10 assert px_commandline.get_command("python2.7 /usr/bin/apa.py") == "apa.py"11 assert px_commandline.get_command("python /usr/bin/hej") == "hej"12 assert px_commandline.get_command("python /usr/bin/hej gris --flaska") == "hej"13 assert px_commandline.get_command("python -c cmd") == "python"14 assert px_commandline.get_command("python -m mod") == "mod"15 assert px_commandline.get_command("python -m mod --hej gris --frukt") == "mod"16 assert px_commandline.get_command("Python -") == "Python"17 # Ignoring switches18 assert px_commandline.get_command("python -E apa.py") == "apa.py"19 assert px_commandline.get_command("python3 -E") == "python3"20 assert px_commandline.get_command("python -u -t -m mod") == "mod"21 # -W switches unsupported for now, room for future improvement22 assert px_commandline.get_command("python -W warning:spec apa.py") == "python"23 # Invalid command lines24 assert px_commandline.get_command("python -W") == "python"25 assert px_commandline.get_command("python -c") == "python"26 assert px_commandline.get_command("python -m") == "python"27 assert px_commandline.get_command("python -m ") == "python"28 assert px_commandline.get_command("python -m -u") == "python"29 assert px_commandline.get_command("python ") == "python"30def test_get_command_java():31 assert px_commandline.get_command("java") == "java"32 assert px_commandline.get_command("java -version") == "java"33 assert px_commandline.get_command("java -help") == "java"34 assert px_commandline.get_command("java SomeClass") == "SomeClass"35 assert px_commandline.get_command("java x.y.SomeClass") == "SomeClass"36 assert px_commandline.get_command("java -jar flaska.jar") == "flaska.jar"37 assert px_commandline.get_command("java -jar /a/b/flaska.jar") == "flaska.jar"38 # Special handling of class name "Main"39 assert px_commandline.get_command("java a.b.c.Main") == "c.Main"40 # We should ignore certain command line parameters41 assert px_commandline.get_command("java -server SomeClass") == "SomeClass"42 assert px_commandline.get_command("java -Xwhatever SomeClass") == "SomeClass"43 assert px_commandline.get_command("java -Dwhatever SomeClass") == "SomeClass"44 assert px_commandline.get_command("java -cp /a/b/c SomeClass") == "SomeClass"45 assert px_commandline.get_command("java -classpath /a/b/c SomeClass") == "SomeClass"46 assert px_commandline.get_command("java -eahej SomeClass") == "SomeClass"47 assert px_commandline.get_command("java -dahej SomeClass") == "SomeClass"48 # Tests for invalid command lines49 assert px_commandline.get_command("java -cp /a/b/c") == "java"50 assert px_commandline.get_command("java ") == "java"51 assert px_commandline.get_command("java -jar") == "java"52 assert px_commandline.get_command("java -jar ") == "java"53 # FIXME: Add test for classpath containing spaces? I say this should be54 # postponed until we have a real world use case for that.55def test_get_command_java_gradled():56 commandline = (57 "/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java "58 + "-XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m "59 + "-Dfile.encoding=UTF-8 -Duser.country=SE -Duser.language=sv -Duser.variant -cp "60 + "/Users/johan/.gradle/wrapper/dists/gradle-2.8-all/gradle-2.8/lib/gradle-launcher-2.8.jar"61 + " org.gradle.launcher.daemon.bootstrap.GradleDaemon 2.8"62 )63 assert px_commandline.get_command(commandline) == "GradleDaemon"64def test_get_command_java_teamcity():65 commandline = (66 "/usr/lib/jvm/jdk-8-oracle-x64/jre/bin/java "67 + "-Djava.util.logging.config.file=/teamcity/conf/logging.properties "68 + "-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager "69 + "-Dsun.net.inetaddr.ttl=60 -server -Xms31g -Xmx31g "70 + "-Dteamcity.configuration.path=../conf/teamcity-startup.properties "71 + "-Dlog4j.configuration=file:/teamcity/bin/../conf/teamcity-server-log4j.xml "72 + "-Dteamcity_logs=../logs/ -Djsse.enableSNIExtension=false -Djava.awt.headless=true "73 + "-Djava.endorsed.dirs=/teamcity/endorsed "74 + "-classpath /teamcity/bin/bootstrap.jar:/teamcity/bin/tomcat-juli.jar "75 + "-Dcatalina.base=/teamcity -Dcatalina.home=/teamcity "76 + "-Djava.io.tmpdir=/teamcity/temp org.apache.catalina.startup.Bootstrap start"77 )78 assert px_commandline.get_command(commandline) == "Bootstrap"79def test_get_command_java_logstash():80 # From: https://github.com/elastic/logstash/issues/331581 commandline = (82 "/usr/bin/java -XX:+UseParNewGC -XX:+UseConcMarkSweepGC "83 + "-Djava.awt.headless=true -XX:CMSInitiatingOccupancyFraction=75 "84 + "-XX:+UseCMSInitiatingOccupancyOnly -Djava.io.tmpdir=/var/lib/logstash "85 + "-Xmx128m -Xss2048k -Djffi.boot.library.path=/opt/logstash/vendor/jruby/lib/jni "86 + "-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -Djava.awt.headless=true "87 + "-XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly "88 + "-Djava.io.tmpdir=/var/lib/logstash "89 + "-Xbootclasspath/a:/opt/logstash/vendor/jruby/lib/jruby.jar -classpath : "90 + "-Djruby.home=/opt/logstash/vendor/jruby "91 + "-Djruby.lib=/opt/logstash/vendor/jruby/lib -Djruby.script=jruby "92 + "-Djruby.shell=/bin/sh org.jruby.Main --1.9 /opt/logstash/lib/bootstrap/environment.rb "93 + "logstash/runner.rb agent -f /etc/logstash/conf.d -l /var/log/logstash/logstash.log"94 )95 assert px_commandline.get_command(commandline) == "jruby.Main"96def test_get_command_java_gradleworkermain():97 commandline = (98 "/some/path/bin/java "99 "-Djava.awt.headless=true "100 "-Djava.security.manager="101 + "worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager "102 "-Dorg.gradle.native=false "103 "-Drobolectric.accessibility.enablechecks=true "104 "-Drobolectric.logging=stderr "105 "-Drobolectric.logging.enabled=true "106 "-agentlib:jdwp=transport=dt_socket,server=y,address=,suspend=n "107 "-noverify "108 "-javaagent:gen_build/.../jacocoagent.jar="109 + "destfile=gen_build/jacoco/testDebugUnitTest.exec,"110 + "append=true,dumponexit=true,output=file,jmx=false "111 "-Xmx2400m "112 "-Dfile.encoding=UTF-8 "113 "-Duser.country=SE "114 "-Duser.language=sv "115 "-Duser.variant "116 "-ea "117 "-cp "118 "/Users/walles/.gradle/caches/4.2.1/workerMain/gradle-worker.jar "119 "worker.org.gradle.process.internal.worker.GradleWorkerMain "120 "'Gradle Test Executor 16'"121 )122 assert px_commandline.get_command(commandline) == "GradleWorkerMain"123def test_get_command_java_equinox():124 # You get these processes with Visual Studio Code's java environment in October 2020125 commandline = (126 "/Library/Java/JavaVirtualMachines/openjdk-11.jdk/Contents/Home/bin/java "127 "--add-modules=ALL-SYSTEM "128 "--add-opens "129 "java.base/java.util=ALL-UNNAMED "130 "--add-opens "131 "java.base/java.lang=ALL-UNNAMED "132 "-Declipse.application=org.eclipse.jdt.ls.core.id1 "133 "-Dosgi.bundles.defaultStartLevel=4 "134 "-Declipse.product=org.eclipse.jdt.ls.core.product "135 "-Dfile.encoding=utf8 "136 "-XX:+UseParallelGC "137 "-XX:GCTimeRatio=4 "138 "-XX:AdaptiveSizePolicyWeight=90 "139 "-Dsun.zip.disableMemoryMapping=true "140 "-Xmx1G "141 "-Xms100m "142 "-noverify "143 "-jar "144 "/Users/walles/.vscode/extensions/redhat.java-0.68.0/server/plugins/org.eclipse.equinox.launcher_1.5.800.v20200727-1323.jar "145 "-configuration "146 "/Users/walles/Library/Application "147 "Support/Code/User/globalStorage/redhat.java/0.68.0/config_mac "148 "-data "149 "/Users/walles/Library/Application "150 "Support/Code/User/workspaceStorage/b8c3a38f62ce0fc92ce4edfb836480db/redhat.java/jdt_ws "151 )152 assert (153 px_commandline.get_command(commandline)154 == "org.eclipse.equinox.launcher_1.5.800.v20200727-1323.jar"155 )156def test_get_command_electron_macos():157 # Note that if we have spaces inside of the path, the path in158 # question needs to be valid on the local system for it to159 # be deciphered properly by px. So this path is from an actual160 # path, but with all spaces removed.161 assert (162 px_commandline.get_command(163 "/Applications/VisualStudioCode.app/Contents/MacOS/Electron "164 "--ms-enable-electron-run-as-node "165 "/Users/johan/.vscode/extensions/ms-python.vscode-pylance-2021.12.2/dist/server.bundle.js "166 "--cancellationReceive=file:d6fe53594ec46a8bb986ad058c985f56d309e7bf19 "167 "--node-ipc "168 "--clientProcessId=42516 "169 )170 == "VisualStudioCode"171 )172def test_get_command_resque():173 # These command names are from a real-world system174 assert px_commandline.get_command("resque-1.20.0: x y z") == "resque-1.20.0:"175 assert px_commandline.get_command("resqued-0.7.12 a b c") == "resqued-0.7.12"176def test_get_command_sudo():177 assert px_commandline.get_command("sudo") == "sudo"178 assert (179 px_commandline.get_command("sudo python /usr/bin/hej gris --flaska")180 == "sudo hej"181 )182 # We could support flags at some point, but until proven necessary we'll183 # fall back on just "sudo" when we get flags.184 assert px_commandline.get_command("sudo -B python /usr/bin/hej") == "sudo"185def test_get_command_sudo_with_space_in_command_name(tmpdir):186 # Create a file name with a space in it187 spaced_path = tmpdir.join("i contain spaces")188 spaced_path.write_binary(b"")189 spaced_name = str(spaced_path)190 # Verify splitting of the spaced file name191 assert px_commandline.get_command("sudo " + spaced_name) == "sudo i contain spaces"192 # Verify splitting with more parameters on the line193 assert (194 px_commandline.get_command("sudo " + spaced_name + " parameter")195 == "sudo i contain spaces"196 )197def test_get_command_sudo_with_space_in_path(tmpdir):198 # Create a file name with a space in it199 spaced_dir = tmpdir.join("i contain spaces")200 os.mkdir(str(spaced_dir))201 spaced_path = spaced_dir + "/runme"202 spaced_path.write_binary(b"")203 spaced_name = str(spaced_path)204 # Verify splitting of the spaced file name205 assert px_commandline.get_command("sudo " + spaced_name) == "sudo runme"206 # Verify splitting with more parameters on the line207 assert (208 px_commandline.get_command("sudo " + spaced_name + " parameter") == "sudo runme"209 )210def test_get_command_interpreters():211 assert px_commandline.get_command("ruby") == "ruby"212 assert px_commandline.get_command("ruby /some/path/apa.rb") == "apa.rb"213 assert px_commandline.get_command("ruby -option /some/path/apa.rb") == "ruby"214 assert px_commandline.get_command("sh") == "sh"215 assert px_commandline.get_command("sh /some/path/apa.sh") == "apa.sh"216 assert px_commandline.get_command("sh -option /some/path/apa.sh") == "sh"217 assert px_commandline.get_command("bash") == "bash"218 assert px_commandline.get_command("bash /some/path/apa.sh") == "apa.sh"219 assert px_commandline.get_command("bash -option /some/path/apa.sh") == "bash"220 assert px_commandline.get_command("perl") == "perl"221 assert px_commandline.get_command("perl /some/path/apa.pl") == "apa.pl"222 assert px_commandline.get_command("perl -option /some/path/apa.pl") == "perl"223def test_get_command_unicode():224 assert px_commandline.get_command("😀") == "😀"225def test_get_command_ruby_switches():226 assert (227 px_commandline.get_command(228 "/usr/bin/ruby -W0 /usr/local/bin/brew.rb install rust"229 )230 == "brew.rb"231 )232 # https://github.com/walles/px/issues/87233 assert (234 px_commandline.get_command("/usr/bin/ruby -W1 -- /apa/build.rb /bepa/cmake.rb")235 == "build.rb"236 )237 # https://github.com/walles/px/issues/74238 assert (239 px_commandline.get_command(240 "/usr/bin/ruby -Eascii-8bit:ascii-8bit /usr/sbin/google-fluentd"241 )242 == "google-fluentd"243 )244def test_get_command_perl():245 # Source: https://github.com/walles/px/issues/85246 assert (247 px_commandline.get_command(248 " ".join(249 [250 "/usr/bin/perl5.18",251 "/usr/local/Cellar/cloc/1.90/libexec/bin/cloc",252 "build-system",253 "build_number_offset",254 "buildbox",255 "Random.txt",256 "README.md",257 "submodules",258 "Telegram",259 "third-party",260 "tools",261 "versions.json",262 "WORKSPACE",263 ]264 )265 )266 == "cloc"267 )268 # Variations on the same theme269 assert (270 px_commandline.get_command(271 " ".join(272 [273 "/usr/bin/perl",274 "/usr/local/Cellar/cloc/1.90/libexec/bin/cloc",275 ]276 )277 )278 == "cloc"279 )280 assert (281 px_commandline.get_command(282 " ".join(283 [284 "perl",285 "/usr/local/Cellar/cloc/1.90/libexec/bin/cloc",286 ]287 )288 )289 == "cloc"290 )291 assert (292 px_commandline.get_command(293 " ".join(294 [295 "/usr/bin/perl5",296 "/usr/local/Cellar/cloc/1.90/libexec/bin/cloc",297 ]298 )299 )300 == "cloc"301 )302 assert (303 px_commandline.get_command(304 " ".join(305 [306 "/usr/bin/perl5.30",307 "/usr/local/Cellar/cloc/1.90/libexec/bin/cloc",308 ]309 )310 )311 == "cloc"312 )313 # Give up on command line switches314 assert (315 px_commandline.get_command(316 " ".join(317 [318 "/usr/bin/perl",319 "-S",320 "cloc",321 ]322 )323 )324 == "perl"325 )326def test_get_homebrew_commandline():327 # Source: https://github.com/walles/px/issues/72328 assert (329 px_commandline.get_command(330 " ".join(331 [332 "/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/current/bin/ruby",333 "-W0",334 "--disable=gems,did_you_mean,rubyopt",335 "/usr/local/Homebrew/Library/Homebrew/brew.rb",336 "upgrade",337 ]338 )339 )340 == "brew.rb"341 )342def test_node_max_old_space():343 assert (344 px_commandline.get_command("node --max_old_space_size=4096 scripts/start.js")345 == "start.js"346 )347def test_macos_app():348 assert (349 px_commandline.get_command(350 "/".join(351 [352 "/System",353 "Library",354 "CoreServices",355 "Dock.app",356 "Contents",357 "XPCServices",358 "com.apple.dock.external.extra.xpc",359 "Contents",360 "MacOS",361 "com.apple.dock.external.extra",362 ]363 )364 )365 == "Dock/extra"366 )367 # https://github.com/walles/px/issues/73368 assert (369 px_commandline.get_command(370 "/".join(371 [372 "/Applications",373 "Firefox.app",374 "Contents",375 "MacOS",376 "plugin-container.app",377 "Contents",378 "MacOS",379 "plugin-container",380 ]381 )382 )383 == "Firefox/plugin-container"384 )385 # Note that if we have spaces inside of the path, the path in386 # question needs to be valid on the local system for it to387 # be deciphered properly by px. So this path is from an actual388 # path, but with all spaces removed.389 assert (390 px_commandline.get_command(391 "/".join(392 [393 "/Applications",394 "VisualStudioCode.app",395 "Contents",396 "Frameworks",397 "CodeHelper(Renderer).app",398 "Contents",399 "MacOS",400 "CodeHelper(Renderer)",401 ]402 )403 )404 == "CodeHelper(Renderer)"405 )406 assert (407 px_commandline.get_command("/Applications/iTerm.app/Contents/MacOS/iTerm2")408 == "iTerm2"409 )410 # Don't duplicate the .app name411 assert (412 px_commandline.get_command(413 "/".join(414 [415 "/System",416 "Library",417 "PrivateFrameworks",418 "IDS.framework",419 "identityservicesd.app",420 "Contents",421 "MacOS",422 "identityservicesd",423 ]424 )425 )426 == "IDS/identityservicesd"...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

...8colorama.init()9command = None10function_code = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "C", "H", "c", "h", "O", "o", "F", "f", "+"]11# функция запрашивает у пользователя код желаемой операции12def get_command():13 global command14 command = str(input("Insert your command: >>> "))15# Удаляется содержимое экрана для вывода обновленного контента. Так исключается большая простыня выводов16def clear():17 os.system('cls' if os.name == 'nt' else 'clear')18fm.print_description() # list of function19get_command()20while command != "e":21 if command in function_code:22 # Реализуем весь функционал ТУТ23 # New Folder24 if command == "1":25 clear()26 name_folder = input("Create New Folder,\ninsert Folder Name: >>>")27 os.mkdir(name_folder)28 clear()29 fm.print_description()30 print("Folder " + Fore.GREEN + name_folder + Style.RESET_ALL + " created!")31 get_command()32 # Delete Folder33 elif command == "2":34 clear()35 name_folder = input("Insert Folder Name for Delete: >>>")36 alert = input(37 "Attention! The folder " + name_folder + "will be deleted along with the files it contains!\nDo you "38 "want to continue? (Y / N):")39 if alert == "Y" or alert == "y":40 import shutil41 shutil.rmtree(name_folder)42 clear()43 fm.print_description()44 print("Folder " + Fore.RED + name_folder + Style.RESET_ALL + " Deleted!")45 get_command()46 elif alert == "N" or alert == "n":47 clear()48 fm.print_description()49 print("Folder not deleted.")50 get_command()51 else:52 clear()53 fm.print_description()54 print("Invalid responce! Folder not deleted!")55 get_command()56 # Rename Folder57 elif command == "3":58 clear()59 old = input("Insert curent folder name: >>> ")60 new = input("Insert NEW folder name: >>> ")61 os.renames(old, new)62 old = new = None63 clear()64 fm.print_description()65 print("Folder renamed")66 get_command()67 # Create file / temporary inactiv function68 elif command == "4":69 clear()70 fm.print_description()71 print("function in construction")72 get_command()73 # Delete file74 elif command == "5":75 clear()76 file_name = input("Insert File Name for Delete: >>>")77 alert = input(78 "You definitely want to delete the file" + file_name + "\n" + "Do you want to continue? (Y / N):")79 if alert == "Y" or alert == "y":80 if os.path.exists(file_name):81 os.remove(file_name)82 clear()83 fm.print_description()84 print("File " + Fore.RED + file_name + Style.RESET_ALL + " Deleted!")85 get_command()86 else:87 clear()88 fm.print_description()89 print("The file does not exist and therefore can'n be deleted")90 get_command()91 elif alert == "N" or alert == "n":92 clear()93 fm.print_description()94 print("File not deleted.")95 get_command()96 else:97 clear()98 fm.print_description()99 print("Invalid responce! File not deleted!")100 get_command()101 # rename file102 elif command == "6":103 clear()104 old = input(Fore.RED + "Insert file name for rename: >>> " + Style.RESET_ALL)105 new = input("Insert NEW file namefor selected file: >>> ")106 if os.path.exists(old):107 if new != "":108 os.renames(old, new)109 old = new = None110 clear()111 fm.print_description()112 print(Fore.GREEN + "The file has been renamed!" + Style.RESET_ALL)113 get_command()114 else:115 clear()116 fm.print_description()117 print(Fore.RED + "You have not entered a new file name. The selected file will not be renamed" + Style.RESET_ALL)118 get_command()119 else:120 clear()121 fm.print_description()122 print("You don't select file for rename. Operation has been intrerupted. Try again.")123 get_command()124 # Copy folder125 elif command == "7":126 clear()127 fm.print_description()128 print("7")129 get_command()130 # Copy file131 elif command == "8":132 clear()133 fm.print_description()134 print("8")135 get_command()136 elif command == "9":137 clear()138 fm.print_description()139 print("List of files in directory:")140 fm.list_file_and_dir()141 get_command()142 # изменение текущей директории143 elif command == "c" or command == "C":144 clear()145 fm.print_description()146 print(Fore.RED + os.getcwd(), "\\" + Style.RESET_ALL)147 print("Change working directories")148 path = input("Insert new path: ")149 os.chdir(path)150 clear()151 fm.print_description()152 print(Fore.RED + os.getcwd(), "\\" + Style.RESET_ALL)153 get_command()154 # Запрос помощи155 elif command == "h" or command == "H":156 clear()157 print(Fore.RED + "Help options is here" + Style.RESET_ALL)158 print("******* HELP CONTENT *******\nfor MAIN Menu - insert '+' and press 'Enter'!")159 get_command()160 elif command == "+":161 clear()162 fm.print_description()163 get_command()164 elif command == "O" or command == "o":165 selected = input("Print file name for open this file: >>> ")166 if os.path.exists(selected):167 f = open(selected, "r")168 clear()169 print(selected + "content:\n")170 print(f.read())171 print(Fore.GREEN + "\n Press ENTER for close this file!" + Style.RESET_ALL)172 input()173 f.close()174 clear()175 fm.print_description()176 get_command()177 else:178 clear()179 fm.print_description()180 print(Fore.RED + "The file not exist! Try again!" + Style.RESET_ALL)181 get_command()182 elif command == "f" or command == "F":183 name = input("Insert char for fins in file list in dhit directori: >>>")184 fm.find(name)185 clear()186 fm.print_description()187 get_command()188 else:189 clear()190 fm.print_description()191 print(Fore.RED + "Invalid value!" + Style.RESET_ALL)192 get_command()193print("End of programm\nPress 'Enter'")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful