Beispiel #1
0
		set output four foo bar
		log ERROR No four
	catch:
		log TRACE Yes

set output GRMPF foo bar
block:
	var input bla foo bar
	if equal $bla "TEST":
		log ERROR No $bla
	else:
		log TRACE Yes

list input foo bar
list output foo bar

shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("ifelse")
load_module("data")
load_module("block")
load_module("bool")
load_module("logging")
load_module("tests")
load_module("errors")

run("io",input)

Beispiel #2
0
set output 2 monitest2
wait :for 0.2
set output 4 monitest
set output 5 monitest2
wait :for 0.2
set output 5 monitest
set output 12 monitest2
list monitor
list monitor moni test
list monitor moni test2
wait :for 0.2
del monitor moni test
del monitor moni test2

shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("trigger")
load_module("monitor")
load_module("block")
load_module("data")
load_module("logging")
load_module("wait")
load_module("tests")
load_module("ifelse")
load_module("bool")
load_module("on_event")

run("monitor", input)
Beispiel #3
0
	codec application "json+obj"
log ERROR connected
try:
	wait shutdown:
		for 100
		debug force
wait foo b:
	for 1000
	debug force
shutdown
"""

main_words.register_statement(ShutdownHandler)
main_words.register_statement(Load)

load_module("wait")
load_module("logging")
#load_module("on_event")
load_module("net")
load_module("data")
load_module("block")
load_module("qbroker")
load_module("state")
load_module("errors")
#load_module("trigger")
load_module("help")

k = spawn(run, "qbroker", input)
j = spawn(gtester)
f = aiogevent.wrap_greenlet(j, loop=qbroker.loop)
#qbroker.loop.run_until_complete(f)
Beispiel #4
0
	if false:
		log ERROR No9
	else if false:
		log ERROR No10
	else:
		log TRACE Yes

block:
	if equal 2 2.0:
		log TRACE Yes
	else:
		log ERROR No11
	if equal 1 2:
		log ERROR No12
	else:
		log TRACE Yes
	if equal 0 Foo:
		log ERROR No13
	else:
		log TRACE Yes
shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("logging")
load_module("ifelse")
load_module("bool")
load_module("block")

run("ifelse", input)
Beispiel #5
0
from moat import patch
patch()
from moat.reactor import ShutdownHandler
from moat.module import load_module
from moat.statement import main_words
from test import run

input = """\
log limit parser NONE
log limit token NONE
log DEBUG
log TRACE "This is not logged"
log DEBUG "This is logged"
log WARN "This is logged too"
log
log PANIC
log WARN "This is not logged either"
log limit event TRACE
log TRACE
trigger Logged :sync
log limit event ERROR
trigger Not Logged :sync
"""

main_words.register_statement(ShutdownHandler)
load_module("logging")
load_module("trigger")

run("logging", input)
Beispiel #6
0
	log DEBUG PWM is now $value
	wait: for 0.1

block:
	if exists pwm foo bar:
		log TRACE Yes
	else:
		log ERROR No2
list pwm
list pwm foo bar
set pwm 0.1 foo bar
wait: for 0.5
list pwm foo bar
wait: for 8.5
list pwm foo bar
wait: for 15
list pwm
shutdown now
"""

main_words.register_statement(ShutdownHandler)
load_module("ifelse")
load_module("data")
load_module("pwm")
load_module("logging")
load_module("block")
load_module("wait")
load_module("on_event")

run("pwm", input)
Beispiel #7
0
		log TRACE Yes error
	
list rrd file a aa aaa
del rrd file a aa aaa
block:
	if exists rrd file a aa aaa:
		log ERROR No3
	else:
		log TRACE Yes
del rrd server t tt ttt
block:
	if exists rrd server t tt ttt:
		log ERROR No4
	else:
		log TRACE Yes
shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("trigger")
load_module("ifelse")
load_module("data")
load_module("rrdc")
load_module("logging")
load_module("block")
load_module("wait")
load_module("errors")

run("rrdc",input)

Beispiel #8
0
from moat import patch
patch()
from moat.reactor import ShutdownHandler
from moat.module import load_module
from moat.statement import main_words
from test import run

input = """\
async:
	wait Foo Bar: for 1.9
wait BEFORE: for 0.2
block:
	log DEBUG Start
	while exists wait Foo Bar:
		log DEBUG waiting
		wait DURING: for 0.7
		log DEBUG testing
	log DEBUG Done

wait AFTER: for 0.1
shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("loop")
load_module("wait")
load_module("block")
load_module("logging")

run("loop", input)
Beispiel #9
0
input = """\
trigger foo1
trigger bar1
wait A: for 0.1
trigger foo2 :sync
trigger bar2 :sync
wait B: for 0.1
skip this:
	trigger never the same
