예제 #1
0
파일: pwm.py 프로젝트: ZigmundRat/moat
	def load(self):
		main_words.register_statement(PWMHandler)
		main_words.register_statement(PWMUpdate)
		main_words.register_statement(PWMSet)
		main_words.register_statement(VarPWMHandler)
		register_condition(PWMs.exists)
		register_condition(OnPWMCheck)
예제 #2
0
파일: amqp.py 프로젝트: ZigmundRat/moat
 def load(self):
     main_words.register_statement(AMQPconn)
     main_words.register_statement(AMQPstart)
     main_words.register_statement(AMQPstop)
     main_words.register_statement(AMQPlog)
     main_words.register_statement(AMQPtell)
     main_words.register_statement(AMQPlisten)
     register_condition(AMQPclients.exists)
예제 #3
0
파일: amqp.py 프로젝트: M-o-a-T/moat
	def load(self):
		main_words.register_statement(AMQPconn)
		main_words.register_statement(AMQPstart)
		main_words.register_statement(AMQPstop)
		main_words.register_statement(AMQPlog)
		main_words.register_statement(AMQPtell)
		main_words.register_statement(AMQPlisten)
		register_condition(AMQPclients.exists)
예제 #4
0
파일: timeslot.py 프로젝트: ZigmundRat/moat
	def load(self):
		main_words.register_statement(TimeslotHandler)
		main_words.register_statement(TimeslotUpdate)
		main_words.register_statement(TimeslotStart)
		main_words.register_statement(TimeslotStop)
		main_words.register_statement(VarTimeslotHandler)
		register_condition(RunningTimeslotCheck)
		register_condition(DuringTimeslotCheck)
예제 #5
0
파일: monitor.py 프로젝트: ZigmundRat/moat
	def load(self):
		main_words.register_statement(MonitorMaker)
		main_words.register_statement(MonitorHandler)
		main_words.register_statement(MonitorUpdate)
		main_words.register_statement(MonitorSet)
		main_words.register_statement(MonitorStart)
		main_words.register_statement(MonitorStop)
		main_words.register_statement(VarMonitorHandler)
		register_condition(RunningMonitorCheck)
		register_condition(WaitingMonitorCheck)
예제 #6
0
파일: state.py 프로젝트: ZigmundRat/moat
 def load(self):
     main_words.register_statement(StateHandler)
     main_words.register_statement(SetStateHandler)
     main_words.register_statement(VarStateHandler)
     main_words.register_statement(ForgetStateHandler)
     register_condition(StateCheck)
     register_condition(StateLockedCheck)
     register_condition(LastStateCheck)
     register_condition(States.exists)
     register_condition(SavedStateCheck)
예제 #7
0
파일: state.py 프로젝트: smurfix/MoaT
	def load(self):
		main_words.register_statement(StateHandler)
		main_words.register_statement(SetStateHandler)
		main_words.register_statement(VarStateHandler)
		main_words.register_statement(ForgetStateHandler)
		register_condition(StateCheck)
		register_condition(StateLockedCheck)
		register_condition(LastStateCheck)
		register_condition(States.exists)
		register_condition(SavedStateCheck)
예제 #8
0
파일: avg.py 프로젝트: M-o-a-T/moat
	def load(self):
		mlen=0
		for v in globals().values():
			m = getattr(v,"mode",None)
			if m is None: continue
			modes[m] = v
			if mlen < len(m): mlen = len(m)
		for v in modes.values():
			AvgHandler.long_doc += v.mode+" "*(mlen-len(v.mode)+1)+v.doc+"\n"

		main_words.register_statement(AvgHandler)
		main_words.register_statement(AvgSet)
		main_words.register_statement(AvgReset)
		main_words.register_statement(VarAvgHandler)
		register_condition(Avgs.exists)
예제 #9
0
	def load(self):
		main_words.register_statement(RRDconnect)
		main_words.register_statement(RRDsetfile)
		main_words.register_statement(RRDset)
		register_condition(RRDconnected)
		register_condition(RRDchannels.exists)
		register_condition(RRDservers.exists)
		register_condition(RRDfiles.exists)
