|
@@ -290,7 +290,7 @@ class Device(object):
|
|
|
self.data['pic'][key]['cdates'] = Demeter.date(value['sdate'])
|
|
|
|
|
|
@staticmethod
|
|
|
- def statBase(self, deviceInfo={}):
|
|
|
+ def statBase(self, deviceInfo={}, state=False):
|
|
|
device = self.input('device')
|
|
|
method = self.input('method', 'maxmin')
|
|
|
if not device:
|
|
@@ -324,7 +324,9 @@ class Device(object):
|
|
|
search['type'] = type
|
|
|
search['id'] = id
|
|
|
self.data['search'] = search
|
|
|
- self.data['statList'] = model.getData(method, search, self.data['deviceInfo'])
|
|
|
+ out = self.input('out')
|
|
|
+ if not out:
|
|
|
+ self.data['statList'] = model.getData(method, search, self.data['deviceInfo'])
|
|
|
@staticmethod
|
|
|
def stat(self):
|
|
|
id, type = Device.init(self, search={'hardware_type--ins':[2,4]})
|
|
@@ -333,6 +335,36 @@ class Device(object):
|
|
|
Device.statBase(self, self.data['device'][0])
|
|
|
self.data['url'] = Device.url('type='+type+'&id=' + id)
|
|
|
|
|
|
+ @staticmethod
|
|
|
+ def out(self):
|
|
|
+ id, type = Device.init(self, search={'hardware_type--ins':[2,4]})
|
|
|
+ if not id:
|
|
|
+ return
|
|
|
+ Device.statBase(self, self.data['device'][0])
|
|
|
+ self.data['url'] = Device.url('type='+type+'&id=' + id)
|
|
|
+
|
|
|
+ if 'statList' in self.data:
|
|
|
+ import csv
|
|
|
+ from datetime import *
|
|
|
+ import uuid
|
|
|
+ self.set_header("Content-Type","text/csv,charset=UTF-8")
|
|
|
+ datas = [['name', 'age'],
|
|
|
+ ['Bob', 14],
|
|
|
+ ['Tom', 23],
|
|
|
+ ['Jerry', '18']]
|
|
|
+
|
|
|
+ day = str(date.today())
|
|
|
+ day = day.split('-')
|
|
|
+ file_name = self.data['deviceInfo']['name']
|
|
|
+ file_path = day[0] + '/' + day[1] + '/' + day[2]
|
|
|
+ file_path = File.mkdirs(os.path.join(Demeter.path, 'runtime','upload', file_path)) + '/' + file_name + '.csv'
|
|
|
+ with open(file_path, 'w', newline='') as f:
|
|
|
+ writer = csv.writer(f)
|
|
|
+ for row in datas:
|
|
|
+ writer.writerow(row)
|
|
|
+ self.finish()
|
|
|
+ return
|
|
|
+
|
|
|
@staticmethod
|
|
|
def log(self):
|
|
|
id, type = Device.init(self)
|
|
@@ -386,6 +418,7 @@ class Device(object):
|
|
|
config['stat'] = '/device/stat?' + param;
|
|
|
config['log'] = '/device/log?' + param;
|
|
|
config['pic'] = '/device/pic?' + param;
|
|
|
+ config['out'] = '/device/out?' + param + '&out=1';
|
|
|
return config
|
|
|
|
|
|
@staticmethod
|