block:
	trigger foo3
	trigger bar3
wait C: for 0.1
block:
	if exists file "misc2":
		include "misc2"
	else:
		include "test/misc2"
shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("trigger")
load_module("wait")
load_module("block")
load_module("path")
load_module("file")
load_module("ifelse")

run("misc", input)
Beispiel #10
0
	if false:
		log ERROR No9
	else if false:
		log ERROR No10
	else:
		log TRACE Yes

block:
	if equal 2 2.0:
		log TRACE Yes
	else:
		log ERROR No11
	if equal 1 2:
		log ERROR No12
	else:
		log TRACE Yes
	if equal 0 Foo:
		log ERROR No13
	else:
		log TRACE Yes
shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("logging")
load_module("ifelse")
load_module("bool")
load_module("block")

run("ifelse",input)
Beispiel #11
0
		log ERROR No 82
	catch Foo Bar Baz:
		log ERROR No 83
	catch Foo Bar:
		log TRACE Yes O
	catch:
		log ERROR No 84
		
	try:
		trigger error Foo Bar
		log ERROR No 91
	catch *a:
		log ERROR No 92
	catch *a *b *c:
		log ERROR No 93
	catch *a *b:
		log TRACE Yes P $a $b
	catch:
		log ERROR No 94
		
shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("logging")
load_module("errors")
load_module("bool")
load_module("block")

run("errors",input)
Beispiel #12
0
	for 0.2
	debug force
list log
#syslog local1 trace localhost 55514
#log DEBUG "One Debug"
#del log local1 localhost 55514
## commented out because the next syslog call opens a new socket
## and netcat (used as a test listener) binds to the first one,
## which causes the second syslog line to not get received

syslog local5 info localhost 55514
log DEBUG "Five Debug"
log WARN "Five Warn"
list log
list log local5 localhost 55514
del log local5 localhost 55514
list log
wait:
	for 0.8
	debug force
shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("logging")
load_module("syslog")
load_module("wait")
load_module("data")

run("syslog", input)
Beispiel #13
0
	name="for"
	doc="for you!"
	
class WhatHandler(sbr,ComplexStatement):
	name="what"
	doc="What is this?"

class FoiledHandler(sbr,Statement):
	name="foiled"
	doc="not clingfilm"

BarHandler.register_statement(WhatHandler)
BarHandler.register_statement(ForHandler)
ForHandler.register_statement(FoiledHandler)
main_words.register_statement(FooHandler)
main_words.register_statement(BarHandler)
main_words.register_statement(ShutdownHandler)
load_module("help")

class TestInterpreter(Interpreter):
	def complex_statement(self,args):
		fn = self.ctx.words.lookup(args)
		fn = fn(self.ctx)
		fn.called(args)
		fn.start_block()
		return TestInterpreter(ctx=self.ctx(words=fn))
	def done(self):
		log(None,"... moving up")

run("parser", input, interpreter=TestInterpreter, logger=log)
Beispiel #14
0
##  This program is distributed in the hope that it will be useful,
##  but WITHOUT ANY WARRANTY; without even the implied warranty of
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##  GNU General Public License (included; see the file LICENSE)
##  for more details.
##
##  This header is auto-generated and may self-destruct at any time,
##  courtesy of "make update". The original is in ‘scripts/_boilerplate.py’.
##  Thus, do not remove the next line, or insert any blank lines above.
##BP

from moat.reactor import ShutdownHandler
from moat.module import Load,load_module
from moat.statement import main_words
from test import run

input = """\
load example
"""+("# This is a filler to test processing of really long files.\n"*10000)+"""\
del module example
shutdown
"""

main_words.register_statement(ShutdownHandler)
main_words.register_statement(Load)

load_module("data")

run("modules",input)

Beispiel #15
0
	if exists path "...":
		log ERROR No2
	else:
		log TRACE Yes
	if exists directory "..":
		log TRACE Yes
	else:
		log ERROR No3
	if exists directory "README":
		log ERROR No4
	else:
		log TRACE Yes
	if exists file "README":
		log TRACE Yes
	else:
		log ERROR No5
	if exists file "..":
		log ERROR No6
	else:
		log TRACE Yes
shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("logging")
load_module("ifelse")
load_module("path")
load_module("block")