예제 #10
0
파일: avg.py 프로젝트: ZigmundRat/moat
    def load(self):
        mlen = 0
        for v in globals().values():
            m = getattr(v, "mode", None)
            if m is None: continue
            modes[m] = v
            if mlen < len(m): mlen = len(m)
        for v in modes.values():
            AvgHandler.long_doc += v.mode + " " * (mlen - len(v.mode) +
                                                   1) + v.doc + "\n"

        main_words.register_statement(AvgHandler)
        main_words.register_statement(AvgSet)
        main_words.register_statement(AvgReset)
        main_words.register_statement(VarAvgHandler)
        register_condition(Avgs.exists)
예제 #11
0
파일: net.py 프로젝트: smurfix/MoaT
	def load(self):
		main_words.register_statement(NETlisten)
		main_words.register_statement(NETconnect)
		main_words.register_statement(NETsend)
		register_condition(Nets.exists)
		register_condition(NetListens.exists)
		register_condition(NETconnected)
예제 #12
0
파일: net.py 프로젝트: ZigmundRat/moat
 def load(self):
     main_words.register_statement(NETlisten)
     main_words.register_statement(NETconnect)
     main_words.register_statement(NETsend)
     register_condition(Nets.exists)
     register_condition(NetListens.exists)
     register_condition(NETconnected)
예제 #13
0
파일: wago.py 프로젝트: ZigmundRat/moat
 def load(self):
     main_words.register_statement(WAGOconnect)
     main_words.register_statement(WAGOmonitor)
     main_words.register_statement(WAGOraw)
     register_condition(WAGOconnected)
     register_condition(WAGOservers.exists)
     register_condition(WAGOchannels.exists)
     register_input(WAGOinput)
     register_output(WAGOoutput)
예제 #14
0
파일: wago.py 프로젝트: smurfix/MoaT
	def load(self):
		main_words.register_statement(WAGOconnect)
		main_words.register_statement(WAGOmonitor)
		main_words.register_statement(WAGOraw)
		register_condition(WAGOconnected)
		register_condition(WAGOservers.exists)
		register_condition(WAGOchannels.exists)
		register_input(WAGOinput)
		register_output(WAGOoutput)
예제 #15
0
파일: onewire.py 프로젝트: smurfix/MoaT
	def load(self):
		global _new_bus_ev
		_new_bus_ev = NewBusEvent()

		main_words.register_statement(OWFSconnect)
		main_words.register_statement(OWFSdisconnect)
		main_words.register_statement(OWFSdir)
		main_words.register_statement(OWFSscan)
		main_words.register_statement(OWFSset)
		main_words.register_statement(OWFSmonitor)
		main_words.register_statement(OWFSpoll)
		main_words.register_statement(AutoPoll)
		register_input(OWFSinput)
		register_output(OWFSoutput)
		register_condition(OWFSconnected)
		register_condition(OWFSconnectedbus)
		register_condition(OWFSpolls.exists)
예제 #16
0
파일: onewire.py 프로젝트: ZigmundRat/moat
    def load(self):
        global _new_bus_ev
        _new_bus_ev = NewBusEvent()

        main_words.register_statement(OWFSconnect)
        main_words.register_statement(OWFSdisconnect)
        main_words.register_statement(OWFSdir)
        main_words.register_statement(OWFSscan)
        main_words.register_statement(OWFSset)
        main_words.register_statement(OWFSmonitor)
        main_words.register_statement(OWFSpoll)
        main_words.register_statement(AutoPoll)
        register_input(OWFSinput)
        register_output(OWFSoutput)
        register_condition(OWFSconnected)
        register_condition(OWFSconnectedbus)
        register_condition(OWFSpolls.exists)
예제 #17
0
파일: path.py 프로젝트: ZigmundRat/moat
 def load(self):
     register_condition(ExistsPathCheck)
     register_condition(ExistsFileCheck)
     register_condition(ExistsDirCheck)
예제 #18
0
파일: in_out.py 프로젝트: M-o-a-T/moat
from moat.check import register_condition
from moat.delay import DelayFor,DelayWhile,DelayUntil,DelayNext, DelayCancelled

import gevent
from gevent.event import AsyncResult

import os
import sys
import socket
import errno

class Inputs(Collection):
	name = "input"
Inputs = Inputs()
Inputs.does("del")
register_condition(Inputs.exists)

class Outputs(Collection):
	name = "output"
