建模程序 多个定时程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

76 lines
2.6 KiB

import redis,requests,json,os,sys
import platform
if platform.system() == 'Windows':
sys.path.append('e:\\libs\\')
else:
sys.path.append('/data/deploy/make3d/make2/libs/')
import config
import requests
from PIL import Image
from io import BytesIO
def main():
#连接mp 的redis
r = redis.Redis(host="106.14.158.208",password="kcV2000",port=6379,db=1)
#取出数据
oemId = r.lpop('setup')
oemId = 21
if oemId is None:
print("没有从redis中获取到oemId的数据")
return
print("oemId",oemId)
#请求mp的接口,获取对应的oem的数据
res = requests.get("http://172.16.20.7:8199/api/oem/infoById",params={"id":oemId})
#获取数据解析数据
# print(res.text)
#解析数据
data = json.loads(res.text)
# print(data)
if data['code'] != 1000:
print("根据id获取oem数据失败")
return
print(data['data'])
#pythob 进入到 E:\wails\oemProject ,将 data 数据写入到 wails.json 文件中的 ext_oem 字段中
with open("D:\\oemProject\\wails.json","r",encoding="utf-8") as f:
wailsData = json.load(f)
wailsData['ext_oem'] = data['data']
wailsData['name'] = data['data']['brand_name']
wailsData["outputfilename"] = str(data['data']['id'])
with open("D:\\oemProject\\wails.json","w",encoding="utf-8") as f:
json.dump(wailsData,f,ensure_ascii=False,indent=4)
# #将图片下载到本地
getExeImg(data['data']['logo'], "D:\\oemProject\\build\\appicon.png")
#写入成功后在 E:\\wails\\oemProject\\ 目录下执行 wails build 命令
os.system("cd D:\\oemProject && wails build")
# #执行 wails build 命令后,将 E:\wails\oemProject\build\bin ,在上传到 oss 中
config.oss_bucket.put_object_from_file(f'exe/'+str(data['data']['id'])+".exe", "D:\\oemProject\\build\\bin\\"+str(data['data']['id'])+".exe")
print("上传成功")
# #上传成功后,调用接口,告诉mp,已经生成exe及上传成功
requests.get("http://172.16.20.7:8199/api/oem/infoSetupUpdate",params={"id":oemId})
def getExeImg(image_url, output_path):
# 从URL获取图片
response = requests.get(image_url)
if response.status_code == 200:
# 将内容读取为图片
image = Image.open(BytesIO(response.content))
# 修改图片尺寸为1024x1024
resized_image = image.resize((1024, 1024))
# 保存图片为PNG格式
resized_image.save(output_path, 'PNG')
else:
print(f"Failed to download image. Status code: {response.status_code}")
if __name__ == '__main__':
main()