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