Outputs = Outputs()
Outputs.does("del")
register_condition(Outputs.exists)

@six.python_2_unicode_compatible
class BadValue(RuntimeError):
	"""The input doesn't match the expected values"""
	def __init__(self, inp,val):
		self.inp = inp
		self.val = val
	def __str__(self):
		return "BadValue: read %s: bad value for %s" % (self.val,self.inp)
예제 #19
0
파일: wait.py 프로젝트: ZigmundRat/moat
 def load(self):
     main_words.register_statement(WaitHandler)
     main_words.register_statement(VarWaitHandler)
     register_condition(Waiters.exists)
예제 #20
0
파일: onewire.py 프로젝트: ZigmundRat/moat
        flags |= OWdevformat.fdi << OWdevformat._offset

        log("onewire", DEBUG, "SEND", 0, len(data), typ, flags, rlen, 0,
            repr(data))
        self.write(struct.pack("!6i", \
         0, len(data), typ, flags, rlen, 0) +data)


class OWchans(Collection):
    name = "onewire connection"


OWchans = OWchans()
OWchans.does("del")
OWchans2 = {}
register_condition(OWchans.exists)


class OWFSchannel(OWFSassembler, NetActiveConnector):
    """A receiver for the protocol used by OWFS."""
    storage = OWchans.storage
    storage2 = OWchans2
    typ = "onewire"

    def down_event(self, external=False):
        simple_event("onewire", "disconnect", *self.name, deprecated=True)
        simple_event("onewire", "link", "state", *self.name, state="down")

    def up_event(self, external=False):
        simple_event("onewire", "connect", *self.name, deprecated=True)
        simple_event("onewire", "link", "state", *self.name, state="up")
예제 #21
0
파일: on_event.py 프로젝트: smurfix/MoaT
	def load(self):
		main_words.register_statement(OnEventHandler)
		main_words.register_statement(OnSkip)
		main_words.register_statement(OnSkip2)
		register_condition(OnHandlers.exists)
예제 #22
0
파일: data.py 프로젝트: M-o-a-T/moat
	def load(self):
		main_words.register_statement(List)
		main_words.register_statement(Del)
		register_condition(VarCheck)
예제 #23
0
파일: rpc.py 프로젝트: smurfix/MoaT
	def load(self):
		main_words.register_statement(RPClisten)
		register_condition(RPCconns.exists)
		register_condition(RPCservers.exists)
예제 #24
0
파일: fs20en.py 프로젝트: M-o-a-T/moat
	def load(self):
		PREFIX[PREFIX_ENERGY] = en_handler()
		main_words.register_statement(FS20en)
		main_words.register_statement(FS20enVal)
		register_condition(ENs.exists)
예제 #25
0
파일: fs20tx.py 프로젝트: ZigmundRat/moat
 def load(self):
     PREFIX[PREFIX_TX] = tx_handler()
     main_words.register_statement(FS20tx)
     main_words.register_statement(FS20txVal)
     register_condition(TXs.exists)
예제 #26
0
파일: fs20avr.py 프로젝트: M-o-a-T/moat
	def load(self):
		main_words.register_statement(AVRconnect)
		main_words.register_statement(AVRsend)
		register_condition(AVRs.exists)
		register_condition(AVRconnected)
예제 #27
0
파일: wait.py 프로젝트: smurfix/MoaT
	def load(self):
		main_words.register_statement(WaitHandler)
		main_words.register_statement(VarWaitHandler)
		register_condition(Waiters.exists)
예제 #28
0
파일: bool.py 프로젝트: M-o-a-T/moat
	def load(self):
		register_condition(TrueCheck)
		register_condition(FalseCheck)
		register_condition(NoneCheck)
		register_condition(EqualCheck)
		register_condition(LessCheck)
		register_condition(GreaterCheck)
예제 #29
0
파일: fs20tx.py 프로젝트: smurfix/MoaT
	def load(self):
		PREFIX[PREFIX_TX] = tx_handler()
		main_words.register_statement(FS20tx)
		main_words.register_statement(FS20txVal)
		register_condition(TXs.exists)
예제 #30
0
 def load(self):
     register_condition(TrueCheck)
     register_condition(FalseCheck)
     register_condition(NoneCheck)
     register_condition(EqualCheck)
     register_condition(LessCheck)
     register_condition(GreaterCheck)
