12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- # update: 2024-3-23
- """
- 配置hosts
- 10.10.4.103 cloudos.service.ob.local
- 10.62.115.83 harbor.platform.dyys.com
- 10.62.115.11 hyty-ifactory.platform.dyys.com
- 10.62.115.83 harbor.platform.dyys.com
- 10.62.115.11 qbee.platform.dyys.com
- 10.62.115.208 mdm.platform.dyys.com
- 10.62.107.11 paas.pre.platform.dyys.com
- 10.62.107.11 qbee.pre.platform.dyys.com
- 10.62.115.11 dacoo.platform.dyys.com
- 10.62.115.11 data-assets-process.platform.dyys.com
- 10.62.115.11 bitmagic.platform.dyys.com
- """
- import requests
- import sys
- import importlib
- import traceback
- # sys.path.append(r'E:\casper\repositories\repositories\casperz.py-project\module-py') # for pc
- sys.path.append('/home/ubuntu/repositories/repositories/casperz.py-project/module-py')
- methods = importlib.import_module(f"xlib")
- class API(object):
- # def __init__(self, username='System001', password='Swdx@143',
- def __init__(self, username='', password=''):
- """
- """
- self.url = f"http://hyty-ifactory.platform.dyys.com/gongyi/ui/ResiduePackage/driver/getParamsSet"
- def get_pot_list(self):
- """
- 获取渣罐数据
- return [
- {
- 'id': '1427897186149990401',
- 'localNumber': '434', # 渣位号
- 'packageNumber': None, # 渣包号
- 'localX': None, # 渣位坐标X
- 'localY': None, # 渣位坐标Y
- 'localStatus': 0, # 渣位水管开关转态 0 关闭 非0 开启
- 'packageStatus': 1, # 渣包状态 1 空位 2 就绪 3 缓冷(空冷) 4 水冷 5 自冷(水冷) 6 待倒 7 故障
- 'weight': None, # 渣包重量
- 'createBy': 'admin',
- 'createTime': '2021-08-18',
- 'updateBy': 'admin',
- 'updateTime': '2024-03-23'
- }
- ]
- return dict(code=-1, data=[], message=f"something is wrong. [{exception.__class__.__name__}]",
- details=f"{methods.trace_log()}")
- """
- try:
- response = requests.get(url=self.url)
- print('API:get_pot_list:url:', self.url)
- print('API:get_pot_list:status_code:', response.status_code)
- result = response.json().get('result')
- # --- check ---
- if not result:
- reason = '接口数据异常'
- detail = f"请求地址: {self.url}, 请求方式: GET, 返回结果: {response.text}"
- return reason, detail
- # --- fill pot_list ---
- pot_list = list()
- for index in range(len(result)):
- pot_list += result[index]
- return pot_list
- except Exception as exception:
- print(f"API.get_pot_list.exception: {exception.__class__.__name__}")
- print(f"API.get_pot_list.traceback: {traceback.format_exc()}")
- reason = f"{exception.__class__.__name__}"
- detail = f"{traceback.format_exc()}"
- return reason, detail
- if __name__ == '__main__':
- # --- init ---
- api = API()
- # --- test ---
- out = api.get_pot_list()
- print(len(out))
|