1234567891011121314151617181920212223242526272829303132 |
- import time
- import requests
- from auo_tests.tasks.config import host
- from auo_tests.tasks.minio_handler import FileHandler, URL as MinioURL
- filename = 'hive2hive.json'
- minio_bucket = 'mytest'
- minio_path = f'datax/' + filename
- minio_handler = FileHandler(bucket_name=minio_bucket)
- with open(filename, 'rb') as f:
- minio_handler.put_byte_file(file_name=minio_path, file_content=f.read())
- file_path = f'{minio_bucket}/{minio_path}'
- cmd_parameter = '-j "-Xms2G -Xmx2G" -p "-Dct=hangzhou" '
- name = f'datax_task_{int(time.time())}'
- data = {
- "name": name,
- "file_urls": [file_path],
- "script": "",
- "cmd": "cd datax/bin && curl $FILE_TO_DOWNLOAD >> config.json && echo \"\'\"$HOME/conda/envs/py27/bin/python datax.py $CMD_PARM config.json\"\'\" |xargs bash -c",
- "cmd_parameters": cmd_parameter,
- "envs": {"FILE_TO_DOWNLOAD": f'http://{MinioURL}/{file_path}'},
- "run_image": "SXKJ:32775/pod_datax:0.9",
- "task_type": "datax",
- "user_id": 33
- }
- print(data)
- ret = requests.post(url=f'http://{host}/jpt/jpt_task', json=data)
- print(ret.json())
|