|
@@ -127,25 +127,25 @@ class VersionManagement(View):
|
|
|
# 文件名为设备版本,最后一个'.'的前面为软件版本,后面为设备规格名称
|
|
|
# V2.2.4.16E201252CA,软件版本:2.2.4,设备规格名称:16E201252CA
|
|
|
# V1.7.2.36C11680X30411F000600000150001Z,软件版本:1.7.2,设备规格名称:36C11680X30411F000600000150001Z
|
|
|
- file_name = str(file) # 文件名
|
|
|
+ file_name = str(file) # 文件名
|
|
|
# .img和.tar.gz文件
|
|
|
file_type_index = file_name.find('.img')
|
|
|
if file_type_index == -1:
|
|
|
file_type_index = file_name.find('.tar')
|
|
|
if file_type_index == -1:
|
|
|
return response.json(903)
|
|
|
- version = file_name[:file_type_index] # 设备版本
|
|
|
+ version = file_name[:file_type_index] # 设备版本
|
|
|
version_index = version.rindex('.')
|
|
|
- softwareVersion = version[1:version_index] # 软件版本
|
|
|
- code = version[version_index+1:] # 设备规格名称
|
|
|
- chipModelList2Code = code[:4] # 主芯片
|
|
|
- type = code[8:10] # 设备机型
|
|
|
- companyCode = code[-1:] # 公司代码
|
|
|
+ softwareVersion = version[1:version_index] # 软件版本
|
|
|
+ code = version[version_index + 1:] # 设备规格名称
|
|
|
+ chipModelList2Code = code[:4] # 主芯片
|
|
|
+ type = code[8:10] # 设备机型
|
|
|
+ companyCode = code[-1:] # 公司代码
|
|
|
fileSize = file.size
|
|
|
filePath = '/'.join(('static/otapack', mci, lang, file_name))
|
|
|
# file_data = file.read()
|
|
|
fileMd5 = hashlib.md5(file_name).hexdigest()
|
|
|
- data_dict = {'mci': mci, 'lang': lang, 'ESN': ESN, 'max_ver': max_ver, 'channel': channel,
|
|
|
+ data_dict = {'mci': mci, 'lang': lang, 'ESN': ESN, 'max_ver': max_ver, 'channel': channel,
|
|
|
'resolutionRatio': resolutionRatio, 'Description': Description, 'status': status,
|
|
|
'version': version, 'softwareVersion': softwareVersion, 'code': code,
|
|
|
'chipModelList2Code': chipModelList2Code, 'type': type, 'companyCode': companyCode,
|
|
@@ -163,7 +163,7 @@ class VersionManagement(View):
|
|
|
os.makedirs(upload_path)
|
|
|
# 文件上传
|
|
|
full_name = upload_path + file_name
|
|
|
- if os.path.exists(full_name): # 删除同名文件
|
|
|
+ if os.path.exists(full_name): # 删除同名文件
|
|
|
os.remove(full_name)
|
|
|
with open(full_name, 'wb+') as write_file:
|
|
|
for chunk in file.chunks():
|
|
@@ -267,9 +267,9 @@ class VersionManagement(View):
|
|
|
data_dict = {'appName': appName, 'appBundleId': appBundleId, 'bundleVersion': bundleVersion,
|
|
|
'newAppversion': newAppversion, 'minAppversion': minAppversion, 'content': content,
|
|
|
'app_type': app_type, 'downloadLink': downloadLink}
|
|
|
- if not id: # 添加
|
|
|
+ if not id: # 添加
|
|
|
App_Info.objects.create(**data_dict)
|
|
|
- else: # 编辑
|
|
|
+ else: # 编辑
|
|
|
app_info_qs = App_Info.objects.filter(id=id)
|
|
|
if not app_info_qs.exists():
|
|
|
return response.json(173)
|
|
@@ -349,13 +349,15 @@ class VersionManagement(View):
|
|
|
app_type = 2
|
|
|
else:
|
|
|
app_type = 3
|
|
|
- app_colophon_qs = App_Colophon.objects.filter(app_id__app_type=app_type).order_by('app_id').values_list('app_id__appBundleId', flat=True).distinct()
|
|
|
+ app_colophon_qs = App_Colophon.objects.filter(app_id__app_type=app_type).order_by('app_id').values_list(
|
|
|
+ 'app_id__appBundleId', flat=True).distinct()
|
|
|
if not app_colophon_qs.exists():
|
|
|
return response.json(173)
|
|
|
total = app_colophon_qs.count()
|
|
|
app_colophon_list = list(app_colophon_qs[(page - 1) * line:page * line])
|
|
|
- app_info_qs = App_Colophon.objects.filter(app_id__appBundleId__in=app_colophon_list).\
|
|
|
- values("id", "lang", "newApp_version", "content","version_time", "app_id__appBundleId", "app_id__appName", "app_id__app_type")
|
|
|
+ app_info_qs = App_Colophon.objects.filter(app_id__appBundleId__in=app_colophon_list). \
|
|
|
+ values("id", "lang", "newApp_version", "content", "version_time", "app_id__appBundleId",
|
|
|
+ "app_id__appName", "app_id__app_type")
|
|
|
app_info_list = list(app_info_qs)
|
|
|
data_dict = {}
|
|
|
# 组装数据
|
|
@@ -399,16 +401,18 @@ class VersionManagement(View):
|
|
|
app_type = 2
|
|
|
else:
|
|
|
app_type = 3
|
|
|
- app_colophon_qs = App_Colophon.objects.filter(app_id__app_type=app_type).order_by('app_id').values_list('app_id__appBundleId', flat=True).distinct()
|
|
|
+ app_colophon_qs = App_Colophon.objects.filter(app_id__app_type=app_type).order_by('app_id').values_list(
|
|
|
+ 'app_id__appBundleId', flat=True).distinct()
|
|
|
if not app_colophon_qs.exists():
|
|
|
return response.json(173)
|
|
|
total = app_colophon_qs.count()
|
|
|
app_colophon_list = list(app_colophon_qs[(page - 1) * line:page * line])
|
|
|
- app_info_qs = App_Colophon.objects.filter(app_id__appBundleId__in=app_colophon_list).\
|
|
|
- values("id", "lang", "newApp_version", "content", "version_time", "app_id__appBundleId", "app_id__appName", "app_id__app_type")
|
|
|
+ app_info_qs = App_Colophon.objects.filter(app_id__appBundleId__in=app_colophon_list). \
|
|
|
+ values("id", "lang", "newApp_version", "content", "version_time", "app_id__appBundleId",
|
|
|
+ "app_id__appName", "app_id__app_type")
|
|
|
app_info_list = list(app_info_qs)
|
|
|
- app_record_list = [] # 响应的app record数据
|
|
|
- appBundleId_list = [] # 记录已添加过的appBundleId
|
|
|
+ app_record_list = [] # 响应的app record数据
|
|
|
+ appBundleId_list = [] # 记录已添加过的appBundleId
|
|
|
# 组装数据
|
|
|
for app_info in app_info_list:
|
|
|
version = app_info['lang'] + app_info['newApp_version']
|
|
@@ -428,7 +432,8 @@ class VersionManagement(View):
|
|
|
if queryVersion and queryVersion == version and queryAppBundleId == app_info['app_id__appBundleId']:
|
|
|
app_record_dict['id'] = app_info['id']
|
|
|
app_record_dict['content'] = app_info['content']
|
|
|
- app_record_dict['version_time'] = time.strftime("%Y-%m-%d", time.localtime(app_info['version_time']))
|
|
|
+ app_record_dict['version_time'] = time.strftime("%Y-%m-%d",
|
|
|
+ time.localtime(app_info['version_time']))
|
|
|
|
|
|
app_record_list.append(app_record_dict)
|
|
|
else:
|
|
@@ -439,7 +444,8 @@ class VersionManagement(View):
|
|
|
# app_record_list里对应字典插入值
|
|
|
app_record_list[index]['id'] = app_info['id']
|
|
|
app_record_list[index]['content'] = app_info['content']
|
|
|
- app_record_list[index]['version_time'] = time.strftime("%Y-%m-%d", time.localtime(app_info['version_time']))
|
|
|
+ app_record_list[index]['version_time'] = time.strftime("%Y-%m-%d",
|
|
|
+ time.localtime(app_info['version_time']))
|
|
|
app_record_list[index]['version'] = version
|
|
|
app_record_list[index]['newApp_version_list'].insert(0, newApp_version_list)
|
|
|
else:
|
|
@@ -487,13 +493,13 @@ class VersionManagement(View):
|
|
|
|
|
|
try:
|
|
|
version_time = int(time.mktime(time.strptime(version_time, '%Y-%m-%d'))) # 字符串转时间戳
|
|
|
- if app_colophon_id: # 编辑
|
|
|
+ if app_colophon_id: # 编辑
|
|
|
# 编辑获取的版本信息前两位为语言
|
|
|
lang = newApp_version[:2]
|
|
|
newApp_version = newApp_version[2:]
|
|
|
App_Colophon.objects.filter(id=app_colophon_id).update(lang=lang, newApp_version=newApp_version,
|
|
|
content=content, version_time=version_time)
|
|
|
- else: # 添加
|
|
|
+ else: # 添加
|
|
|
app_info_qs = App_Info.objects.filter(appBundleId=appBundleId).values('id')
|
|
|
if not app_info_qs.exists():
|
|
|
return response.json(173)
|
|
@@ -630,4 +636,4 @@ class VersionManagement(View):
|
|
|
return response.json(0)
|
|
|
except Exception as e:
|
|
|
print(e)
|
|
|
- return response.json(500, repr(e))
|
|
|
+ return response.json(500, repr(e))
|