run("path", input)
Beispiel #16
0
list fs20 tx tempix
list fs20 tx hygrix
#async:
#	wait:
#		for 0.1
#		debug force
#	del fs20 receiver foobar
#	wait:
#		for 0.1
#		debug force
#	del fs20 sender bar foo
wait:
	for 0.7
	debug force
#list fs20 receiver
#list fs20 sender
shutdown
"""

main_words.register_statement(ShutdownHandler)
main_words.register_statement(Load)

load_module("block")
load_module("file")
load_module("data")
load_module("ifelse")
load_module("path")

run("fs20",input)

Beispiel #17
0
list fs20 tx
list fs20 tx tempix
list fs20 tx hygrix
#async:
#	wait:
#		for 0.1
#		debug force
#	del fs20 receiver foobar
#	wait:
#		for 0.1
#		debug force
#	del fs20 sender bar foo
wait:
	for 0.7
	debug force
#list fs20 receiver
#list fs20 sender
shutdown
"""

main_words.register_statement(ShutdownHandler)
main_words.register_statement(Load)

load_module("block")
load_module("file")
load_module("data")
load_module("ifelse")
load_module("path")

run("fs20", input)
Beispiel #18
0
	if exists path "...":
		log ERROR No2
	else:
		log TRACE Yes
	if exists directory "..":
		log TRACE Yes
	else:
		log ERROR No3
	if exists directory "README":
		log ERROR No4
	else:
		log TRACE Yes
	if exists file "README":
		log TRACE Yes
	else:
		log ERROR No5
	if exists file "..":
		log ERROR No6
	else:
		log TRACE Yes
shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("logging")
load_module("ifelse")
load_module("path")
load_module("block")

run("path",input)
Beispiel #19
0
##BP

from moat import patch;patch()
from moat.reactor import ShutdownHandler
from moat.module import load_module
from moat.statement import main_words
from test import run

input = """\
log limit parser NONE
log limit token NONE
log DEBUG
log TRACE "This is not logged"
log DEBUG "This is logged"
log WARN "This is logged too"
log
log PANIC
log WARN "This is not logged either"
log limit event TRACE
log TRACE
trigger Logged :sync
log limit event ERROR
trigger Not Logged :sync
"""

main_words.register_statement(ShutdownHandler)
load_module("logging")
load_module("trigger")

run("logging",input)
Beispiel #20
0
from moat import patch;patch()
from moat.reactor import ShutdownHandler
from moat.module import load_module
from moat.statement import main_words
from test import run

input = """\
async:
	wait Foo Bar: for 1.9
wait BEFORE: for 0.2
block:
	log DEBUG Start
	while exists wait Foo Bar:
		log DEBUG waiting
		wait DURING: for 0.7
		log DEBUG testing
	log DEBUG Done

wait AFTER: for 0.1
shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("loop")
load_module("wait")
load_module("block")
load_module("logging")

run("loop",input)

Beispiel #21
0
from moat.reactor import ShutdownHandler, mainloop, shut_down
from moat.context import Context
from moat.twist import callLater, fix_exception
from moat.logging import log_level, NONE

from tokenize import tok_name
import os, sys

main_words.register_statement(Load)
main_words.register_statement(LoadDir)
main_words.register_statement(ShutdownHandler)

log_level("token", NONE)
log_level("parser", NONE)

load_module("help")
load_module("data")
load_module("file")
load_module("path")
load_module("ifelse")

syms = {}


def parse_logger(t, *x):
    x = list(x)
    try:
        x[1] = tok_name[x[1]]
    except KeyError:
        pass
    print(t + ":" + " ".join(str(d) for d in x))
Beispiel #22
0
		log TRACE "No‽ 2"
	if saved state foo bar:
		log TRACE "Yes!"
	else:
		log TRACE "No‽ 4"

block:
	var state x foo bar
	log TRACE We still have $x
del state foo bar
list state
block:
	if saved state foo bar:
		log TRACE "No‽ 9"
	else:
		log TRACE "Yes!"
shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("state")
load_module("block")
load_module("data")
load_module("on_event")
load_module("logging")
load_module("ifelse")
load_module("trigger")

run("persist2",input)

Beispiel #23
0
list rrd t tt ttt
wait: for 1.1
set rrd 10 t tt ttt
wait: for 1.1
set rrd 11 t tt ttt
wait: for 1.1
set rrd 12 t tt ttt
list rrd t tt ttt
block:
	var rrd x last_ds t tt ttt
	trigger last $x
del rrd t tt ttt
block:
	if exists rrd t tt ttt:
		log ERROR No3
	else:
		log TRACE Yes

"""

