|
@@ -390,6 +390,7 @@ def addNewEquipmentVersionInterface(request):
|
|
return response.json(444)
|
|
return response.json(444)
|
|
deviceContent = request_dict.get('content', None).encode('utf-8')
|
|
deviceContent = request_dict.get('content', None).encode('utf-8')
|
|
token = request_dict.get('token', None)
|
|
token = request_dict.get('token', None)
|
|
|
|
+ file_s = request.FILES.get('file', None)
|
|
deviceContent = str(deviceContent, encoding='utf-8')
|
|
deviceContent = str(deviceContent, encoding='utf-8')
|
|
deviceContent = deviceContent.replace(' ', ' ').replace('\'', '\"')
|
|
deviceContent = deviceContent.replace(' ', ' ').replace('\'', '\"')
|
|
if deviceContent is None:
|
|
if deviceContent is None:
|
|
@@ -416,6 +417,28 @@ def addNewEquipmentVersionInterface(request):
|
|
if version is None or filePath is None:
|
|
if version is None or filePath is None:
|
|
return response.json(444, 'content')
|
|
return response.json(444, 'content')
|
|
deviceData['filePath'] = ','.join(filePath)
|
|
deviceData['filePath'] = ','.join(filePath)
|
|
|
|
+ paths = 'static/versions/image'
|
|
|
|
+ if not os.path.exists(paths):
|
|
|
|
+ os.makedirs(paths) # makedirs 创建文件时如果路径不存在会创建这个路径
|
|
|
|
+ # print ('该文件不存在')
|
|
|
|
+ else:
|
|
|
|
+ print ('该文件存在')
|
|
|
|
+ print(file_s)
|
|
|
|
+ if file_s is None:
|
|
|
|
+ deviceData['img'] = ''
|
|
|
|
+ else:
|
|
|
|
+ rv_path = 'static/versions/image/' + code + '.png'
|
|
|
|
+ try:
|
|
|
|
+ as_path = os.path.join(BASE_DIR, rv_path)
|
|
|
|
+ if os.path.exists(as_path):
|
|
|
|
+ os.remove(as_path)
|
|
|
|
+ with open(as_path, 'wb+') as destination:
|
|
|
|
+ for chunk in file_s.chunks():
|
|
|
|
+ destination.write(chunk)
|
|
|
|
+ except Exception as e:
|
|
|
|
+ pass
|
|
|
|
+ else:
|
|
|
|
+ deviceData['img'] = SERVER_DOMAIN + 'sysfile/' + rv_path
|
|
ev_qs = Equipment_Version(
|
|
ev_qs = Equipment_Version(
|
|
eid=CommonService.getUserID(getUser=False, setOTAID=True),
|
|
eid=CommonService.getUserID(getUser=False, setOTAID=True),
|
|
**deviceData)
|
|
**deviceData)
|