update xlsx
This commit is contained in:
parent
855260497f
commit
7622808756
|
|
@ -10,7 +10,6 @@ import zipfile
|
|||
import rarfile
|
||||
from openpyxl import Workbook, load_workbook
|
||||
from django.db.models import Count
|
||||
import time
|
||||
# Create your views here.
|
||||
class CMAViewSet(ModelViewSet):
|
||||
"""
|
||||
|
|
@ -50,7 +49,7 @@ class CMAViewSet(ModelViewSet):
|
|||
import os
|
||||
if fullpath.endswith('.rar'):
|
||||
rar = rarfile.RarFile(fullpath)
|
||||
fulldir = fullpath.replace('.rar',time.strftime('%Y%m%d%H%M%S'))
|
||||
fulldir = fullpath.replace('.rar','')
|
||||
os.mkdir(fulldir)
|
||||
os.chdir(fulldir)
|
||||
rar.extractall()
|
||||
|
|
@ -62,7 +61,7 @@ class CMAViewSet(ModelViewSet):
|
|||
import_cma(f, os.path.join(root,f))
|
||||
return Response('不支持非xlsx格式', status = status.HTTP_400_BAD_REQUEST)
|
||||
elif fullpath.endswith('.zip'):
|
||||
fulldir = fullpath.replace('.zip',time.strftime('%Y%m%d%H%M%S'))
|
||||
fulldir = fullpath.replace('.zip','')
|
||||
os.mkdir(fulldir)
|
||||
os.chdir(fulldir)
|
||||
CMA.objects.filter(type='center').delete()
|
||||
|
|
@ -85,7 +84,7 @@ class CMAViewSet(ModelViewSet):
|
|||
import os
|
||||
if fullpath.endswith('.rar'):
|
||||
rar = rarfile.RarFile(fullpath)
|
||||
fulldir = fullpath.replace('.rar',time.strftime('%Y%m%d%H%M%S'))
|
||||
fulldir = fullpath.replace('.rar','')
|
||||
os.mkdir(fulldir)
|
||||
os.chdir(fulldir)
|
||||
rar.extractall()
|
||||
|
|
@ -97,7 +96,7 @@ class CMAViewSet(ModelViewSet):
|
|||
import_cma2(f, os.path.join(root,f))
|
||||
return Response('不支持非xlsx格式', status = status.HTTP_400_BAD_REQUEST)
|
||||
elif fullpath.endswith('.zip'):
|
||||
fulldir = fullpath.replace('.zip',time.strftime('%Y%m%d%H%M%S'))
|
||||
fulldir = fullpath.replace('.zip','')
|
||||
os.mkdir(fulldir)
|
||||
os.chdir(fulldir)
|
||||
# CMA.objects.filter(type='sub').delete()
|
||||
|
|
|
|||
Loading…
Reference in New Issue