main_words.register_statement(ShutdownHandler)
load_module("trigger")
load_module("ifelse")
load_module("data")
load_module("rrd")
load_module("logging")
load_module("block")
load_module("wait")

run("rrd", input)
Beispiel #24
0
	for 0.2
	debug force
list log
#syslog local1 trace localhost 55514
#log DEBUG "One Debug"
#del log local1 localhost 55514
## commented out because the next syslog call opens a new socket
## and netcat (used as a test listener) binds to the first one,
## which causes the second syslog line to not get received

syslog local5 info localhost 55514
log DEBUG "Five Debug"
log WARN "Five Warn"
list log
list log local5 localhost 55514
del log local5 localhost 55514
list log
wait:
	for 0.8
	debug force
shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("logging")
load_module("syslog")
load_module("wait")
load_module("data")

run("syslog",input)
Beispiel #25
0
##  GNU General Public License (included; see the file LICENSE)
##  for more details.
##
##  This header is auto-generated and may self-destruct at any time,
##  courtesy of "make update". The original is in ‘scripts/_boilerplate.py’.
##  Thus, do not remove the next line, or insert any blank lines above.
##BP

from moat import patch
patch()
from moat.reactor import ShutdownHandler
from moat.module import load_module
from moat.statement import main_words
from test import run

input = """\
trigger foo :sync
wait: for 1m -90s 0.5min +.5s
trigger bar :sync
trigger baz notlogged :
	log NONE
	sync
shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("trigger")
load_module("wait")

run("trigger", input)
Beispiel #26
0
##  This program is distributed in the hope that it will be useful,
##  but WITHOUT ANY WARRANTY; without even the implied warranty of
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##  GNU General Public License (included; see the file LICENSE)
##  for more details.
##
##  This header is auto-generated and may self-destruct at any time,
##  courtesy of "make update". The original is in ‘scripts/_boilerplate.py’.
##  Thus, do not remove the next line, or insert any blank lines above.
##BP

from moat.reactor import ShutdownHandler
from moat.module import Load, load_module
from moat.statement import main_words
from test import run

input = """\
load example
""" + ("# This is a filler to test processing of really long files.\n" *
       10000) + """\
del module example
shutdown
"""

main_words.register_statement(ShutdownHandler)
main_words.register_statement(Load)

load_module("data")

run("modules", input)
Beispiel #27
0
		log TRACE "No‽ 7"
block:
	if last state two foo bar:
		log TRACE "Yes!"
	else:
		log TRACE "No‽ 6"
on whatever:
	var state x foo bar
	log TRACE We got $x
log DEBUG End1
trigger whatever :sync
log DEBUG End2
list state
log DEBUG End3
shutdown
log DEBUG End4
"""

main_words.register_statement(ShutdownHandler)
load_module("state")
load_module("block")
load_module("data")
load_module("on_event")
load_module("logging")
load_module("ifelse")
load_module("bool")
load_module("trigger")
load_module("errors")

run("persist1", input)
Beispiel #28
0
##  GNU General Public License (included; see the file LICENSE)
##  for more details.
##
##  This header is auto-generated and may self-destruct at any time,
##  courtesy of "make update". The original is in ‘scripts/_boilerplate.py’.
##  Thus, do not remove the next line, or insert any blank lines above.
##BP

from moat import patch;patch()
from moat.reactor import ShutdownHandler
from moat.module import load_module
from moat.statement import main_words
from test import run

input = """\
trigger foo :sync
wait: for 1m -90s 0.5min +.5s
trigger bar :sync
trigger baz notlogged :
	log NONE
	sync
shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("trigger")
load_module("wait")

run("trigger",input)

Beispiel #29
0
trigger foo1
trigger bar1
wait A: for 0.1
trigger foo2 :sync
trigger bar2 :sync
wait B: for 0.1
skip this:
	trigger never the same
block:
	trigger foo3
	trigger bar3
wait C: for 0.1
block:
	if exists file "misc2":
		include "misc2"
	else:
		include "test/misc2"
shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("trigger")
load_module("wait")
load_module("block")
load_module("path")
load_module("file")
load_module("ifelse")

run("misc",input)

Beispiel #30
0
on send logger:
	log DEBUG hello This is a test
try:
	wait shutdown:
		for 1
		debug force
wait foo b:
	for 1
	debug force
shutdown
"""

main_words.register_statement(ShutdownHandler)
main_words.register_statement(Load)

