|
@@ -4,8 +4,6 @@ from datetime import *
|
|
|
import uuid
|
|
|
import os
|
|
|
import os.path
|
|
|
-import requests
|
|
|
-import shutil
|
|
|
|
|
|
class Convert(object):
|
|
|
|
|
@@ -98,6 +96,7 @@ class Convert(object):
|
|
|
|
|
|
def download(self, file, local):
|
|
|
if 'http' in file:
|
|
|
+ import requests
|
|
|
r = requests.get(file, stream=True)
|
|
|
with open(local, 'wb') as up:
|
|
|
for chunk in r.iter_content(chunk_size=1024):
|
|
@@ -105,6 +104,7 @@ class Convert(object):
|
|
|
up.write(chunk)
|
|
|
|
|
|
else:
|
|
|
+ import shutil
|
|
|
shutil.copyfile(file, local)
|
|
|
|
|
|
if File.exists(local):
|
|
@@ -116,7 +116,7 @@ class Convert(object):
|
|
|
convert = convert + 'libreoffice --invisible --convert-to pdf ' + info['local']
|
|
|
convert = convert + ' && '
|
|
|
convert = convert + 'pdf2htmlEX --zoom 1.3 --no-drm 1 --split-pages 1 '
|
|
|
- convert = convert + '--embed-css 1 --embed-javascript 0 --embed-image 0 --embed-font 1 '
|
|
|
+ convert = convert + '--embed-css 1 --embed-javascript 0 --embed-image 0 --embed-font 1 --process-outline 0 '
|
|
|
convert = convert + '--embed-external-font 0 --dest-dir '+info['path']+' --page-filename %d.page ' + info['pdf']
|
|
|
|
|
|
return convert
|
|
@@ -145,19 +145,17 @@ class Convert(object):
|
|
|
model.id = id
|
|
|
update = {}
|
|
|
update['status'] = 2
|
|
|
- #model.update(update)
|
|
|
+ model.update(update)
|
|
|
|
|
|
if not File.exists(info['local']):
|
|
|
self.download(info['file'], info['local'])
|
|
|
|
|
|
if not File.exists(info['html']):
|
|
|
handle = self.command(info)
|
|
|
- print handle
|
|
|
- return
|
|
|
Shell.popen(handle)
|
|
|
if File.exists(info['html']):
|
|
|
|
|
|
- self.string_switch(info['html'], "taste", "tasting")
|
|
|
+ #self.string_switch(info['html'], "taste", "tasting")
|
|
|
# 获取有多少页
|
|
|
page = self.total(info['path'])
|
|
|
model.id = id
|