Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
55ba3382
authored
2020-11-18 16:20:02 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix bug
1 parent
7a3d093e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
src/apps/doc/management/commands/folder_ocr_process.py
src/apps/doc/views.py
src/apps/doc/management/commands/folder_ocr_process.py
View file @
55ba338
...
...
@@ -165,7 +165,12 @@ class Command(BaseCommand, LoggerMixin):
def
folder_process
(
self
,
input_dir
,
classify
):
while
not
os
.
path
.
isdir
(
input_dir
):
self
.
folder_log
.
info
(
'{0} [input dir is not dir] [input_dir={1}]'
.
format
(
self
.
log_base
,
input_dir
))
time
.
sleep
(
self
.
sleep_time
)
print
(
self
.
switch
)
if
self
.
switch
:
time
.
sleep
(
self
.
sleep_time
)
continue
else
:
return
output_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
input_dir
),
'Output'
)
img_output_dir
=
os
.
path
.
join
(
output_dir
,
'image'
)
wb_output_dir
=
os
.
path
.
join
(
output_dir
,
'excel'
)
...
...
@@ -177,11 +182,16 @@ class Command(BaseCommand, LoggerMixin):
os
.
makedirs
(
pdf_output_dir
,
exist_ok
=
True
)
os
.
makedirs
(
failed_output_dir
,
exist_ok
=
True
)
while
self
.
switch
:
if
not
os
.
path
.
isdir
(
input_dir
):
self
.
folder_log
.
info
(
'{0} [input dir is not dir] [input_dir={1}]'
.
format
(
self
.
log_base
,
input_dir
))
time
.
sleep
(
self
.
sleep_time
)
continue
# 1. 从input dir获取pdf or image
list_dir
=
os
.
listdir
(
input_dir
)
if
not
list_dir
:
self
.
folder_log
.
info
(
'{0} [input dir empty] [input_dir={1}]'
.
format
(
self
.
log_base
,
input_dir
))
time
.
sleep
(
self
.
sleep_time
)
continue
for
name
in
list_dir
:
try
:
path
=
os
.
path
.
join
(
input_dir
,
name
)
...
...
src/apps/doc/views.py
View file @
55ba338
...
...
@@ -294,7 +294,7 @@ class DocView(GenericView, DocHandler):
pdf_file
=
args
.
get
(
'pdf_file'
)
if
isinstance
(
pdf_file
.
name
,
str
):
if
not
pdf_file
.
name
.
endswith
(
'pdf'
)
or
not
pdf_file
.
name
.
endswith
(
'PDF'
):
if
not
pdf_file
.
name
.
endswith
(
'pdf'
)
and
not
pdf_file
.
name
.
endswith
(
'PDF'
):
self
.
invalid_params
(
msg
=
'invalid params: not a PDF file'
)
business_type
=
random
.
choice
(
consts
.
BUSINESS_TYPE_LIST
)
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment