Exemplo n.º 1
0
	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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
Arquivo: amqp.py Projeto: 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)
Exemplo n.º 4
0
	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)
Exemplo n.º 5
0
	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)
Exemplo n.º 6
0
 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)
Exemplo n.º 7
0
	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)
Exemplo n.º 8
0
Arquivo: avg.py Projeto: 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)
Exemplo n.º 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)
Exemplo n.º 10
0
    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)
Exemplo n.º 11
0
Arquivo: net.py Projeto: 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)
Exemplo n.º 12
0
 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)
Exemplo n.º 13
0
 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)
Exemplo n.º 14
0
Arquivo: wago.py Projeto: 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)
Exemplo n.º 15
0
	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)
Exemplo n.º 16
0
    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)
Exemplo n.º 17
0
 def load(self):
     register_condition(ExistsPathCheck)
     register_condition(ExistsFileCheck)
     register_condition(ExistsDirCheck)
Exemplo n.º 18
0
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)
Exemplo n.º 19
0
 def load(self):
     main_words.register_statement(WaitHandler)
     main_words.register_statement(VarWaitHandler)
     register_condition(Waiters.exists)
Exemplo n.º 20
0
        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")
Exemplo n.º 21
0
	def load(self):
		main_words.register_statement(OnEventHandler)
		main_words.register_statement(OnSkip)
		main_words.register_statement(OnSkip2)
		register_condition(OnHandlers.exists)
Exemplo n.º 22
0
Arquivo: data.py Projeto: M-o-a-T/moat
	def load(self):
		main_words.register_statement(List)
		main_words.register_statement(Del)
		register_condition(VarCheck)
Exemplo n.º 23
0
Arquivo: rpc.py Projeto: smurfix/MoaT
	def load(self):
		main_words.register_statement(RPClisten)
		register_condition(RPCconns.exists)
		register_condition(RPCservers.exists)
Exemplo n.º 24
0
	def load(self):
		PREFIX[PREFIX_ENERGY] = en_handler()
		main_words.register_statement(FS20en)
		main_words.register_statement(FS20enVal)
		register_condition(ENs.exists)
Exemplo n.º 25
0
 def load(self):
     PREFIX[PREFIX_TX] = tx_handler()
     main_words.register_statement(FS20tx)
     main_words.register_statement(FS20txVal)
     register_condition(TXs.exists)
Exemplo n.º 26
0
	def load(self):
		main_words.register_statement(AVRconnect)
		main_words.register_statement(AVRsend)
		register_condition(AVRs.exists)
		register_condition(AVRconnected)
Exemplo n.º 27
0
Arquivo: wait.py Projeto: smurfix/MoaT
	def load(self):
		main_words.register_statement(WaitHandler)
		main_words.register_statement(VarWaitHandler)
		register_condition(Waiters.exists)
Exemplo n.º 28
0
Arquivo: bool.py Projeto: 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)
Exemplo n.º 29
0
	def load(self):
		PREFIX[PREFIX_TX] = tx_handler()
		main_words.register_statement(FS20tx)
		main_words.register_statement(FS20txVal)
		register_condition(TXs.exists)
Exemplo n.º 30
0
 def load(self):
     register_condition(TrueCheck)
     register_condition(FalseCheck)
     register_condition(NoneCheck)
     register_condition(EqualCheck)
     register_condition(LessCheck)
     register_condition(GreaterCheck)
Exemplo n.º 31
0
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 
Exemplo n.º 32
0
	def load(self):
		main_words.register_statement(LogHandler)
		main_words.register_statement(LogLevelHandler)
		register_condition(Loggers.exists)
Exemplo n.º 33
0
 def load(self):
     main_words.register_statement(OnEventHandler)
     main_words.register_statement(OnSkip)
     main_words.register_statement(OnSkip2)
     register_condition(OnHandlers.exists)
Exemplo n.º 34
0
 def load(self):
     main_words.register_statement(RPClisten)
     register_condition(RPCconns.exists)
     register_condition(RPCservers.exists)
Exemplo n.º 35
0
	def load(self):
		main_words.register_statement(LogHandler)
		main_words.register_statement(LogLevelHandler)
		register_condition(Loggers.exists)
Exemplo n.º 36
0
 def load(self):
     PREFIX[PREFIX_ENERGY] = en_handler()
     main_words.register_statement(FS20en)
     main_words.register_statement(FS20enVal)
     register_condition(ENs.exists)
Exemplo n.º 37
0
	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)
Exemplo n.º 38
0
	def load(self):
		main_words.register_statement(FS20switches)
		main_words.register_statement(FS20send)
		register_condition(SwitchGroups.exists)
		register_condition(Switches.exists)
Exemplo n.º 39
0
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):
Exemplo n.º 40
0
 def load(self):
     main_words.register_statement(List)
     main_words.register_statement(Del)
     register_condition(VarCheck)
Exemplo n.º 41
0
Arquivo: rrd.py Projeto: smurfix/MoaT
	def load(self):
		main_words.register_statement(RRDHandler)
		main_words.register_statement(RRDset)
		main_words.register_statement(VarRRDHandler)
		register_condition(RRDs.exists)
Exemplo n.º 42
0
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"
Exemplo n.º 43
0
		# 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")
Exemplo n.º 44
0
#	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):
        """\
Exemplo n.º 45
0
Arquivo: path.py Projeto: smurfix/MoaT
	def load(self):
		register_condition(ExistsPathCheck)
		register_condition(ExistsFileCheck)
		register_condition(ExistsDirCheck)
Exemplo n.º 46
0
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),)
Exemplo n.º 47
0
 def load(self):
     main_words.register_statement(FS20switches)
     main_words.register_statement(FS20send)
     register_condition(SwitchGroups.exists)
     register_condition(Switches.exists)
Exemplo n.º 48
0
 def load(self):
     main_words.register_statement(RRDHandler)
     main_words.register_statement(RRDset)
     main_words.register_statement(VarRRDHandler)
     register_condition(RRDs.exists)
Exemplo n.º 49
0
 def load(self):
     main_words.register_statement(QBconnect)
     register_condition(QBconns.exists)
Exemplo n.º 50
0
	def load(self):
		main_words.register_statement(QBconnect)
		register_condition(QBconns.exists)
Exemplo n.º 51
0
 def load(self):
     main_words.register_statement(AVRconnect)
     main_words.register_statement(AVRsend)
     register_condition(AVRs.exists)
     register_condition(AVRconnected)