|
@@ -8,13 +8,39 @@
|
|
"""
|
|
"""
|
|
import time
|
|
import time
|
|
import json
|
|
import json
|
|
|
|
+import uuid
|
|
|
|
+from datetime import *
|
|
from demeter import *
|
|
from demeter import *
|
|
class Record_pic(object):
|
|
class Record_pic(object):
|
|
-
|
|
|
|
|
|
+ pic = {}
|
|
def handle(self, config, value):
|
|
def handle(self, config, value):
|
|
- print config['type']
|
|
|
|
method = config['type'].split('_')
|
|
method = config['type'].split('_')
|
|
- name = method[0]
|
|
|
|
- total = method[1]
|
|
|
|
- index = method[2]
|
|
|
|
-
|
|
|
|
|
|
+ name = method[0] + '.jpg'
|
|
|
|
+ if name not in self.pic:
|
|
|
|
+ self.pic[name] = {}
|
|
|
|
+ total = int(method[1])
|
|
|
|
+ index = int(method[2])
|
|
|
|
+ self.pic[name][index] = value
|
|
|
|
+ picLen = len(self.pic[name])
|
|
|
|
+ if picLen >= total:
|
|
|
|
+ self.create(name)
|
|
|
|
+
|
|
|
|
+ def create(self, name):
|
|
|
|
+ pic = sorted(self.pic[name].items(), key=lambda e:e[0], reverse=False)
|
|
|
|
+ data = []
|
|
|
|
+ day = str(date.today())
|
|
|
|
+ day = day.split('-')
|
|
|
|
+ file_name = str(uuid.uuid5(uuid.uuid1(), 'file'))
|
|
|
|
+ file_path = day[0] + '/' + day[1] + '/' + day[2]
|
|
|
|
+ file_path = File.mkdirs(os.path.join(Demeter.path, 'runtime','camera', file_path)) + '/' + Demeter.md5(file_name) + '.jpg'
|
|
|
|
+
|
|
|
|
+ for value in pic:
|
|
|
|
+ data.append(value[1])
|
|
|
|
+ with open(file_path, 'wb') as f:
|
|
|
|
+ f.writelines(data)
|
|
|
|
+ del self.pic[name]
|
|
|
|
+
|
|
|
|
+ self.write(file_path)
|
|
|
|
+
|
|
|
|
+ def write(self, file):
|
|
|
|
+ return
|