load_module("wait")
load_module("logging")
load_module("on_event")
load_module("net")
load_module("data")
load_module("block")
load_module("rpc")
load_module("state")
load_module("errors")
load_module("trigger")
load_module("help")

run("rpc",input)

import sys
sys.exit(0)
Beispiel #31
0
	wait: for 0.1

block:
	if exists pwm foo bar:
		log TRACE Yes
	else:
		log ERROR No2
list pwm
list pwm foo bar
set pwm 0.1 foo bar
wait: for 0.5
list pwm foo bar
wait: for 8.5
list pwm foo bar
wait: for 15
list pwm
shutdown now
"""

main_words.register_statement(ShutdownHandler)
load_module("ifelse")
load_module("data")
load_module("pwm")
load_module("logging")
load_module("block")
load_module("wait")
load_module("on_event")

run("pwm",input)

Beispiel #32
0
		log ERROR No 82
	catch Foo Bar Baz:
		log ERROR No 83
	catch Foo Bar:
		log TRACE Yes O
	catch:
		log ERROR No 84
		
	try:
		trigger error Foo Bar
		log ERROR No 91
	catch *a:
		log ERROR No 92
	catch *a *b *c:
		log ERROR No 93
	catch *a *b:
		log TRACE Yes P $a $b
	catch:
		log ERROR No 94
		
shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("logging")
load_module("errors")
load_module("bool")
load_module("block")

run("errors", input)
Beispiel #33
0
wait :for 0.2
set output 4 monitest
set output 5 monitest2
wait :for 0.2
set output 5 monitest
set output 12 monitest2
list monitor
list monitor moni test
list monitor moni test2
wait :for 0.2
del monitor moni test
del monitor moni test2

shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("trigger")
load_module("monitor")
load_module("block")
load_module("data")
load_module("logging")
load_module("wait")
load_module("tests")
load_module("ifelse")
load_module("bool")
load_module("on_event")

run("monitor",input)

Beispiel #34
0
		log DEBUG Y what $what
	else:
		log ERROR N what $what
list on
trigger run test:
	param also two
	sync
wait :for 0.1
list on
trigger test me
wait :for 60
shutdown
"""

main_words.register_statement(DoNothingHandler)
main_words.register_statement(ShutdownHandler)
load_module("block")
load_module("trigger")
load_module("on_event")
load_module("exec")
load_module("ifelse")
load_module("bool")
load_module("data")
load_module("logging")
load_module("state")
load_module("wait")
load_module("amqp")

run("exec",input)

Beispiel #35
0
	try:
		set output four foo bar
		log ERROR No four
	catch:
		log TRACE Yes

set output GRMPF foo bar
block:
	var input bla foo bar
	if equal $bla "TEST":
		log ERROR No $bla
	else:
		log TRACE Yes

list input foo bar
list output foo bar

shutdown
"""

main_words.register_statement(ShutdownHandler)
load_module("ifelse")
load_module("data")
load_module("block")
load_module("bool")
load_module("logging")
load_module("tests")
load_module("errors")

run("io", input)
Beispiel #36
0
from moat.reactor import ShutdownHandler,mainloop,shut_down
from moat.context import Context
from moat.twist import callLater,fix_exception
from moat.logging import log_level,NONE

from tokenize import tok_name
import os,sys

main_words.register_statement(Load)
main_words.register_statement(LoadDir)
main_words.register_statement(ShutdownHandler)

log_level("token",NONE)
log_level("parser",NONE)

load_module("help")
load_module("data")
load_module("file")
load_module("path")
load_module("ifelse")

syms = {}
def parse_logger(t,*x):
	x=list(x)
	try:
		x[1] = tok_name[x[1]]
	except KeyError:
		pass
	print(t+":"+" ".join(str(d) for d in x))

def reporter(err):
Beispiel #37
0
	codec application "json+obj"
log ERROR connected
try:
	wait shutdown:
		for 100
		debug force
wait foo b:
	for 1000
	debug force
shutdown
"""

main_words.register_statement(ShutdownHandler)
main_words.register_statement(Load)

load_module("wait")
load_module("logging")
# load_module("on_event")
load_module("net")
load_module("data")
load_module("block")
load_module("qbroker")
load_module("state")
load_module("errors")
# load_module("trigger")
load_module("help")

k = spawn(run, "qbroker", input)
j = spawn(gtester)
f = aiogevent.wrap_greenlet(j, loop=qbroker.loop)
# qbroker.loop.run_until_complete(f)