1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- from demeter import *
- model = Demeter.model('manage_admin')
- model.id = 1
- info = model.select(type='fetchone')
- if not info:
- model.role_id = 1
- model.username = 'admin'
- model.mobile = '15810090845'
- model.password = '123456'
- model.insert()
- model = Demeter.model('manage_role')
- model.id = 1
- info = model.select(type='fetchone')
- if not info:
- model.name = '管理员'
- model.insert()
- model = Demeter.model('content')
- model.id = 1
- info = model.select(type='fetchone')
- if not info:
- model.name = '农小盒'
- model.subname = '农作物生长监测与产品溯源'
- model.insert()
- model = Demeter.model('farm')
- model.id = 1
- info = model.select(type='fetchone')
- if not info:
- model.name = '默认园区'
- model.insert()
- # 初始化网关,测试用
- model = Demeter.model('device_gateway')
- model.hardware_id = 10086
- info = model.select(type='fetchone')
- if not info:
- model.farm_id = 1
- model.hardware_id = 10086
- model.name = '默认网关'
- model.insert()
- # 初始化设备类型
- device_type = ({'name':'温度', 'key':'temprature', 'unit':'℃'},{'name':'湿度', 'key':'humidity','unit':'%RH'})
- model = Demeter.model('device_type')
- for value in device_type:
- model.key = value['key']
- info = model.select(type='fetchone')
- if not info:
- model.key = value['key']
- model.name = value['name']
- model.exp = '{n}'
- model.unit = value['unit']
- model.insert()
- # 初始化硬件类型
- hardware_type = ({'name':'网关','key':'gateway'},{'name':'传感器', 'key':'sensor'},{'name':'控制器', 'key':'control'},{'name':'电源', 'key':'power'},{'name':'摄像机', 'key':'pic'},{'name':'状态器', 'key':'status'})
- model = Demeter.model('hardware_type')
- for value in hardware_type:
- model.key = value['key']
- info = model.select(type='fetchone')
- if not info:
- model.key = value['key']
- model.name = value['name']
- model.insert()
- # 初始化消息类型
- msg_type = ({'name':'系统消息', 'key':'system'},{'name':'警告提醒', 'key':'notice'},{'name':'操作提示', 'key':'oper'},{'name':'新闻', 'key':'news'})
- model = Demeter.model('msg_type')
- for value in msg_type:
- model.key = value['key']
- info = model.select(type='fetchone')
- if not info:
- model.key = value['key']
- model.name = value['name']
- model.insert()
- print 'install success!'
|