本文整理汇总了Python中mrflog.mrflog.warn函数的典型用法代码示例。如果您正苦于以下问题:Python warn函数的具体用法?Python warn怎么用?Python warn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了warn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cmd_mrfctrl
def cmd_mrfctrl(self,data,wsid):
mrflog.warn( "cmd_mrfctrl here, data was %s"%repr(data))
if data['tab'] != self.graphid:
return
if data['row'] == 'days':
self.days = int(data['value'])
elif data['row'] == 'type':
self.graph_type = data['value']
if self.graph_type == 'Ambient':
sensor_ids=["LOUNGE_AMBIENT","OUTSIDE_AMBIENT"]
elif self.graph_type == 'Store':
sensor_ids=["ACC_100","ACC_60","ACC_30","ACC_RET"]
else:
sensor_ids=["ACC_100","ACC_60","ACC_30","OUTSIDE_AMBIENT"]
docdate = datetime.datetime.combine(datetime.datetime.now().date(),datetime.time())
self.rm.db_days_graph(sensor_ids=sensor_ids,stype='temp',docdate=docdate,wsid=wsid, wtag=self.graphtag(self.graphid),days=self.days)
示例2: time_tick
def time_tick(self):
if self._active:
mrflog.info("time_tick active");
if self.active_cmd == None:
mrflog.info("tick can run another cmd")
else:
mrflog.info("time_tick active resp_timer %d"%self.resp_timer)
self.resp_timer += 1
if self.resp_timer > 7:
mrflog.warn("give up waiting for response for %s"%( self.active_cmd))
if hasattr(self,'tcp_server') and self.tcp_server.tag_is_tcp_client(self.active_cmd.tag):
mrflog.info("response for tcp client %d"%self.active_cmd.tag)
mrflog.info("sending empty dict")
rstr = mrfland.to_json({})
self.tcp_server.write_to_client(self.active_cmd.tag,rstr)
self.active_cmd = None
if self.active_cmd == None:
self._check_if_anything()
if self._active:
self._set_timeout(0.1)
self.quiet_cnt = 0
else:
mrflog.info("inactive - setting 5 secs - quiet_cnt %d"%self.quiet_cnt)
self.quiet_cnt += 1
self._set_timeout(5.0)
if self.quiet_cnt % 5 == 0 :
#mrflog.info("calling state task qc %d"%self.quiet_cnt)
self.rm.quiet_task()
self.quiet_cnt = 0
示例3: setserver
def setserver(self,server): # OUCH , we let the server set a reference to itself..for now
self.server = server # Please only let a mrfland_server or subclass ever call this function
## run postinit
for wtag in self.weblets.keys():
wl = self.weblets[wtag]
if hasattr( wl, 'run_init'):
mrflog.warn( "calling run_init for weblet %s "%wtag)
getattr(wl, 'run_init')()
## rm should connect graph callbacks here
""" regmanager now keeps history for registered sensors """
self.shist = {}
self.shist_ts = []
self.shist_start_time = time.time() ## should be consistent with self.shist_ts[0]
self.shist_last_time = self.shist_start_time ## last time reading arrived
for sl in self.sgraphs.keys():
mrflog.warn("graph subscribe %s"%sl)
flds = self.sgraphs[sl]
self.shist[sl] = {}
for fld in flds:
self.shist[sl][fld] = []
#self.sensors[sl].subscribe_minutes(self.graph_callback)
# get sensors that have data in db
if hasattr(self,'db'):
tornado.ioloop.IOLoop.current().run_sync(lambda: self.db_get_sensors())
## start minute tick
self.server.start_minute_tick(0,self._minute_tick)
示例4: __init__
def __init__(self,config):
self.labels = {}
self.devices = {} ### hash devices by label - must be unique
self.devmap = {} ## hash devices by address
self.sensors = {} ### hash sensors by label
self.senstypes = {} ### hash lists of sensors by sensor type
self.senscaps = {} ## hash lists by cap string
self.actuators = {}
self.sensmap = {} ## keep physical mapping here - addr, chan dict returned for each sensor label
self.addresses = {} ### hash devices by address - must be unique
self.wups = [] ## webupdates from weblets to send to browsers
self.dups = [] ## device updates : from weblets to send to devices
self.hostname = socket.gethostname()
self.weblets = OrderedDict() # has weblets by tag
self.timers = {}
self.sgraphs = {} # support graph data for these sensors during this mrfland session
self.graph_insts = 0
self.config = config
self.comm = mrf_comm(log=mrflog)
if self.config.has_key('db_uri') and type(self.config['db_uri'])==type("") and self.config['db_uri'] != "":
from motor import motor_tornado
self.db = motor_tornado.MotorClient(self.config['db_uri']).mrfbus
mrflog.warn("opened db connection %s"%repr(self.db))
self.server = None
示例5: pane_html
def pane_html(self):
s = """<hr>
<div>
"""
s += mrfctrl_select_html(self.tag,self.graphid, 'days', ['1','7','28'],'Days')
s += mrfctrl_select_html(self.tag,self.graphid, 'type', ['Ambient','Store','Energy'],'Graph')
s += """
</div>
"""
s += '<div id="'+self.graphid+'"></div>'
if hasattr(self.rm,'db_sensors'):
sens = self.rm.db_sensors
mrflog.warn("pane_html got sensors %s"%repr(sens))
else:
sens = None
if False: # sens: FIXME - what is this , generates javascript browser error - NOT VALID!!
s += """
<script type="text/javascript">
"""+to_json(sens)+"""
</script>
"""
return s
示例6: cmd_mrfctrl
def cmd_mrfctrl(self,data, wsid=None):
mrflog.warn( "cmd_mrfctrl here, data was %s"%repr(data))
if not data.has_key("tab") or not data.has_key("row"):
mrflog.error("cmd_mrfctrl data problem in %s"%repr(data))
return
if data["tab"] != 'unit_test':
mrflog.error("weblet devs cmd_mrfctrl tab was not unit_test - got %s"%(repr(data["tab"])))
return
dn = data["row"]
if not self.test_active.has_key(dn):
mrflog.error("weblet devs cmd_mrfctrl row %s does not match any devname"%dn)
return
if self.test_active[dn]:
mrflog.warn( "unit_test already active for device %s"%repr(dn))
return
if not self.rm.devices.has_key(dn):
mrflog.warn( "can't find device %s registered"%repr(dn))
return
tdev = self.rm.devices[dn]
address = tdev.address
mrflog.warn( "starting unit_test for device %s address 0x%x"%(repr(dn),address))
rv = self.rm.subprocess(['/usr/bin/python', os.path.join(os.environ['MRFBUS_HOME'],'land','test_default.py' ), hex(address)] , self.subproc_callback(dn))
mrflog.warn("subprocess returned")
示例7: db_app_load_cfg_data
def db_app_load_cfg_data(self, **kwargs):
if not hasattr(self,'db'):
return
mrflog.warn("app_data_replace : kwargs %s"%repr(kwargs))
apptag = kwargs['apptag']
collname = '%s.cfg.webapps'%(self.hostname)
coll = self.db.get_collection(collname)
filt = {'tag' : apptag }
future = coll.find_one(filt)
result = yield future
mrflog.warn("loaded config for app %s result %s"%(apptag,repr(result)))
if result.has_key('data'):
self.weblets[apptag].restore_cfg(result['data'])
示例8: set_timeout
def set_timeout(self,seconds):
# start timer
mrflog.warn("%s : set_timeout seconds %d "%(self.__class__.__name__,seconds))
now = datetime.now()
td = timedelta(seconds = seconds)
tod = now + td
self.set_timer( tod.time() , 'state' , 'TO')
示例9: run_init
def run_init(self):
mrflog.warn("%s run_init"%(self.__class__.__name__))
# start timer
now = datetime.now()
td = timedelta(seconds = 30)
tod = now + td
self.set_timer( tod.time() , 'state' , 'TO')
示例10: pane_html
def pane_html(self):
""" just want to display pt1000sens output stucture"""
s = """
<h2>"""+self.label+" "+self.var.tank_top.html+" °C</h2>"
sensors = []
for level in self.ts:
sensors.append(self.ts[level].label)
sensors.append(self.return_sens.label)
s += self.rm.graph_inst({
"temp" : sensors
})
skeys = self.var.__dict__.keys()
skeys.sort()
mrflog.warn("store app var keys are %s"%repr(skeys))
s += """
<hr>
<h3>Temps</h3>"""
s += self.html_var_table(skeys)
return s
示例11: var_callback
def var_callback(self,name,wsid=None):
if False and self.__class__.__name__ == 'MrfSensMemory':
mrflog.warn("%s var_callback for %s value %s wsid %s"%(self.__class__.__name__, name, self.var.__dict__[name].val, repr(wsid)))
else:
mrflog.debug("%s var_callback for %s value %s wsid %s"%(self.__class__.__name__, name, self.var.__dict__[name].val, repr(wsid)))
if self.var.__dict__[name].public: # if set this var has been instanced in a webpage
mrflog.debug("%s running webupdate for %s value %s wsid %s"%(self.__class__.__name__, name, self.var.__dict__[name].val, repr(wsid)))
self.rm.webupdate(self.var.__dict__[name].webtag,
{ 'val' : self.var.__dict__[name].val}
)
self.rm.server._run_updates() # ouch
# hmpff... see if this var belongs to a timer
mob = MrflandWeblet._ret.match(name)
if mob and self._timers.has_key(mob.group(1)):
tn = mob.group(1)
mrflog.warn("timer var changed %s timer %s"%(name,tn))
self._eval_timer(tn)
tmr = self._timers[tn]
if tmr.en.val : # make sure timers are set
for act in ['on','off']:
aval = tmr.__dict__[act]
self.set_timer( aval.tod , tn , act)
if self.var.__dict__[name].__class__.__name__ == 'MrfWebletConfigVar':
self._cfg_touched = True
if hasattr(self,'var_changed'):
self.var_changed(name,wsid=wsid)
示例12: restore_cfg
def restore_cfg(self,data):
mrflog.warn("weblet %s restoring data %s"%(self.tag,repr(data)))
for vn in data.keys():
mrflog.warn("setting var %s to %s"%(vn,repr(data[vn])))
dv = self.var.__dict__[vn]._val.__class__(data[vn]) # FIXME str types are unicode when they come back from DB
self.var.__dict__[vn].set(dv)
示例13: init
def init(self):
mrflog.info("%s init"%(self.__class__.__name__))
# do subscriptions here
## looking for all MrfSensPt1000 types
if not self.rm.senstypes.has_key(MrfSensPt1000):
mrflog.error("%s post_init failed to find sensor type MrfSensPt1000 in rm"%self.__class__.__name__)
return
ts = self.rm.senstypes[MrfSensPt1000]
mrflog.info("num MrfSensPt1000 found was %d"%len(ts))
self.slabs = []
self.sens = OrderedDict()
if not self.cdata.has_key('acc_tag'):
mrflog.error("%s , no acc_tag in data")
return
if not self.cdata.has_key('acc_litres'):
mrflog.error("%s , no acc_litres in data")
return
self.litres = self.cdata['acc_litres']
self.top_ts = self.rm.sens_search_vector_max(MrfSensPt1000, self.cdata['acc_tag'])
self.add_var('tank_top',self.top_ts, field='temp', graph=True)
self.return_sens = self.rm.sens_search(self.cdata['acc_tag'] + "_RET")
self.add_var('return_temp',self.return_sens, field='temp', graph=True)
self.ts = self.rm.sens_search_vector(MrfSensPt1000, self.cdata['acc_tag'])
for l in self.ts: #
s = self.ts[l]
self.add_var(s.label,s, field='temp', graph=True)
mrflog.warn("Store has temp sensors at following levels %s"%repr(self.ts.keys()))
示例14: timer_callback
def timer_callback(self, app, tag , act):
mrflog.warn("RegManager timer_callback, app %s tag %s act %s",app, tag,act)
if not self.weblets.has_key(app):
mrflog.error("%s timer_callback no app %s "%(self.__class__.__name__,app, tid,len(self.timers[tid])))
return
self.weblets[app]._timer_callback(tag, act)
示例15: init
def init(self):
mrflog.info("%s init"%(self.__class__.__name__))
# do subscriptions here
## looking for all devs
dadds = self.rm.devmap.keys()
mrflog.warn("got dadds %s"%repr(dadds))
self.devs = OrderedDict()
dadds.sort()
self.devnames = []
for dadd in dadds:
dev = self.rm.devmap[dadd]
self.devs[dev.label] = dev
self.devnames.append(dev.label)
mrflog.warn("MrfLandWebletDevs added dev label %s add %s"%(dev.label, dev.address))
self.devs[dev.label].subscribe(self.sens_callback)
# build prototype output data
utest = OrderedDict()
utest['last_run'] = ''
utest['last_result'] = ''
self.pod = OrderedDict()
self.pod['unit_test'] = utest
self.pod['dev_info'] = PktDeviceInfo().dic()
self.pod['dev_status'] = PktDeviceStatus().dic()
self.pod['sys_info'] = PktSysInfo().dic()
self.pod['app_info'] = PktAppInfo().dic()
self.test_active = {}
for dn in self.devnames:
self.test_active[dn] = False