(self, url, data, timeout=6, UserAgent='BT-Panel')
| 398 | return ":".join([mac[e:e + 2] for e in range(0, 11, 2)]) |
| 399 | |
| 400 | def HttpPost(self, url, data, timeout=6, UserAgent='BT-Panel'): |
| 401 | try: |
| 402 | pdata = "" |
| 403 | if type(data) == dict: |
| 404 | for key in data: |
| 405 | pdata += "{}={}&".format(key, data[key]) |
| 406 | pdata = pdata.strip('&') |
| 407 | else: |
| 408 | pdata = data |
| 409 | curl_cmd = "curl -sS --connect-timeout {} --max-time {} --user-agent '{}' -d '{}' '{}'".format(timeout, timeout, UserAgent, pdata, url) |
| 410 | |
| 411 | result = public.ExecShell(curl_cmd) |
| 412 | if result[1]: |
| 413 | self.write_log("httpPost:", result[1]) |
| 414 | return result[0] |
| 415 | except Exception as ex: |
| 416 | self.write_log("URL: {} => {}".format(url, ex)) |
| 417 | return str(ex) |
| 418 | |
| 419 | def maillog_event_service(self): |
| 420 | # 判断是否已安装企业版邮局 |
no test coverage detected