예제 #31
0
파일: module.py 프로젝트: M-o-a-T/moat
def par(_): return os.path.join(os.pardir,_)
#if os.path.exists("modules"):
#	ModuleDirs.append("modules")
#elif os.path.exists(par("modules")) and os.path.exists(par("Makefile")):
#	ModuleDirs.append(par("modules"))

class ModuleExistsError(RuntimeError):
	"""A module with that name already exists."""
	pass

class Modules(Collection):
	name = "module"
	prio = 99
Modules = Modules()
Modules.does("del")
register_condition(Modules.exists)

class Module(Collected):
	"""\
		This is a loadable module. See moat.config.py, the
		"Loader" and "Unloader" classes, for examples.
		"""

	name = "Module"
	storage = Modules.storage
	info = "some idiot programmer forgot to override me"
	path = None

	def __init__(self, *name):
		"""\
			Initialize a module. The arguments are passed in from the 
예제 #32
0
파일: logging.py 프로젝트: smurfix/MoaT
	def load(self):
		main_words.register_statement(LogHandler)
		main_words.register_statement(LogLevelHandler)
		register_condition(Loggers.exists)
예제 #33
0
 def load(self):
     main_words.register_statement(OnEventHandler)
     main_words.register_statement(OnSkip)
     main_words.register_statement(OnSkip2)
     register_condition(OnHandlers.exists)
예제 #34
0
 def load(self):
     main_words.register_statement(RPClisten)
     register_condition(RPCconns.exists)
     register_condition(RPCservers.exists)
예제 #35
0
파일: logging.py 프로젝트: ZigmundRat/moat
	def load(self):
		main_words.register_statement(LogHandler)
		main_words.register_statement(LogLevelHandler)
		register_condition(Loggers.exists)
예제 #36
0
파일: fs20en.py 프로젝트: ZigmundRat/moat
 def load(self):
     PREFIX[PREFIX_ENERGY] = en_handler()
     main_words.register_statement(FS20en)
     main_words.register_statement(FS20enVal)
     register_condition(ENs.exists)
예제 #37
0
파일: fs20em.py 프로젝트: ZigmundRat/moat
	def load(self):
		PREFIX[PREFIX_EM] = em_handler()
		PREFIX[PREFIX_EM2] = em2_handler()
		main_words.register_statement(FS20em)
		main_words.register_statement(FS20emVal)
		register_condition(EMs.exists)
예제 #38
0
파일: fs20switch.py 프로젝트: M-o-a-T/moat
	def load(self):
		main_words.register_statement(FS20switches)
		main_words.register_statement(FS20send)
		register_condition(SwitchGroups.exists)
		register_condition(Switches.exists)
예제 #39
0
파일: in_out.py 프로젝트: ZigmundRat/moat
import gevent
from gevent.event import AsyncResult

import os
import sys
import socket
import errno


class Inputs(Collection):
    name = "input"


Inputs = Inputs()
Inputs.does("del")
register_condition(Inputs.exists)


class Outputs(Collection):
    name = "output"


Outputs = Outputs()
Outputs.does("del")
register_condition(Outputs.exists)


@six.python_2_unicode_compatible
class BadValue(RuntimeError):
    """The input doesn't match the expected values"""
    def __init__(self, inp, val):
예제 #40
0
 def load(self):
     main_words.register_statement(List)
     main_words.register_statement(Del)
     register_condition(VarCheck)
예제 #41
0
파일: rrd.py 프로젝트: smurfix/MoaT
	def load(self):
		main_words.register_statement(RRDHandler)
		main_words.register_statement(RRDset)
		main_words.register_statement(VarRRDHandler)
		register_condition(RRDs.exists)
예제 #42
0
파일: monitor.py 프로젝트: smurfix/MoaT
from moat.collect import Collection,Collected
from moat.check import register_condition

from gevent.event import Event as gEvent
from gevent.queue import Channel,Queue
import gevent

from time import time
import os,sys
import datetime as dt

class Monitors(Collection):
	name = "monitor"
Monitors = Monitors()
Monitors.does("del")
register_condition(Monitors.exists)

class MonitorAgain(RuntimeError):
	"""The monitor is not ready yet; retry please"""
	pass

