|
@@ -15,7 +15,7 @@ class Convert(object):
|
|
|
|
|
|
return data
|
|
return data
|
|
|
|
|
|
- def update(self, site, site_key, file):
|
|
|
|
|
|
+ def update(self, site, site_key, file, file_id):
|
|
|
|
|
|
info = self.getFile(site_key, file)
|
|
info = self.getFile(site_key, file)
|
|
|
|
|
|
@@ -26,6 +26,7 @@ class Convert(object):
|
|
data = convert.select(type='fetchone')
|
|
data = convert.select(type='fetchone')
|
|
if not data:
|
|
if not data:
|
|
convert.site_id = site
|
|
convert.site_id = site
|
|
|
|
+ convert.file_id = file_id
|
|
convert.file = info['file']
|
|
convert.file = info['file']
|
|
convert.key = info['key']
|
|
convert.key = info['key']
|
|
convert.name = info['name']
|
|
convert.name = info['name']
|
|
@@ -138,6 +139,10 @@ class Convert(object):
|
|
|
|
|
|
if not info:
|
|
if not info:
|
|
return
|
|
return
|
|
|
|
+ siteModel = Demeter.model('site')
|
|
|
|
+ siteModel.id = info['site_id']
|
|
|
|
+ site = siteModel.select(type='fetchone')
|
|
|
|
+
|
|
status = True
|
|
status = True
|
|
if info['status'] == 1 or info['status'] == 4:
|
|
if info['status'] == 1 or info['status'] == 4:
|
|
status = False
|
|
status = False
|
|
@@ -167,6 +172,9 @@ class Convert(object):
|
|
update['page'] = page
|
|
update['page'] = page
|
|
update['status'] = 3
|
|
update['status'] = 3
|
|
model.update(update)
|
|
model.update(update)
|
|
|
|
+
|
|
|
|
+ # 通知接口 通知应用成功转换
|
|
|
|
+ self.api(info, site)
|
|
return
|
|
return
|
|
|
|
|
|
model.id = id
|
|
model.id = id
|
|
@@ -174,6 +182,33 @@ class Convert(object):
|
|
update['status'] = 4
|
|
update['status'] = 4
|
|
model.update(update)
|
|
model.update(update)
|
|
|
|
|
|
|
|
+ def api(self, info, site):
|
|
|
|
+ if 'file_id' in info and info['file_id']:
|
|
|
|
+ api = site['api']
|
|
|
|
+ key = site['key']
|
|
|
|
+ token = site['token']
|
|
|
|
+ file = info['file']
|
|
|
|
+ file_id = info['file_id']
|
|
|
|
+
|
|
|
|
+ url = info['url']
|
|
|
|
+ page = info['page']
|
|
|
|
+ ext = info['ext']
|
|
|
|
+
|
|
|
|
+ nonce = Demeter.time()
|
|
|
|
+ sign = Demeter.md5(key + '&' + token + '&' + nonce + '&' + file_id + '&' + url);
|
|
|
|
+
|
|
|
|
+ param = {}
|
|
|
|
+ param['signature'] = sign
|
|
|
|
+ param['key'] = key
|
|
|
|
+ param['nonce'] = nonce
|
|
|
|
+ param['file_id'] = file_id
|
|
|
|
+ param['url'] = url
|
|
|
|
+ param['page'] = page
|
|
|
|
+ param['ext'] = ext
|
|
|
|
+
|
|
|
|
+ Demeter.curl(api, param, 'post')
|
|
|
|
+
|
|
|
|
+
|
|
def cut(self, info):
|
|
def cut(self, info):
|
|
pdf = Image(filename=info['pdf'], resolution=50)
|
|
pdf = Image(filename=info['pdf'], resolution=50)
|
|
jpg = pdf.convert('jpg')
|
|
jpg = pdf.convert('jpg')
|