@six.python_2_unicode_compatible
class MonitorError(RuntimeError):
	def __init__(self,w):
		self.monitor = w
	def __str__(self):
		return self.text % (" ".join(six.text_type(x) for x in self.monitor.name),)

class DupMonitorError(MonitorError):
	text = u"A monitor ‹%s› already exists"
예제 #43
0
파일: onewire.py 프로젝트: smurfix/MoaT
		# needed for sometimes-broken 1wire daemons
		flags |= OWFlag.busret
		# flags |= 1<<8 ## ?
		flags |= OWtempformat.celsius << OWtempformat._offset
		flags |= OWdevformat.fdi << OWdevformat._offset

		log("onewire",DEBUG,"SEND", 0, len(data), typ, flags, rlen, 0, repr(data))
		self.write(struct.pack("!6i", \
			0, len(data), typ, flags, rlen, 0) +data)

class OWchans(Collection):
       name = "onewire connection"
OWchans = OWchans()
OWchans.does("del")
OWchans2 = {}
register_condition(OWchans.exists)

class OWFSchannel(OWFSassembler, NetActiveConnector):
	"""A receiver for the protocol used by OWFS."""
	storage = OWchans.storage
	storage2 = OWchans2
	typ = "onewire"

	def down_event(self, external=False):
		simple_event("onewire","disconnect",*self.name, deprecated=True)
		simple_event("onewire","link","state",*self.name, state="down")

	def up_event(self, external=False):
		simple_event("onewire","connect",*self.name, deprecated=True)
		simple_event("onewire","link","state",*self.name, state="up")
예제 #44
0
파일: module.py 프로젝트: ZigmundRat/moat
#	ModuleDirs.append(par("modules"))


class ModuleExistsError(RuntimeError):
    """A module with that name already exists."""
    pass


class Modules(Collection):
    name = "module"
    prio = 99


Modules = Modules()
Modules.does("del")
register_condition(Modules.exists)


class Module(Collected):
    """\
		This is a loadable module. See moat.config.py, the
		"Loader" and "Unloader" classes, for examples.
		"""

    name = "Module"
    storage = Modules.storage
    info = "some idiot programmer forgot to override me"
    path = None

    def __init__(self, *name):
        """\
예제 #45
0
파일: path.py 프로젝트: smurfix/MoaT
	def load(self):
		register_condition(ExistsPathCheck)
		register_condition(ExistsFileCheck)
		register_condition(ExistsDirCheck)
예제 #46
0
파일: timeslot.py 프로젝트: ZigmundRat/moat
from moat.base import Name
from moat.twist import callLater, fix_exception
from moat.context import Context
from moat.check import register_condition
from moat.logging import log,TRACE,DEBUG,ERROR
from moat.collect import Collection,Collected

from time import time
import os
import datetime as dt

class Timeslots(Collection):
	name = "timeslot"
Timeslots = Timeslots()
Timeslots.does("del")
register_condition(Timeslots.exists)

class Timeslotted(object):
	pass
#	def slot_up(self):
#		pass
#	def slot_down(self):
#		pass

@six.python_2_unicode_compatible
class TimeslotError(RuntimeError):
	def __init__(self,w):
		self.timeslot = w
	def __str__(self):
		return self.text % (" ".join(six.text_type(x) for x in self.timeslot.name),)
예제 #47
0
 def load(self):
     main_words.register_statement(FS20switches)
     main_words.register_statement(FS20send)
     register_condition(SwitchGroups.exists)
     register_condition(Switches.exists)
예제 #48
0
 def load(self):
     main_words.register_statement(RRDHandler)
     main_words.register_statement(RRDset)
     main_words.register_statement(VarRRDHandler)
     register_condition(RRDs.exists)
예제 #49
0
파일: qbroker.py 프로젝트: M-o-a-T/moat
 def load(self):
     main_words.register_statement(QBconnect)
     register_condition(QBconns.exists)
예제 #50
0
파일: qbroker.py 프로젝트: smurfix/MoaT
	def load(self):
		main_words.register_statement(QBconnect)
		register_condition(QBconns.exists)
예제 #51
0
 def load(self):
     main_words.register_statement(AVRconnect)
     main_words.register_statement(AVRsend)
     register_condition(AVRs.exists)
     register_condition(AVRconnected)